Efficient Manipulation of 'Rd' Files and Help Topics

Provides fast, cached lookup of help topics and aliases across installed, source, and in-development packages, plus efficient retrieval of parsed 'Rd' ('R' documentation) objects. Per-package indexes are built once and cached, making repeated retrieval cheap enough to call in a tight loop.


rdtools

R-CMD-check Codecov testcoverage

rdtools provides fast, cached lookup of help topics and aliases across installed, source, and in-development packages, plus efficient retrieval of parsed Rd objects. It’s low-level infrastructure designed to be shared by documentation tools like roxygen2, pkgdown, pkgload, and downlit, which currently each implement their own variant of this machinery.

Installation

You can install the development version of rdtools from GitHub with:

# install.packages("pak")
pak::pak("r-lib/rdtools")

Usage

pkg_topics() maps every alias a package documents to the Rd file that documents it:

library(rdtools)

head(pkg_topics("stats"))
#>    stats-package  .checkMFClasses      .getXlevels          .lm.fit 
#>  "stats-package" "checkMFClasses" "checkMFClasses"          "lmfit" 
#>         .MFclass    .nknots.smspl 
#> "checkMFClasses"  "smooth.spline"

topic_find() tells you which package documents a topic, searching the attached packages by default:

topic_find("rnorm")
#> $package
#> [1] "stats"
#> 
#> $file
#> [1] "Normal"

topic_split("dplyr::across")
#> $package
#> [1] "dplyr"
#> 
#> $topic
#> [1] "across"

topic_rd() retrieves the parsed Rd for a topic, fetching it lazily from the help database for installed packages, or parsing man/*.Rd for source packages:

rd <- topic_rd("rnorm", "stats")
class(rd)
#> [1] "Rd"

All lookups are backed by per-package indexes that remain cached until explicitly reset. Installed package indexes are reset when their namespace is unloaded, while source package indexes can be reset with pkg_cache_reset(). This makes lookups cheap enough to call in a tight loop (e.g. once per link while rendering documentation).

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("rdtools")

0.1.0 by Hadley Wickham, 3 months ago


https://rdtools.r-lib.org, https://github.com/r-lib/rdtools


Report a bug at https://github.com/r-lib/rdtools/issues


Browse source code at https://github.com/cran/rdtools


Authors: Hadley Wickham [aut, cre, cph] (ORCID: , Posit Software , PBC [cph, fnd] (ROR: <https://ror.org/03wc8by49>)


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports stats, tools

Suggests testthat, withr


Imported by roxygen2.


See at CRAN