我正在编写一个R包,并希望在函数文档之间包含交叉引用。
按照这里的文档,有一个专门讨论此事的部分:
Cross-references
There are two tags that make it easier for people to navigate around your documentation:
@seealso
and@family
. [...] If you have a family of related functions, you can use@family {family}
to cross-reference each function to every other function within the family. A function can be a member of multiple families.For
sum()
, this might look like:
#' @family aggregations #' @seealso [prod()] for products, [cumsum()] for cumulative sums, and #' [colSums()]/[rowSums()] marginal sums over high-dimensional arrays.
By default
@family {family}
, will generate the see also text“Other {family}:”
, so the@family
name should be plural (i.e.,“model building helpers”
not“model building helper”
). You can override the default title by providing ard_family_title
list inman/roxygen/meta.R
:
rd_family_title <- list( aggregations = "Aggregation functions" )
因此,我将我的函数文档编写如下:
#' My foo function
#'
#' Does something with my data.
#'
#' Lorem ipsum.
#'
#' @param .data A data frame.
#' @return My processed data.
#' @usage
#' my_foo_function(.data)
#' @family {a_family}
#' @family {another_family}
#' @export
my_foo_function <- function(.data) {
# Some code
}
我用这种方式编写了约9个函数。
我还编写了这个meta.R
文件:
rd_family_title <- list(
a_family = "A family of functions",
another_family = "Another family of functions"
)
这个保存在这里:[包项目路径]/roxygen/man/meta.R
(遵循文档)。
然而,当我运行document()
函数(用于构建.Rd
文件)时,我收到以下警告:
document()
## Updating my_package documentation
## Writing NAMESPACE
## Warning messages:
## 1: Unknown Roxygen options a_family, another_family.
## Supported options: roclets, load, old_usage, markdown, r6, package
当我阅读文档时,我看到了类似于这样的内容:
[...]
另请参阅
其他 a_family:bar(),baz() 其他 another_family:spam(),eggs()
(我用 @family a_family
替换了 @family {a_family}
并获得了相同的结果。
那么...我错过了什么?rd_family_title
列表应该在哪里?为什么Roxygen无法用我定义的标题替换那个“其他…”的东西?
一些附加信息:
- R版本:3.6.0,运行在CentOs 7上,并使用Rstudio
- Roxygen2版本:7.0.2
- devtools版本:2.2.1
man/roxygen/meta.R
应该返回一个列表,其中一个元素是rd_family_title
,请参见此处。这应该可以消除警告。但对我来说仍然不起作用。 - alan ocallaghan<-
而不是=
。看起来这可能目前已经出现了问题,因为load_options_meta
仅在全局范围内执行,而rd_family_title
不是允许的选项,请参见:https://github.com/r-lib/roxygen2/search?q=load_options_meta&unscoped_q=load_options_meta - alan ocallaghan