[英]Using Roxygen2 Template tags
有人可以舉例說明如何在Roxygen2
正確使用模板標簽。 我試圖做最明顯的事情(對我來說):
在我的packageName-package.R
文件中:
#' [... other Roxygen blocks ...]
#'
#' @templateVar testTemplateTag Testing one two
NULL
然后在someFunction.R文件中
#' [... other Roxygen blocks ...]
#'
#' @template testTemplateTag
我收到錯誤:
Error : Can not find template testTemplateTag
我試圖有一個地方來記錄通常重復的定義示例等。當這些東西嵌套在一組函數中時,我一直在使用@inheritParms
。 但有些東西,如定義和其他描述,在幾個地方使用。 我已經搜索了@template
和@templateVar
高低使用率, @template
沒有找到任何東西。
謝謝。
完善! 謝謝@hadley。 Plyr的GitHub版本就是一個很好的例子。
我將在此描述未來溢流器的過程。
1)您應該創建一個文件夾來保存模板: man-roxygen/
2)每個模板都是一個生活在man-roxygen/
的.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)現在在其他一些roxygen2
塊中,您可以roxygen2
這種方式調用所有 roxygen2
代碼。
#' ... [other roxygen2 tags and information] ...
#'
#' @template someTemplate
4)當您使用模板時,您將獲得someTemplate.R
文件中的所有內容。
查看GitHub上的plyr包 ,看看Hadley使用man-roxygen\\
存儲的幾個模板文件的巧妙方式,他可以混合搭配來創建文檔。 請看以下內容以獲得想法:
在這些文件中查找@template
:
R/aaply.r
R/adply.r
看看這里的模板:
man-roxygen/ply.r
man-roxygen/a-.r
man-roxygen/-a.r
man-roxygen/-d.r
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.