Output the docstring info of a module.

print_info(name = .Last.name, line_numbers = F, sep = "\n",
  load = TRUE)

info(name = .Last.name, line_numbers = F, sep = "\n", load = TRUE)

Arguments

name

A string (character vector of lenght one).

A module name can contain letters, figures and some special characters, namely _, -, and /. The latter is a namespace separator.

Names containing /mock/, /mocks/, /test/, /tests/, /example/, or /examples/ have a special meaning related to code testing and examples.

The name "modulr" corresponds to a special module and is therefore reserved.

line_numbers

A flag. Should the source line numbers be outputed?

sep

A string (character vector of length one) containing the separator between docstrings blocs.

load

A flag. Should the module be loaded?

Details

A docstring is intended to document a module and provide the user with the ability to inspect it at run time, for instance as an interactive help system, or as metadata. Formally, it is a block of commented lines prefixed with #' and located at the top of the module provider.

The preferred formatting for a docstring is R Markdown, notabely for Modulr Gears (see prepare_gear).

See also

define, prepare_gear, and reset.

Examples

define("foo", NULL, { #' # Info #' This is a docstring for `foo`. })
#> [2017-06-21T21:58:29 UTC] Re-defining 'foo' ... OK
print_info("foo")
#> # Info #> This is a docstring for `foo`.
not_run({ tmp <- tempfile(fileext = ".html") cat((knitr::knit2html(text = info("foo"))), file = tmp) if(interactive()) rstudio::viewer(tmp) Sys.sleep(1L); unlink(tmp) })