Skip to content

Commit 723222c

Browse files
author
deepayan
committed
document and export pkg2HTML
git-svn-id: https://svn.r-project.org/R/trunk@86206 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent a285b77 commit 723222c

File tree

3 files changed

+96
-1
lines changed

3 files changed

+96
-1
lines changed

doc/NEWS.Rd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,9 @@
279279
been updated to use the GPL-compatible licence published by
280280
Oracle America in 2010.
281281

282+
New function \code{pkg2HTML()} in \pkg{tools} to create
283+
single-page HTML reference manuals for R packages.
284+
282285
}
283286
}
284287

src/library/tools/NAMESPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ useDynLib(tools, .registration = TRUE, .fixes = "C_")
22

33
## Bootstrapping R ==> do _not_ import, rather use ' :: '
44

5-
export("Adobe_glyphs", "HTMLheader", "Rcmd", "Rd2HTML", "Rd2ex",
5+
export("Adobe_glyphs", "HTMLheader", "Rcmd", "Rd2HTML", "pkg2HTML", "Rd2ex",
66
"Rd2latex", "Rd2txt", "Rd2txt_options", "RdTextFilter", "Rd_db",
77
"Rdiff", "Rdindex", "SweaveTeXFilter", "add_datalist",
88
"as.Rconcordance",

src/library/tools/man/pkg2HTML.Rd

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
% File src/library/tools/man/pkg2HTML.Rd
2+
% Part of the R package, https://www.R-project.org
3+
% Copyright 2024 R Core Team
4+
% Distributed under GPL 2 or later
5+
6+
\name{pkg2HTML}
7+
\alias{pkg2HTML}
8+
\title{ Rd Converters }
9+
\description{
10+
Generate a single-page HTML reference manual from the Rd sources
11+
contained in an installed or source R package.
12+
}
13+
\usage{
14+
pkg2HTML(package, dir = NULL, lib.loc = NULL,
15+
outputEncoding = "UTF-8",
16+
stylesheet = R.home("doc/html/R-nav.css"),
17+
hooks = list(pkg_href = function(pkg) sprintf("\%s.html", pkg)),
18+
texmath = getOption("help.htmlmath"),
19+
prism = TRUE,
20+
out = NULL,
21+
...,
22+
Rhtml = FALSE,
23+
include_description = TRUE)
24+
}
25+
\arguments{
26+
27+
\item{package}{ character string giving either the name of an
28+
installed package, or a file path or URL pointing to a source tarball.
29+
}
30+
\item{dir}{ character string giving the path to a directory containing
31+
an installed or source package.
32+
}
33+
34+
\item{lib.loc}{a character vector describing the location of \R
35+
library trees to search through, or \code{NULL}. Passed on to
36+
\code{\link{find.package}} and \code{\link{Rd_db}}.
37+
}
38+
\item{outputEncoding}{ character string; see \code{\link{Rd2HTML}}. }
39+
\item{stylesheet}{ character string giving URL containing CSS style
40+
information.
41+
}
42+
\item{hooks}{A list of functions controlling details of
43+
output. Currently the only component used is \code{pkg_href}, which
44+
is used to determine the output HTML file path given a package name
45+
as input.
46+
}
47+
\item{texmath, prism}{ logical flags, passed on to
48+
\code{\link{Rd2HTML}}.
49+
}
50+
\item{out}{a filename or connection object to which to write the
51+
output. The default \code{out = ""} is equivalent to
52+
\code{out = \link{stdout}()}.}
53+
\item{...}{additional arguments, passed on to
54+
\code{\link{Rd2HTML}}. The \code{stages} argument, if specified, is
55+
passed on to \code{\link{Rd_db}}.
56+
}
57+
\item{Rhtml}{logical: whether the output is intended to be a \I{Rhtml}
58+
file that can be processed using \CRANpkg{knitr}. If \code{TRUE}, the
59+
examples section is wrapped inside a \code{rcode} block.
60+
}
61+
\item{include_description}{ logical flag indicating whether the output
62+
should begin with the contents of the \code{DESCRIPTION} file.
63+
}
64+
}
65+
66+
\details{
67+
The \code{pkg2HTML} function is intended to produce a single-page HTML
68+
reference manual for a given package, with links to other
69+
packages. The URLs of links to external packages are controlled by the
70+
provided hooks.
71+
72+
The handling of \verb{\Sexpr}-s are necessarily incomplete, but can be
73+
controlled to some extent by specifying the \code{stages}
74+
argument. Best results are likely for installed packages.
75+
}
76+
77+
\value{
78+
The name of the output file(invisibly).
79+
}
80+
\author{
81+
Deepayan Sarkar
82+
}
83+
\seealso{
84+
\code{\link{parse_Rd}}, \code{\link{Rd_db}},
85+
\code{\link{Rd2HTML}}.
86+
}
87+
\examples{
88+
\donttest{
89+
pkg2HTML("tools", out = tempfile(fileext = ".html")) |> browseURL()
90+
}
91+
}
92+
\keyword{ documentation }

0 commit comments

Comments
 (0)