Parses the roxygen2 package documentation of a specific R package or from a single .R
source code file.
Arguments
- pkg, text
Either a package name (
pkg
) or a character vector of R source code lines (text
) to extract the object's roxygen2 tag value from.- ...
Further arguments passed on to
utils::download.packages()
, excluding"pkgs"
,"destdir"
,"available"
,"type"
and"quiet"
. Only relevant ifpkg
is provided.- quiet
Whether or not to suppress printing status output from internal processing.
Value
A list of roxy_block
objects.
See also
Other package documentation functions:
enum_fn_param_defaults()
,
fn_param_defaults()
,
roxy_obj()
,
roxy_tag_value()
,
roxy_to_md_links()
Examples
# Either provide an R source file as a character vector `text`...
text <- readr::read_lines(paste0("https://raw.githubusercontent.com/r-lib/rlang/",
"db52a58d505b65f58ba922d4752b5b0061f2a98c/R/fn.R"))
pal::roxy_blocks(text = text) |> head(n = 3L)
#> [[1]]
#> <roxy_block> [<text>:39]
#> $tag
#> [line: 1] @title 'Create a function' {parsed}
#> [line: 3] @description '...' {parsed}
#> [line: 10] @param 'args A named list or pairlist of default argume...' {parsed}
#> [line: 14] @param 'body A language object representing the code in...' {parsed}
#> [line: 17] @param 'env The parent environment of the function, def...' {parsed}
#> [line: 19] @export '' {parsed}
#> [line: 20] @examples '...' {parsed}
#> [line: 39] @usage '<generated>' {parsed}
#> [line: 39] @.formals '<generated>' {parsed}
#> [line: 39] @backref '<generated>' {parsed}
#> $call new_function <- function(args, body, env = caller_env()) { ...
#> $object <function>
#> $topic new_function
#> $alias new_function
#>
#> [[2]]
#> <roxy_block> [<text>:50]
#> $tag
#> [line: 46] @title 'Name of a primitive function' {parsed}
#> [line: 47] @param 'prim A primitive function such as [base::c()].' {parsed}
#> [line: 48] @keywords 'internal' {parsed}
#> [line: 49] @export '' {parsed}
#> [line: 50] @usage '<generated>' {parsed}
#> [line: 50] @.formals '<generated>' {parsed}
#> [line: 50] @backref '<generated>' {parsed}
#> $call prim_name <- function(prim) { ...
#> $object <function>
#> $topic prim_name
#> $alias prim_name
#>
#> [[3]]
#> <roxy_block> [<text>:91]
#> $tag
#> [line: 62] @title 'Extract arguments from a function' {parsed}
#> [line: 64] @description '`fn_fmls()` returns a named list of formal argu...' {parsed}
#> [line: 70] @details 'Unlike `formals()`, these helpers throw an erro...' {parsed}
#> [line: 73] @param 'fn A function. It is lookep up in the calling f...' {parsed}
#> [line: 75] @seealso '[call_args()] and [call_args_names()]' {parsed}
#> [line: 76] @export '' {parsed}
#> [line: 77] @examples '...' {parsed}
#> [line: 91] @usage '<generated>' {parsed}
#> [line: 91] @.formals '<generated>' {parsed}
#> [line: 91] @backref '<generated>' {parsed}
#> $call fn_fmls <- function(fn = caller_fn()) { ...
#> $object <function>
#> $topic fn_fmls
#> $alias fn_fmls
#>
# ...or provide a package name as `pkg`
try(
pal::roxy_blocks(pkg = "tinkr",
repos = "https://cloud.r-project.org") |>
head(n = 3L)
)
#> Warning: Objects listed as exports, but not present in namespace:
#> • find_between
#> • get_protected
#> • md_ns
#> • protect_curly
#> • protect_fences
#> • protect_math
#> • show_block
#> • show_censor
#> • show_list
#> • stylesheet
#> • to_md
#> • to_md_vec
#> • to_xml
#> • yarn
#> list()