pkg2HTML {tools}R Documentation

Rd Converters

Description

Generate a single-page HTML reference manual from the Rd sources contained in an installed or source R package.

Usage

pkg2HTML(package, dir = NULL, lib.loc = NULL,
         outputEncoding = "UTF-8",
         stylesheet = file.path(R.home("doc"), "html", "R-nav.css"),
         hooks = list(pkg_href = function(pkg) sprintf("%s.html", pkg)),
         texmath = getOption("help.htmlmath"),
         prism = TRUE,
         out = NULL,
         toc_entry = c("title", "name"),
         ...,
         Rhtml = FALSE,
         mathjax_config = file.path(R.home("doc"), "html", "mathjax-config.js"),
         include_description = TRUE)

Arguments

package

a character string, typically giving the name of an installed package. Can also be a file path or URL pointing to a source tarball (this feature is experimental).

dir

character string giving the path to a directory containing an installed or source package.

lib.loc

a character vector describing the location of R library trees to search through, or NULL. Passed on to find.package and Rd_db.

outputEncoding

character string; see Rd2HTML.

stylesheet

character string giving URL containing CSS style information.

hooks

A list of functions controlling details of output. Currently the only component used is pkg_href, which is used to determine the output HTML file path given a package name as input.

texmath

character string controlling math rendering library to be used, either "katex" or "mathjax". The default is to use "katex", unless the package appears to use the mathjaxr package in at least one of its documentation files. The support for MathJax is experimental and may not work well.

prism

logical flag controlling code highlighting, as described in Rd2HTML.

out

a filename or connection object to which to write the output. By default (NULL), the filename is inferred from hooks$pkg_href, which defaults to ‘pkg.html’.

toc_entry

Determines whether the entry for a help page in the table of contents is the name of the help page or its title.

...

additional arguments, passed on to Rd2HTML. The stages argument, if specified, is passed on to Rd_db.

Rhtml

logical: whether the output is intended to be a Rhtml file that can be processed using knitr. If TRUE, the examples section is wrapped inside a rcode block.

mathjax_config

character string giving path of file containing configuration instructions for mathjax. Relevant only if texmath = "mathjax".

include_description

logical flag indicating whether the output should begin with the contents of the DESCRIPTION file.

Details

The pkg2HTML function is intended to produce a single-page HTML reference manual for a given package, with links to other packages. The URLs of links to external packages are controlled by the provided hooks.

The handling of ⁠\Sexpr⁠-s are necessarily incomplete, but can be controlled to some extent by specifying the stages argument. Best results are likely for installed packages.

Value

The name of the output file (invisibly).

Author(s)

Deepayan Sarkar

See Also

parse_Rd, Rd_db, Rd2HTML.

Examples


pkg2HTML("tools", out = tempfile(fileext = ".html")) |> browseURL()


[Package tools version 4.4.1 Index]