Parse formal arguments of functions

Description

Parse formal arguments of functions and convert them to f_usage objects.

Usage

1
2
3
4
parse_pairlist(x)

pairlist2f_usage1(x, name, S3class = "", S4sig = "", infix = FALSE,
                  fu = TRUE)

Arguments

x

a pairlist or a list of pairlists, see ‘Details’.

name

function name.

S3class

S3 class, see ‘Details’

S4sig

S4 signature, see Details.

infix

if TRUE the function usage is in infix form, see Details.

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

These functions are mostly internal.

x is a single pairlist object for parse_pairlist and pairlist2f_usage1.

The pairlist object is parsed into a list whose first component contains the names of the arguments. The second component is a named list containing the default values, converted to strings. Only arguments with default values have entries in the second component (so, it may be of length zero).

pairlist2f_usage1 adds components name (function name), S3class, S4sig and infix. S3class is set for S3 methods, S4sig is the signature of an S4 method (as used in Rd macro \S4method). infix is TRUE for the rare occations of usages of infix operators. The result is given class "f_usage". This class has a method for as.character which generates a text suitable for inclusion in Rd documentation.

Value

For parse_pairlist, a list with the following components:

argnames

names of arguments, a character vector

defaults

a named character vector containing the default values, converted to character strings.

For pairlist2f_usage1, an object with S3 class "f_usage". This is a list as for parse_pairlist and the following additional components:

name

function name, a character string.

S3class

S3 class, a character string.

S4sig

S4 signature.

infix

a logical value, TRUE for infix operators.

Author(s)

Georgi N. Boshnakov

See Also

promptUsage

Examples

1

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.