Suppose I have a function closure in my package, for example
f = function(x) {
x = x
g = function(y) x <<- y
h = function() x
list(g = g, h = h)
}
l = f(5)
l$g(10)
l$h()
What is the correct (in the official CRAN sense) way of documenting this function? In particular,
roxygen2
g
and h
One way would be to do something similar to ?family
where you document g()
and h()
in the Value
section of the .Rd
file. Then provide extended documentation about g()
and h()
in a bespoke \section{foo}
, which you point to in the Value
section entries for the two functions.
\value{
Returns an object of class \code{"foo"}, a list with the
following components:
\item{g}{function; does foo. See Returned Functions for details.}
\item{h}{function; does bar. See Returned Functions for details.}
}
\section{Returned Functions}{
The returned functions do, blah blah...
\code{g} is defined as
\preformatted{
g(x, y, z, ...)
}
Arguments are:
\describe{
\item{x}{foo}
\item{y}{foo}
\item{z}{foo}
}
}
Whilst roxygen won't be able to do this from the argument @param
, but you should be able to write this as an arbitrary roxygen section to add to the Rd file. The Value
section can be written as standard roxygen markup, only the bespoke section would need to be entered literally.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With