Learn R Programming

toscutil (version 2.8.0)

get_docstring: Get docstring for a Function

Description

The roxygen2 package makes it possible to write documentation for R functions directly above the corresponding function. This function can be used to retrieve the full documentation string (docstring).

Usage

get_docstring(content, func, collapse = TRUE, template = DOCSTRING_TEMPLATE)

Value

A character vector of length 1 containing either the docstring or the empty string (in case no documentation could be detected).

Arguments

content

R code as string.

func

Name of function to get docstring for.

collapse

Whether to collapse all docstring into a single string.

template

String to return in case no docstring could be found.

Examples

Run this code
uri <- system.file("testfiles/funcs.R", package = "toscutil")
content <- readLines(uri)
func <- "f2"
get_docstring(content, func)
get_docstring(content, func, collapse = TRUE)

Run the code above in your browser using DataLab