I want to create a online help for my program using the qt help framework. My doc files are generated by doxygen, and I want to generate files for qt help generator from it.
My program is built with CMake, and I've added a target for generating documentation:
cmake_minimum_required (VERSION 3.21.0)
find_package(Doxygen REQUIRED dot)
set (DOXYGEN_HIDDEN_SYMBOLS "")
if (DOXYGEN_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile #ONLY)
doxygen_add_docs(
myprograme-manual
${CMAKE_CURRENT_SOURCE_DIR}/en
)
endif(DOXYGEN_FOUND)
The configure_file is needed because in the configuration I use come CMake variables, like the version of my program and so on.
This is the part of the doxyfile where I create the qhp file.
GENERATE_QHP = YES
# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify
# the file name of the resulting .qch file. The path specified is relative to
# the HTML output folder.
# This tag requires that the tag GENERATE_QHP is set to YES.
QCH_FILE = #DOC_OUTPUT_DIRECTORY#/manual.qch
# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help
# Project output. For more information please see Qt Help Project / Namespace
# (see:
# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace).
# The default value is: org.doxygen.Project.
# This tag requires that the tag GENERATE_QHP is set to YES.
QHP_NAMESPACE = my.program
# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt
# Help Project output. For more information please see Qt Help Project / Virtual
# Folders (see:
# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual-folders).
# The default value is: doc.
# This tag requires that the tag GENERATE_QHP is set to YES.
QHP_VIRTUAL_FOLDER = doc
# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom
# filter to add. For more information please see Qt Help Project / Custom
# Filters (see:
# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters).
# This tag requires that the tag GENERATE_QHP is set to YES.
QHP_CUST_FILTER_NAME =
# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the
# custom filter to add. For more information please see Qt Help Project / Custom
# Filters (see:
# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters).
# This tag requires that the tag GENERATE_QHP is set to YES.
QHP_CUST_FILTER_ATTRS =
# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
# project's filter section matches. Qt Help Project / Filter Attributes (see:
# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes).
# This tag requires that the tag GENERATE_QHP is set to YES.
QHP_SECT_FILTER_ATTRS =
# The QHG_LOCATION tag can be used to specify the location (absolute path
# including file name) of Qt's qhelpgenerator. If non-empty doxygen will try to
# run qhelpgenerator on the generated .qhp file.
# This tag requires that the tag GENERATE_QHP is set to YES.
QHG_LOCATION =
Problem is that the file is not generated. From the comments I can see that I need to define the QHG_LOCATION parameter, that's the full path of qhelpgenerator. Since I use CMake the qt path on the computer is not fixed, and I use find_package in order to use Qt. How can I define a variable from the find_package(Qt) that allows me to define the location of the qhelpgenerator?
Related
I'm trying to attach a custom css stylesheet to style my shiny app. However I haven't had much success. I know that there is many ways to do it, but according to chapter 4 of Outstanding UI with Shiny (right after figure 4.3) the best way to do so seems to be with htmlDependency() and tagList().
I have created my dependency as shown below:
css_dependency <- function() {
htmlDependency(
name = "css dep",
version = "1.0",
src = "./www",
stylesheet = "styles.css"
)
}
However I am not sure how to attach it and where to attach it. With my browser developer tool, I can see that most dependencies seems to be in the <head> tag. Should I attach it like that?
tagList(head, css_dependency())
Also, I am not quite sure where I should call the tagList() function. Would that be directly in ui?
I can't seem to find many information on that method so any help would be appreciated. Thank you.
I think htmlDependency() is designed to be use with package. It constructs path to the file using passed arguments, but I think it won't work if there is no package. I made some experiments and it looks like it locates library directory and constructs path using name, version etc. So it doesn't make sense (at least because version is included in the path) without package.
Let's now divide the answer if we have a package or not:
1. A package.
You are close, but I would:
css_dependency <- function() {
htmlDependency(
name = "css_dep",
version = utils::packageVersion("name_of_your_package"),
package = "name_of_your_package",
src = "./www",
stylesheet = "styles.css"
)
}
Assuming styles.css file is inside www directory and www directory is inside inst directory (inst directory is use to install elements inside as is when package is installed by user), I have changed:
space from name - replaced by _ (just for safe);
hard-coded version number - now the version number will be the same as package version number (for convenience);
new argument added - package name;
And how to use it?
tagList() makes it possible to return (e.g. by a function) multiple tags - it is e.g. needed in modules, without tagList() the function would return only the last tag. The usage is:
library(shiny)
tagList(tags$h1("h1"), tags$h2("h2"))
And it returns:
<h1>h1</h1>
<h2>h2</h2>
i.e. both tags at once.
I'm talking about this, because your example (tagList(head, css_dependency())) is wrong, inside tagList() you need to use tags in the same way like in the UI part of app directly.
How to include dependency then? It will be just:
tags$head(css_dependency())
Because you are right that dependencies should be inside head tag. And there is no need to use tagList() directly in the UI part (use it if you need to return multiple tags by some function which will be used in the UI part)
2. Not a package.
We should use different approach than htmlDependency(). I would say:
tags$head(tags$link(rel = "stylesheet", type = "text/css", href = "path_to_the_file"))
"path_to_the_file" is:
relative to the directory where is a root of the application (i.e. where app.R or server.R and ui.R lives), so if you made a directory css/my_stylesheet.css, then it will be: tags$head(tags$link(rel = "stylesheet", type = "text/css", href = "css/my_stylesheet.css"));
however if you - the same as in your example - put your css file in www directory and www directory will be in the same directory where is a root of the application (i.e. not in some subdirectories), then you won't include www in path, because Shiny is designed to detect www directory automatically as a directory where will be css and js files., so in this case if my_stylesheet.css will be in www directory, the path will be: tags$head(tags$link(rel = "stylesheet", type = "text/css", href = "my_stylesheet.css"))
So I am following the guide here which indicates the way to access photos is as follows:
flags <- c(
system.file("img", "flag", "au.png", package = "ggpattern"),
system.file("img", "flag", "dk.png", package = "ggpattern")
)
My goal is to now use this code for my own uses, so I saved a few images in a folder. Here is my directory:
"C:/Users/Thom/Docs/Misc/Testy"
And within the Testy folder, there is a folder called image, holding 3 images. But the following doesn't seem to work and idk why...
images <- c(
system.file("image", "image1.png", package = "ggpattern"),
system.file("image", "image2.png", package = "ggpattern")
)
system.file is for use when a file included in a package. Basically, it will look for the file starting its search path to where your R packages are installed (because this can vary from user to user). system.file will return the resolved path to the file locally
If you already know the absolute path on your local computer (i.e. "C:/Users/Thom/Docs/Misc/Testy") you can use that as just the input to a read function, e.g. readBin("C:/Users/Thom/Docs/Misc/Testy")
If you want to get a little fancy or are like me and can't ever remember which direction of a slash to use on which OS, you can also do something like this which will add in the OS specific path separator:
readBin(file.path("C:", "Users", "Thom", "Docs", "Misc", "Testy"))
I've been having difficulty getting boxr to successfully create a file within my box directory. My code reads:
library(boxr)
box_auth()
my_file_dir <- box_setwd("76009318507")
box_dir_create(dir_name="TEST", parent_dir_id = my_file_dir)
after running which, I get the following output:
box.com remote folder reference
name :
dir id :
size :
modified at :
created at :
uploaded by :
owned by :
shared link : None
parent folder name :
parent folder id :
Checking my box directory, I find no folders have been created.
I've tried using additional arguments within box_dir_create, but according to the documentation only dir_name and parent_dir_name are accepted.
Any help is much appreciated. I understand this is a somewhat obscure R package, so I've included links to the documentation below:
https://cran.r-project.org/web/packages/boxr/boxr.pdf
https://github.com/r-box/boxr
I got an answer via the package's developer, and I figured I'd pay it forward for any fellow travelers in the future.
It turns out that box_setwd() sets a default directory but returns nothing. Using
box_dir_create(dir_name="TEST", parent_dir_id = "76009318507")
creates the folder successfully. It will not do so if a folder of the same name is already created.
After more digging, I was also told that box_dir_create() is quietly passing back a lot of useful information, including the newly created directory's ID. To access it you can save the function results as a variable, like so:
b <- box_dir_create("test_dir")
names(b) # lots of info
b$id # what you want
box_ul(b$id, "image_file.jpg") # is this file by file?
box_push(b$id, "image_directory/") # or a directory wide operation?
Thanks for your help, and I hope this helps someone else down the road. Cheers!
From Documenter.jl's documentation of #autodocs:
[...], a Pages vector may be included in #autodocs to filter
docstrings based on the source file in which they are defined:
```#autodocs
Modules = [Foo]
Pages = ["a.jl", "b.jl"]
```
However, it also says
Note that page matching is done using the end of the provided strings
and so a.jl will be matched by any source file that ends in a.jl, i.e.
src/a.jl or src/foo/a.jl.
How can I restrict the #autodocs block to specific source files?
My package's source code is organized as
src/
foo/a.jl
foo/b.jl
ignore/a.jl
ignore/b.jl
other.jl
How to make the #autodocs block only consider files src/foo/a.jl and src/foo/b.jl but not src/ignore/a.jl and src/ignore/b.jl?
Unfortunately, Pages = ["foo/a.jl", "foo/b.jl"] didn't do it for me.
Thanks in advance.
x-ref: https://discourse.julialang.org/t/documenter-jl-autodocs-for-specific-source-files/8784
x-ref: https://github.com/JuliaDocs/Documenter.jl/issues/630
Turns out that this is a Windows issue due to absence of normalization of path separators (see linked github issue).
On Linux Pages = ["foo/a.jl", "foo/b.jl"] should work.
On Windows Pages = ["foo\\a.jl", "foo\\b.jl"] should work.
EDIT: joinpath.("foo", ["a.jl", "b.jl"]) should work on any OS.
I'm having some issues displaying an interactive map in R-Shiny that incorporates a KML file. I installed leaflet-plugins and was able to create an HTML file that displays properly by itself in the browser but not within Shiny. This attempt followed an example here - the code is available if you view source.
Because this initial version does not require the HTML itself to change, I attempted to follow the samples here to include the raw HTML in my page but I receive a 404 error with these as well as when I attempted to include it as an iframe within R-Shiny (following this discussion). I then set up an external facing server for both the KML file and the HTML file and got the same result.
I was able to get a map working without the KML file with leaflet-shiny but I'm frankly not sure how to add the KML file and don't see this in the documentation.
Finally, I tried rMaps which does have a "addKML" method, but I can't get it working with various locations of files on my server (
map1 = Leaflet$new()
map1$setView(c(45.5236, -122.675), 13)
map1$tileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png")
map1$addKML('http://kml-samples.googlecode.com/svn/trunk/kml/Placemark/placemark.kml')
map1
It works without the $addKML line. It might be worth noting that the tilelayer line on example 1 here also resulted in a blank map.
I actually have some possibly similar issues hosting derived title layers that are still unresolved which is one reason I opted for uses KML layers for this demo version of the application, which is why I tagged networking on here as well. I'm using Digital Ocean.
Thank you for any thoughts or pointers you may have.
I think there may be a small issue in the rMaps library. If you inspect the config.yml file
https://github.com/ramnathv/rCharts/blob/master/inst/libraries/leaflet/config.yml you will see that for
content delevery network (cdn) there is reference to
"http://harrywood.co.uk/maps/examples/leaflet/leaflet-plugins/layer/vector/KML.js". This KML reader is a plugin for leaflet from https://github.com/shramov/leaflet-plugins/blob/master/layer/vector/KML.js. When content is delivered locally:
css: [external/leaflet.css, external/leaflet-rCharts.css, external/legend.css]
jshead:
- external/leaflet.js
- external/leaflet-providers.js
- external/Control.FullScreen.js
there is no reference to this javascript file. We can fix this:
require(yaml)
leafletLib <- file.path(find.package("rMaps"), "libraries", "leaflet")
rMapsConfig <- yaml.load_file(file.path(leafletLib, "config.yml"))
# add a kml library
kmlLib <- readLines("http://harrywood.co.uk/maps/examples/leaflet/leaflet-plugins/layer/vector/KML.js")
write(kmlLib, file.path(leafletLib, "external", "leaflet-kml.js"))
# add the library to config.yml
rMapsConfig$leaflet$jshead <- union(rMapsConfig$leaflet$jshead , "external/leaflet-kml.js")
write(as.yaml(rMapsConfig), file.path(leafletLib, "config.yml"))
Now the config.yml will contain the necessary link to the KML reader and there is a local copy stored now in external/leaflet-kml.js. Our example still wont work however as we will get a Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://kml-samples.googlecode.com/svn/trunk/kml/Placemark/placemark.kml. This can be fixed by moving the resource to the same domain or enabling CORS.
We will need to have this file served locally. We can place it as a temporary measure in the leaflet folder in the rMaps package. When a map is created this folder gets copied to a temporary file:
require(rMaps)
map1 = Leaflet$new()
map1$setView(c(45.5236, -122.675), 13)
map1$tileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png")
map1$addKML('leaflet/placemark.kml')
# temp copy http://kml-samples.googlecode.com/svn/trunk/kml/Placemark/placemark.kml
# to rMaps
sampleKml <- readLines('http://kml-samples.googlecode.com/svn/trunk/kml/Placemark/placemark.kml')
write(sampleKml, file.path(leafletLib, 'placemark.kml'))
# finally try the map
map1
# remove the temp file
file.remove(file.path(leafletLib, 'placemark.kml'))
UPDATE:
There is an addAssets method in rCharts which allows you to add .js files. This allows us to simpilfy things and doesnt require us to write a copy of the js file nor edit the config.yml file.
require(rMaps)
map1 = Leaflet$new()
map1$setView(c(45.5236, -122.675), 13)
map1$tileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png")
map1$addAssets(css = NULL, jshead = 'http://harrywood.co.uk/maps/examples/leaflet/leaflet-plugins/layer/vector/KML.js')
map1$addKML('leaflet/placemark.kml')
leafletLib <- file.path(find.package("rMaps"), "libraries", "leaflet")
sampleKml <- readLines('http://kml-samples.googlecode.com/svn/trunk/kml/Placemark/placemark.kml')
write(sampleKml, file.path(leafletLib, 'placemark.kml'))
# finally try the map
map1
# remove the temp file
file.remove(file.path(leafletLib, 'placemark.kml'))