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

Share:

Description

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

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
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)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.