get_rd: Safely retrieve help documentation objects

View source: R/get_rd.R

get_rdR Documentation

Safely retrieve help documentation objects

Description

The function is using function provided by utils package, to retrieve a R documentation object. It retrieve documentation either directly form the source .Rd file, or extract it using help function. See Arguments section to get to know more about when each mode is called.

Usage

get_rd(topic, package, file = NULL, macros = NULL)

Arguments

topic

usually, a name or character string specifying the topic for which help is sought. A character string (enclosed in explicit single or double quotes) is always taken as naming a topic.

If the value of topic is a length-one character vector the topic is taken to be the value of the only element. Otherwise topic must be a name or a reserved word (if syntactically valid) or character string.

See ‘Details’ for what happens if this is omitted.

package

a name or character vector giving the packages to look into for documentation, or NULL. By default, all packages whose namespaces are loaded are used. To avoid a name being deparsed use e.g. (pkg_ref) (see the examples).

file

Alternatively, provide a .Rd filepath. When file is provided, other arguments are ignored.

macros

Filename or environment from which to load additional macros, or a logical value. See the Details below.

Details

macros and file parameters are used directly by the tools::parse_Rd function. Please refer to details of this function to get to know more about their usage. The rd2markdown package adds an additional behavior to the original macros. If it is NA then get_rd will try to find macros directory associated with passed file and pass it to tools::parse_Rd.

Examples

# Retrieve documentation directly form the .Rd file
rd_file_example <- system.file("examples", "rd_file_sample.Rd", package = "rd2markdown")
rd2markdown::get_rd(file = rd_file_example)

# Retrieve documentation from an installed package
rd2markdown::get_rd(topic = "rnorm", package = "stats")

# Auto discover macros
rd2markdown::get_rd(file = rd_file_example, macros = NA)
  

Genentech/rd2markdown documentation built on Feb. 28, 2025, 1:27 p.m.