Rdpack (version 0.4-20)

promptUsage: Usage text for a function, S3 method or S4 method

Description

Obtains the usage text for a function, S3 method or S4 method for inclusion in the usage section of Rd documentation.

Usage

get_usage(object, name = NULL, force.function = FALSE, ..., S3class = "", S4sig = "", infix = FALSE, fu = TRUE, out.format = "text")
promptUsage(..., usage)

Arguments

...
for promptUsage, arguments to be passed on to get_usage; for get_usage, currently not used.
usage
an usage object, see Details.
object
a function object or a character name of one.
name
the name of a function, a string.
force.function
enforce looking for a function.
S3class
the S3 class of the function, a character vector.
out.format
if "text", return the result as a character vector.
S4sig
(the signature of an S4 method, as used in Rd macro \S4method).
infix
if TRUE the function is an infix operator.
fu
if TRUE the object is a function, otherwise it is something else (e.g. a variable or a constant like pi and Inf).

Value

a character string or an object of S3 class "f_usage", see pairlist2f_usage for its format.

Details

Argument usage could probably only be useful in programming when the usage text has been obtained (or generated) programmatically. usage may be an "f_usage" object obtained e.g. from get_usage().

Use cat() to print the result for copying and pasting into Rd documentation (or saving to a file). Otherwise, if the usage text contains backslashes, they may appear duplicated.

See Also

parse_pairlist

Examples

Run this code
u <- get_usage(lm)    # a long usage text
cat(u)

# if there are additional arguments in S3 methods,
# use names of the functions, not the objects, e.g.
get_usage("droplevels",S3class="data.frame")
get_usage(name="droplevels",S3class="data.frame")
# (both give "\method{droplevels}{data.frame}(x, except = NULL, \dots)")

# but this gives the args of the generic:  "\method{droplevels}{data.frame}(x, \dots)"
get_usage(droplevels,S3class="data.frame")

Run the code above in your browser using DataLab