Learn R Programming

options (version 0.3.0)

as_params: Produce @param roxygen sections for options

Description

Generate parameter documentation based on option behaviors. Especially useful for ubiquitous function parameters that default to option values.

Usage

as_params(...)

Value

A character vector of roxygen2

@param tags

Arguments

...

Character values of options to use. If named arguments are provided, the option description provided as the value is mapped to a parameter of the argument's name.

See Also

Other options_roxygen2: as_roxygen_docs()

Examples

Run this code
options::define_options(
  "whether messages should be written softly, or in all-caps",
  quiet = TRUE
)

#' Hello, World
#'
#' @eval options::as_params("softly" = "quiet")
#'
hello <- function(who, softly = opt("quiet")) {
  say_what <- paste0("Hello, ", who, "!")
  if (quiet) say_what else toupper(say_what)
}

Run the code above in your browser using DataLab