char2Rdpiece: Convert a character vector to Rd piece

View source: R/elements.R

char2RdpieceR Documentation

Convert a character vector to Rd piece

Description

Convert a character vector to Rd piece.

Usage

char2Rdpiece(content, name, force.sec = FALSE)

Arguments

content

a character vector.

name

name of an Rd macro, a string.

force.sec

TRUE or FALSE, see ‘Details’.

Details

Argument content is converted to an Rd piece using name to determine the format of the result.

The ⁠Rd tag⁠ of content is set as appropriate for name. More specifically, if name is the name of a macro (without the leading '⁠\⁠') whose content has a known "Rdtag", that tag is used. Otherwise the tag is set to "TEXT".

If force.sec is TRUE, name is treated as the name of a top level section of an Rd object. A top level section is exported as one argument macro if it is a standard section (detected with is_Rdsecname) and as the two argument macro "⁠\section⁠" otherwise.

If force.sec is FALSE, the content is exported as one argument macro without further checks.

Note

This function does not attempt to escape special symbols like ‘%’.

Author(s)

Georgi N. Boshnakov

Examples

## add a keyword section
a1 <- char2Rdpiece("graphics", "keyword")
a1
## "keyword" is a standard Rd top level section, so 'force.sec' is irrelevant
a2 <- char2Rdpiece("graphics", "keyword", force.sec = TRUE)
identical(a1, a2)

## an element suitable to be put in a "usage" section
char2Rdpiece("log(x, base = exp(1))", "usage")

## a user defined section "Todo"
char2Rdpiece("Give more examples for this function.", "Todo", force.sec = TRUE)

Rdpack documentation built on Nov. 8, 2023, 5:06 p.m.