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

Description Usage Arguments Details Value Note Author(s) See Also Examples

View source: R/repromptAny.R

Description

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

Usage

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

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.

Value

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

Note

For an S3 or S4 generic, use the name of the function, not the object, see the examples.

These functions are for usage descriptions as they appear in the "usage" section of Rd files. Descriptions of S4 methods for "Methods" sections are dealt with by other functions.

Author(s)

Georgi N. Boshnakov

See Also

parse_pairlist

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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")

Rdpack documentation built on April 1, 2018, 12:15 p.m.