Rev 69170 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
% File src/library/tools/man/parse_Rd.Rd% Part of the R package, https://www.R-project.org% Copyright 2008-2016 R Core Team% Distributed under GPL 2 or later\name{parse_Rd}\alias{parse_Rd}\alias{print.Rd}\alias{as.character.Rd}\title{ Parse an Rd file }\description{This function reads an R documentation (Rd) file and parses it, forprocessing by other functions.}\usage{parse_Rd(file, srcfile = NULL, encoding = "unknown",verbose = FALSE, fragment = FALSE, warningCalls = TRUE,macros = file.path(R.home("share"), "Rd", "macros", "system.Rd"),permissive = FALSE)\method{print}{Rd}(x, deparse = FALSE, \dots)\method{as.character}{Rd}(x, deparse = FALSE, \dots)}\arguments{\item{file}{A filename or text-mode connection. At present filenameswork best.}\item{srcfile}{\code{NULL}, or a \code{"srcfile"} object. See the\sQuote{Details} section.}\item{encoding}{Encoding to be assumed for input strings.}\item{verbose}{Logical indicating whether detailed parsinginformation should be printed.}\item{fragment}{Logical indicating whether file represents a completeRd file, or a fragment.}\item{warningCalls}{Logical: should parser warnings include the call?}\item{macros}{Filename or environment from which to load additionalmacros, or a logical value. See the Details below.}\item{permissive}{Logical indicating that unrecognized macrosshould be treated as text with no warning.}\item{x}{An object of class Rd.}\item{deparse}{If \code{TRUE}, attempt to reinstate the escape charactersso that the resulting characters will parse to the same object.}\item{\dots}{Further arguments to be passed to or from other methods.}}\details{This function parses \file{Rd} files according to the specification givenin \url{https://developer.r-project.org/parseRd.pdf}.It generates a warning for each parse error and attempts to continueparsing. In order to continue, it is generally necessary to drop someparts of the file, so such warnings should not be ignored.Files without a marked encoding are by default assumed to be in thenative encoding. An alternate default can be set using the\code{encoding} argument. All text in files is translated to theUTF-8 encoding in the parsed object.As from \R version 3.2.0, User-defined macros may be given in aseparate file using \samp{\newcommand} or \samp{\renewcommand}.An environment may also be given: it would be produced by\code{\link{loadRdMacros}}, \code{\link{loadPkgRdMacros}}, orby a previous call to \code{parse_Rd}. If a logical valueis given, only the default built-in macros will be used;\code{FALSE} indicates that no \code{"macros"} attributewill be returned with the result.The \code{permissive} argument allows text to be parsed that isnot completely in Rd format. Typically it would be LaTeX code,used in an Rd fragment, e.g.\sspace{}in a \code{\link{bibentry}}.With \code{permissive = TRUE}, this will be passed through as plaintext. Since \code{parse_Rd} doesn't know how many argumentsbelong in LaTeX macros, it will guess based on the presenceof braces after the macro; this is not infallible.}\value{\code{parse_Rd} returns an object of class \code{"Rd"}. Theinternal format of this object is subject to change. The\code{as.character()} and \code{print()} methods defined for theclass return character vectors and print them, respectively.Unless \code{macros = FALSE}, the object will have an attributenamed \code{"macros"}, which is an environment containing themacros defined in \code{file}, in a format that can be used forfurther \code{parse_Rd} calls in the same session. It is notguaranteed to work if saved to a file and reloaded in a differentsession.}\references{ \url{https://developer.r-project.org/parseRd.pdf} }\author{ Duncan Murdoch }\seealso{\code{\link{Rd2HTML}} for the converters that use the output of\code{parse_Rd()}.}\keyword{utilities}\keyword{documentation}