this is intended to be used in a Roxygen tag to document the default value or allowable values of a function
doc_formals(fn, param, one_of = TRUE)
a function in the current package
a parameter (usually the same as the param block)
decorate the string with a "default"/"one of" depending on type
a formatted string for inclusion in a Roxygen block
#' A test function
#'
#' @param arg a set of descriptions: `r doc_formals(test_fn, arg)`
#' @param def a set of descriptions: `r doc_formals(test_fn, def)`
#' @param ghi a set of descriptions: `r doc_formals(test_fn, ghi)`
#'
#' @ return nothing
test_fn = function(
arg = c("option one","option two","option three"),
def = 123,
ghi = def*2
) {
arg = match.arg(arg)
}
# @param arg a set of descriptions: `r doc_formals(test_fn, arg)`
doc_formals(test_fn, arg)
#> [1] "one of: `option one`, `option two`, `option three`; default `option one`"
doc_formals(test_fn, def)
#> [1] "default `123`"
doc_formals(test_fn, geh)
#> character(0)