Theme R manual pages with roxygen2
The @theme
tag allows adding CSS and JS files to the HTML version of
the manual pages.
To support @theme
, you need to use the roxygenlabs_rd
roclet. E.g.
add this to DESCRIPTION
:
1 2 | Roxygen: { library(roxygenlabs); list(markdown = TRUE,
roclets = c("collate", "namespace", "roxygenlabs_rd")) }
|
and then use the @theme
tag to add CSS/JS files to all manual pages.
Multiple file names can be specicified in a single @theme
tag, and
file names are relative to the inst/doc
directory, within the package:
1 | #' @theme assets/extra.css assets/rd.js
|
See the assets/extra.css
and assets/rd.js
files, included in the
package, for an example CSS/JS theme that has the following changes
compared to plain Rd documentation:
R code is syntax-highlighted. This includes R code in the “Usage”
and “Examples” sections, R code created via “r” fences in roxygen’s
markdown, and R code chunks produced by roxygen’s @includeRmd
tag.
Add a “Copy” button to R code chunks, to copy them to the clipboard.
Headings have a new style, including a serif font.
More spacious formatting of arguments and list.
Restrict the width of the manual page, to avoid very long lines.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.