print_info: Output Docstring Info.

Description Usage Arguments Details See Also Examples

View source: R/info.R

Description

Output the docstring info of a module.

Usage

1
2
3
4
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
define("foo", NULL, {
 #' # Info
 #' This is a docstring for `foo`.
})
print_info("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)
## End(Not run)

openscienceunil/modulr documentation built on May 3, 2019, 5:49 p.m.