Skip to content

Commit a26e5d8

Browse files
committed
close #51: add an argument overview = TRUE to pkg_manual()
1 parent 2c0eb54 commit a26e5d8

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

R/package.R

+9-4
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,14 @@ tweak_citation = function(x) {
269269
x
270270
}
271271

272+
#' @param overview Whether to include the package overview page, i.e., the
273+
#' `{name}-package.Rd` page.
272274
#' @return `pkg_manual()` returns all manual pages of the package in HTML.
273275
#' @rdname pkg_desc
274276
#' @export
275-
pkg_manual = function(name = detect_pkg(), toc = TRUE, number_sections = TRUE) {
277+
pkg_manual = function(
278+
name = detect_pkg(), toc = TRUE, number_sections = TRUE, overview = TRUE
279+
) {
276280
links = tools::findHTMLlinks('')
277281
# resolve internal links (will assign IDs of the form sec:man-ID to all h2)
278282
r = sprintf('^[.][.]/[.][.]/(%s)/html/(.+)[.]html$', name)
@@ -285,14 +289,15 @@ pkg_manual = function(name = detect_pkg(), toc = TRUE, number_sections = TRUE) {
285289
links = sub(r, 'https://rdrr.io/cran/\\1/man/', links)
286290

287291
db = tools::Rd_db(name) # all Rd pages
292+
intro = paste0(name, '-package') # the name-package entry (package overview)
293+
entries = setdiff(names(db), intro)
294+
db = db[c(if (overview && intro %in% names(db)) intro, entries)]
288295
al = lapply(db, Rd_aliases)
289296

290297
cl = header_class(toc, number_sections, FALSE)
291298
r1 = '<code class="reqn">\\s*([^<]+?)\\s*</code>' # inline math
292299
r2 = sprintf('<p[^>]*>\\s*%s\\s*</p>', r1) # display math
293-
# show the page name-package first
294-
idx = vapply(al, is.element, el = paste0(name, '-package'), FALSE)
295-
res = uapply(names(db)[order(!idx)], function(i) {
300+
res = uapply(names(db), function(i) {
296301
txt = ''
297302
con = textConnection('txt', 'w', local = TRUE, encoding = 'UTF-8')
298303
tryCatch(

man/fuse_book.Rd

+2-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/pkg_desc.Rd

+9-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)