Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

roxy_block

Blocks


Description

A roxy_block represents a single roxygen2 block.

The block_* functions provide a few helpers for common operations:

  • block_has_tag(blocks, tags): does block contain any of these tags?

  • block_get_tags(block, tags): get all instances of tags

  • block_get_tag(block, tag): get single tag. Returns NULL if 0, throws warning if more than 1.

  • block_get_tag_value(block, tag): gets val field from single tag.

Usage

roxy_block(tags, file, line, call, object = NULL)

block_has_tags(block, tags)

block_get_tags(block, tags)

block_get_tag(block, tag)

block_get_tag_value(block, tag)

Arguments

tags

A list of roxy_tags.

file, line

Location of the call (i.e. the line after the last line of the block).

call

Expression associated with block.

object

Optionally, the object associated with the block, found by inspecting/evaluating call.

block

A roxy_block to manipulate.

tag, tags

Either a single tag name, or a character vector of tag names.

Examples

# The easiest way to see the structure of a roxy_block is to create one
# using parse_text:
text <- "
  #' This is a title
  #'
  #' @param x,y A number
  #' @export
  f <- function(x, y) x + y
"

# parse_text() returns a list of blocks, so I extract the first
block <- parse_text(text)[[1]]
block

roxygen2

In-Line Documentation for R

v7.1.1
GPL (>= 2)
Authors
Hadley Wickham [aut, cre, cph] (<https://orcid.org/0000-0003-4757-117X>), Peter Danenberg [aut, cph], Gábor Csárdi [aut], Manuel Eugster [aut, cph], RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.