Save a package manual to a file
save_manual.RdRenders a full package reference manual and writes it to a file.
Arguments
- package
(Scalar character)
The name of an installed package.- output
(Scalar character)
File path where the manual will be written. The extension must be one of.md,.html, or.htm.- md_format
(Scalar character:
md_format_default)
Pandoc output format string used for Markdown conversion. Only applies whenoutputhas a.mdextension. See Pandoc manual for available formats and extensions.- wrap
(Scalar integer:
Inf;[1, Inf])
Column width for word wrapping in Markdown output.Infdisables wrapping. Only applies whenoutputhas a.mdextension.
Details
For Markdown output, the function first renders the manual to a temporary HTML file via tools::pkg2HTML(), converts argument tables to HTML definition lists for cleaner Markdown output, then converts to Markdown using Pandoc.
Pandoc must be installed and on the system PATH.
The default markdown format is:
Examples
#----------------------------------------------------------------------------
# save_manual() example
#----------------------------------------------------------------------------
library(bkmisc)
# Save the tools package manual as markdown
tmp <- tempfile(fileext = ".md")
save_manual("tools", output = tmp)
readLines(tmp) |> head(20)
#> [1] "# Package {tools}"
#> [2] ""
#> [3] "## Contents"
#> [4] ""
#> [5] "- [](#tools-package)"
#> [6] ""
#> [7] " Tools for Package Development"
#> [8] ""
#> [9] "- [](#.print.via.format)"
#> [10] ""
#> [11] " Printing Utilities"
#> [12] ""
#> [13] "- [](#CRANtools)"
#> [14] ""
#> [15] " CRAN Package Repository Tools"
#> [16] ""
#> [17] "- [](#HTMLheader)"
#> [18] ""
#> [19] " Generate a Standard HTML Header for R Help"
#> [20] ""