Using Roxygen2 Template tags

后端 未结 1 1410
伪装坚强ぢ
伪装坚强ぢ 2020-12-13 14:58

Could someone provide an example of how to properly use the Template Tags in Roxygen2. I have tried to do the most obvious thing (to me):

In my pa

相关标签:
1条回答
  • 2020-12-13 15:41

    Perfect! Thanks @hadley. The GitHub version of plyr was the perfect example.

    I will describe the process here for future overflowers.

    Using Templates with Roxygen2

    1) You should create a folder to hold your templates: man-roxygen/

    2) Each template is a .R file that lives in man-roxygen/

    For example: 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.

     #' ... [other roxygen2 tags and information] ...
     #'
     #' @template someTemplate
    

    4) When you use the template you get everything in the someTemplate.R file.

    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. Look at the following to get the idea:

    Look for the use of @template in these files:

     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
    
    0 讨论(0)
提交回复
热议问题