Rdo_set_section: Replace a section in an Rd file

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/sections.R

Description

Replace a section in an Rd file.

Usage

1

Arguments

text

the new text of the section, a character vector.

sec

name of the section.

file

name of the file.

...

arguments to be passed on to Rdo_modify.

Details

Parses the file, replaces the specified section with the new content and writes the file back. The text is processed as appropriate for the particular section (sec).

For example:

Rdo_set_section("Georgi N. Boshnakov", "author", "./man/Rdo2Rdf.Rd")

(Some care is needed with the author field for "xxx-package.Rd" files, such as "Rdpack-package.Rd", where the Author(s) field has somewhat different layout.)

By default Rdo_set_section does not create the section if it does not exist, since this may not be desirable for some Rd files. The "..." arguments can be used to change this, they are passed on to Rdo_modify, see its documentation for details.

Value

This function is used mainly for the side effect of changing file. It returns the Rd formatted text as a character vector.

Author(s)

Georgi N. Boshnakov

See Also

Rdo_modify

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
dummyfun <- function(x) x

fn <- tempfile("dummyfun", fileext = "Rd")
reprompt(dummyfun, filename = fn)
Rdo_show(tools::parse_Rd(fn))

## set the author section, create it if necessary.
Rdo_set_section("A.A. Author", "author", fn, create = TRUE)
Rdo_show(tools::parse_Rd(fn))

## replace the author section
Rdo_set_section("Georgi N. Boshnakov", "author", fn)
Rdo_show(tools::parse_Rd(fn))

unlink(fn)

Rdpack documentation built on May 24, 2018, 5:04 p.m.