Rdpack (version 0.4-20)

append_to_Rd_list: 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 "[[".

Value

the modified rdo object

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.

Examples

Run this code
rdoseq <- utils:::.getHelpFile(help("seq"))
iusage <- which(tools:::RdTags(rdoseq) == "\\usage")

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

# then append a new usage statement, in this case for another function
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 the doc.
#     reports new argument "nvec" and updates the Rd object.
      # notice that the usage statement of sequence() is corrected
      # and an item for argument nvec is created.
reprompt(rdoseq3, filename=NA)

Run the code above in your browser using DataLab