假设我的包中有一个函数闭包,例如
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()记录此功能的正确方法是正确的(在官方 CRAN 意义上) ?
What is the correct (in the official CRAN sense) way of documenting this function? In particular,
推荐答案
一种方法是做与?family 类似的事情在 Value $ c $中记录 g()和 h()的位置 .Rd 文件的c>部分。然后在定制的 \部分中提供有关 g()和 h()的扩展文档{foo} ,您将在这两个函数的 Value 部分条目中指向它们。
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} } }虽然氧气无法从参数 @param ,但是您应该可以将其写为任意的roxygen部分,以添加到Rd文件中。 Value 部分可以写为标准的roxygen标记,只需按需输入定制部分。
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.
更多推荐
记录功能关闭
发布评论