Skip to contents

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

Usage

as_params(...)

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.

Value

A character vector of roxygen2

@param tags

See also

Other options_roxygen2: as_roxygen_docs()

Examples

options::define_options(
  "whether messages should be written softly, or in all-caps",
  quiet = TRUE
)
#> 
#> quiet = TRUE
#> 
#>   whether messages should be written softly, or in all-caps
#> 
#>   option  : globalenv.quiet
#>   envvar  : R_GLOBALENV_QUIET (evaluated if possible, raw string otherwise)
#>  *default : 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)
}