[英]Using Roxygen2 Template tags
Could someone provide an example of how to properly use the Template Tags in Roxygen2
. 有人可以举例说明如何在
Roxygen2
正确使用模板标签。 I have tried to do the most obvious thing (to me): 我试图做最明显的事情(对我来说):
In my packageName-package.R
file: 在我的
packageName-package.R
文件中:
#' [... other Roxygen blocks ...]
#'
#' @templateVar testTemplateTag Testing one two
NULL
Then in a file someFunction.R 然后在someFunction.R文件中
#' [... other Roxygen blocks ...]
#'
#' @template testTemplateTag
I get the error: 我收到错误:
Error : Can not find template testTemplateTag
I am trying to have one place to document commonly repeated definitions examples etc. When these things are nested within a set of functions I have been using @inheritParms
. 我试图有一个地方来记录通常重复的定义示例等。当这些东西嵌套在一组函数中时,我一直在使用
@inheritParms
。 But some things, like definitions and and other descriptions, are used in several places. 但有些东西,如定义和其他描述,在几个地方使用。 I've searched high and low for usage of
@template
and @templateVar
and have not found anything. 我已经搜索了
@template
和@templateVar
高低使用率, @template
没有找到任何东西。
Thanks. 谢谢。
Perfect! 完善! Thanks @hadley.
谢谢@hadley。 The GitHub version of plyr was the perfect example.
Plyr的GitHub版本就是一个很好的例子。
I will describe the process here for future overflowers. 我将在此描述未来溢流器的过程。
1) You should create a folder to hold your templates: man-roxygen/
1)您应该创建一个文件夹来保存模板:
man-roxygen/
2) Each template is a .R
file that lives in man-roxygen/
2)每个模板都是一个生活在
man-roxygen/
的.R
文件
For example: man-roxygen/someTemplate.R
例如:
man-roxygen/someTemplate.R
#' ... [other roxygen2 tags and information] ...
#'
#' @param someParm A parameter that is used in several functions.
#'
#' ... [more roxygen2 tags and information] ...
3) Now in some other roxygen2
block you can call all of that roxygen2
code this way. 3)现在在其他一些
roxygen2
块中,您可以roxygen2
这种方式调用所有 roxygen2
代码。
#' ... [other roxygen2 tags and information] ...
#'
#' @template someTemplate
4) When you use the template you get everything in the someTemplate.R
file. 4)当您使用模板时,您将获得
someTemplate.R
文件中的所有内容。
Check out the plyr package on GitHub to see the clever way Hadley uses several template files stored in man-roxygen\\
that he can mix and match to create the documentation. 查看GitHub上的plyr包 ,看看Hadley使用
man-roxygen\\
存储的几个模板文件的巧妙方式,他可以混合搭配来创建文档。 Look at the following to get the idea: 请看以下内容以获得想法:
Look for the use of @template
in these files: 在这些文件中查找
@template
:
R/aaply.r
R/adply.r
Look at the templates here: 看看这里的模板:
man-roxygen/ply.r
man-roxygen/a-.r
man-roxygen/-a.r
man-roxygen/-d.r
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.