R: Parse an Rd file

parse_Rd {tools} | R Documentation

## Parse an Rd file

### Description

This function reads an R documentation (Rd) file and parses it, for processing by other functions.

### Usage

    parse_Rd(file, srcfile = NULL, encoding = "unknown",
             verbose = FALSE, fragment = FALSE, warningCalls = TRUE)
    ## S3 method for class 'Rd'
    print(x, deparse = FALSE, ...)
    ## S3 method for class 'Rd'
    as.character(x, deparse = FALSE, ...)

### Arguments

`file` | A filename or text-mode connection. At present filenames work best.
`srcfile` | `NULL`, or a `"srcfile"` object. See the ‘Details’ section.
`encoding` | Encoding to be assumed for input strings.
`verbose` | Logical indicating whether detailed parsing information should be printed.
`fragment` | Logical indicating whether file represents a complete Rd file, or a fragment.
`warningCalls` | Logical: should parser warnings include the call?
`x` | An object of class Rd.
`deparse` | If `TRUE`, attempt to reinstate the escape characters so that the resulting characters will parse to the same object.
`...` | Further arguments to be passed to or from other methods.

### Details

This function parses ‘Rd’ files according to the specification given in http://developer.r-project.org/parseRd.pdf.

It generates a warning for each parse error and attempts to continue parsing. In order to continue, it is generally necessary to drop some parts of the file, so such warnings should not be ignored.

### Value

`parse_Rd` returns an object of class `"Rd"`. The internal format of this object is subject to change. The `as.character()` and `print()` methods defined for the class return character vectors and print them, respectively.

Files without a marked encoding are by default assumed to be in the native encoding. An alternate default can be set using the `encoding` argument. All text in files is translated to the UTF-8 encoding in the parsed object.

### Author(s)

Duncan Murdoch

### References

http://developer.r-project.org/parseRd.pdf

### See Also

`Rd2HTML` for the converters that use the output of `parse_Rd()`.

[Package tools version 2.15.1 Index]