记录功能关闭

编程入门 行业动态 更新时间:2024-10-25 01:28:50
本文介绍了记录功能关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

假设我的包中有一个函数闭包,例如

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,

  • 我想使用 roxygen2
  • 我想为函数 g 和 h
  • $ b $提供文档b
  • I would like to use roxygen2
  • I would like to provide documentation for the functions g and h
  • 推荐答案

    一种方法是做与?family 类似的事情在 Value 部分。然后在定制的 \部分中提供有关 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.

    更多推荐

    记录功能关闭

    本文发布于:2023-11-25 04:12:47,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1628271.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:功能

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!