Converts an Rd object to Rd format and saves it to a file or returns it as a character vector. It escapes percents where necessary and (optionally) backslashes in the examples section.
Rdo2Rdf(rdo, deparse = FALSE, ex_restore = FALSE, file = NULL,
rcode = TRUE, srcfile = NULL)
NULL
, if file
is not NULL
. Otherwise the Rd
formatted text as a character vector.
an Rd object or a character vector, see `Details'.
logical, passed to the print method for Rd objects, see `Details'.
logical, if TRUE
escapes backslashes where
necessary.
a filename where to store the result. If NULL
or
"missing", the result is returned as a character vector.
if TRUE, duplicate backslahes in RCODE elements, see Details.
NULL or a file name, see 'Details'.
Georgi N. Boshnakov
The description here is rather technical and incomplete. In any case it concerns almost exclusively Rd files which use escape sequences containing multiple consecutive backslashes or escaped curly braces (such things appear in regular expressions, for example).
In principle, this function should be redundant, since the
print
and as.character
methods for objects of class "Rd"
would be expected to do the job. I was not able to get the desired
result that way (the deparse
option to print
did not
work completely for me either).
Arguments ex_restore
and rcode
were added on an ad-hoc
basis. rcode
is more recent and causes Rdo2Rdf
to
duplicate backslashes found in any element Rd_tag
-ed with
"RCODE". ex_restore
does the same but only for the examples
section. In effect, if rcode
is TRUE, ex_restore
is
ignored.
The initial intent of this function (and the package Rdpack as a whole
was not to refer to the Rd source file. However, there is some
flexibility in the Rd syntax that does not allow the source file to be
restored identically from the parsed object. This concerns mainly
backslahes (and to some extent curly braces) which in certain contexts
may or may not be escaped and the parsed object is the same. Although
this does not affect functionality, it may be annoying if the escapes
in sections not examined by reprompt
were changed.
If srcfile
is the name of a file, the file is parsed and the Rd
text of sections of rdo
that are identical to sections from
srcfile
is taken directly from srcfile
, ensuring that
they will be identical to the original.
# # this keeps the backslashes in "author" (see Note above)
# reprompt(infile="./man/Rdo2Rdf.Rd")
# # this outputs "author" preceded by one backslash only.
# reprompt(infile="./man/Rdo2Rdf.Rd", sec_copy = FALSE)
Run the code above in your browser using DataLab