Rd_canonize: Rd Canonical Form
Description
Canonical form is simply described as that which would come out from reading
an Rd file via, tools::parse_Rd()
.
Usage
Rd_canonize(rd, ..., .check = TRUE)Rd_canonize_text(rd, .check = TRUE, ...)
Rd_canonize_code(rd, .check = TRUE, ...)
Arguments
rd
the Rd container object to put in canonical form.
...
Arguments passed on to is_valid_Rd_object
- x
object to test
- strict
if the class must be set. A value of NA indicates that the
first level need not be classed but all subsequent must be.
- tags
the type of tag(s) allowed in the Rd_tag
attribute.
- deep
should contained elements also be checked for validity?
Details
Canonical Rd Text has:
One line per element, with attr(., 'Rd_tag')=='TEXT'
The indents are merged with content if the first content is text.
Newlines are contained with the content provided the content is 'TEXT',
but the newline must be the last character in the string and cannot appear anywhere else.
Comments are a separate class and do not include the newline.
Canonical R code follows the following rules:
One element per line of code.
newline is included at the end of the line string,
not as a separate element.
if there are multiple lines they are bound together in an Rd or Rd_tag list.
Examples
Run this code# NOT RUN {
## Rd_c does not guarantee canonical code.
x <- Rd_c(Rd('Testing'), Rd('\n'))
str(x)
str(Rd_canonize(x))
# }
Run the code above in your browser using DataLab