append_to_Rd_list: Add content to the element of an Rd object or fragment at a...

View source: R/manip.R

append_to_Rd_listR Documentation

Add content to the element of an Rd object or fragment at a given position

Description

Add content to the element of an Rd object or fragment at a given position.

Usage

append_to_Rd_list(rdo, x, pos)

Arguments

rdo

an Rd object

x

the content to append, an Rd object or a list of Rd objects.

pos

position at which to append x, typically an integer but may be anything accepted by the operator "[[".

Details

The element of rdo at position pos is replaced by its concatenation with x. The result keeps the "Rd_tag" of rdo[[pos]].

Argument pos may specify a position at any depth of the Rd object.

This function is relatively low level and is mainly for use by other functions.

Value

the modified rdo object

Author(s)

Georgi N. Boshnakov

Examples

#rdoseq <- utils:::.getHelpFile(help("seq"))
rdoseq <- Rdo_fetch("seq", "base")
iusage <- which(tools:::RdTags(rdoseq) == "\\usage")
iusage
attr(rdoseq[[iusage]], "Rd_tag")

## append a new line after the last usage line
rdoseq2 <- append_to_Rd_list(rdoseq, list(Rdo_newline()), iusage)

## Suppose that we wish to describe the function 'sequence' in the same Rd file.
## We append an usage statement for 'sequence()', without worrying about its
## actual signature.
rdoseq2 <- append_to_Rd_list(rdoseq2, list(Rdo_Rcode("sequence()")), iusage)
Rdo_show(rdoseq2)

## the two operations can be done in one step
rdoseq3 <- append_to_Rd_list(rdoseq, list(Rdo_newline(), Rdo_Rcode("sequence()")), iusage)
Rdo_show(rdoseq3)

## now run reprompt() to update rdoseq3, namely:
##    (1) it corrects the signature of 'sequence' in section \usage.
##    (2) reports new argument "nvec"
##    (3) inserts \item for the new argument(s) in section \arguments.
reprompt(rdoseq3, filename=NA)

Rdpack documentation built on Nov. 8, 2023, 5:06 p.m.