Convert a character vector to Rd piece
char2Rdpiece.Rd
Convert a character vector to Rd piece.
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.
Examples
## add a keyword section
a1 <- char2Rdpiece("graphics", "keyword")
a1
#> [[1]]
#> [1] "graphics"
#> attr(,"Rd_tag")
#> [1] "TEXT"
#>
#> attr(,"Rd_tag")
#> [1] "\\keyword"
## "keyword" is a standard Rd top level section, so 'force.sec' is irrelevant
a2 <- char2Rdpiece("graphics", "keyword", force.sec = TRUE)
identical(a1, a2)
#> [1] TRUE
## an element suitable to be put in a "usage" section
char2Rdpiece("log(x, base = exp(1))", "usage")
#> [[1]]
#> [1] "log(x, base = exp(1))"
#> attr(,"Rd_tag")
#> [1] "RCODE"
#>
#> attr(,"Rd_tag")
#> [1] "\\usage"
## a user defined section "Todo"
char2Rdpiece("Give more examples for this function.", "Todo", force.sec = TRUE)
#> [[1]]
#> [[1]][[1]]
#> [1] "Todo"
#> attr(,"Rd_tag")
#> [1] "TEXT"
#>
#>
#> [[2]]
#> [[2]][[1]]
#> [1] "Give more examples for this function."
#> attr(,"Rd_tag")
#> [1] "TEXT"
#>
#>
#> attr(,"Rd_tag")
#> [1] "\\section"