Rdo_collect_metadata: Collect aliases or other metadata from an Rd object

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/manip.R

Description

Collect aliases or other metadata from an Rd object.

Usage

1
2
3

Arguments

rdo

an Rd object

sec

the kind of metadata to collect, a character string, such as "alias" and "keyword".

Details

Rdo_collect_aliases finds all aliases in rdo and returns them as a named character vector. The name of an alias is usually the empty string, "", but it may also be "windows" or "unix" if the alias is wrapped in a #ifdef directive with the corresponding first argument.

Rdo_collect_metadata is a generalisation of the above. It collects the metadata from section(s) sec, where sec is the name of a section without the leading backslash. sec is assumed to be a section containing a single word, such as "keyword", "alias", "name".

Currently Rdo_collect_metadata is not exported.

Value

a named character vector, as described in Details.

Author(s)

Georgi N. Boshnakov

See Also

tools:::.Rd_get_metadata

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## this example originally (circa 2012) was:
##     infile <- file.path(R.home(), "src/library/base/man/timezones.Rd")
## but the OS conditional alias in that file has been removed.
## So, create an artificial example:
infile <- system.file("examples", "tz.Rd", package = "Rdpack")

## file.show(infile)
rd <- tools::parse_Rd(infile)

## The functions described here handle "ifdef" and similar directives.
## This detects OS specific aliases (windows = "onlywin" and unix = "onlyunix"):
Rdo_collect_aliases(rd)
Rdpack:::Rdo_collect_metadata(rd, "alias") # same

## In contrast, the following do not find "onlywin" and "onlyunix":
sapply(rd[which(tools:::RdTags(rd)=="\alias")], as.character)
tools:::.Rd_get_metadata(rd, "alias")

Rdpack:::Rdo_collect_metadata(rd, "name")
Rdpack:::Rdo_collect_metadata(rd, "keyword")

Rdpack documentation built on May 24, 2018, 5:04 p.m.