Returns the first top-level node of a tools::parse_Rd() result whose
Rd_tag matches tag, or NULL if absent. Use it to reach a specific
section, such as \\value or \\examples, when writing a documentation
check.
Arguments
- rd
A parsed
.Rdobject fromtools::parse_Rd().- tag
Character. The
Rd_tagto find, e.g."\\value"or"\\examples".
Examples
rd_file <- tempfile(fileext = ".Rd")
writeLines(c("\\name{foo}", "\\title{Foo}", "\\value{A number.}"), rd_file)
rd <- tools::parse_Rd(rd_file)
collect_rd_text(extract_rd_section(rd, "\\value"))
#> [1] "A number."