9

Using roxygen2 documentation with devtools document function automatically generates a Collate: field in the package DESCRIPTION, regardless of whether or not it is necessary to load the package library files in a particular order.

I'm working on a package with a bunch of S4 methods and want to be sure the class definitions are loaded before any methods or other classes using them, which I understand I can do with the Collate list, but I'm not sure how to indicate this in the roxygen2 documentation format.

The roxygen2 manual makes some reference to an @include tag but that looks like it might actually just include code in the documentation, for instance, for adding external examples through an @examples flag. Can this be used for specifying collate order for methods?

4

2 回答 2

15

include 标签用于说明一个文件需要另一个文件才能工作。(名字包括可能不是最好的选择,但生活就是这样)。如果您想确保在文件 A 之前加载文件 B,请确保@include B在 A 中加载。Roxygen 将负责排序整理字段以满足您的限制。

于 2013-09-03T14:07:23.200 回答
5

我刚刚发现,如果您在 R 文件的顶部添加 @include 语句,它将干扰下一个 roxygen2 文档块,除非您使用 NULL 跟随它,例如

#' @include something.R
NULL

#' Documenting a function
#'
#" It does something...
#'
#' @param ...
#'
于 2014-02-26T18:56:26.343 回答