简体   繁体   English

Roxygen2文档参数故障

[英]Roxygen2 documentation parameter out of order

I'm using Roxygen2 for documentation and I cannot get the order of parameters to be right. 我正在使用Roxygen2进行文档编制,但无法获得正确的参数顺序。 Specifically, I have 3 sets of parameters for this one set of methods: 具体来说,对于这一套方法,我有3组参数:

  • "n": A parameter of all functions that should always be first “ n”:所有功能的参数,应始终优先
  • "r": A parameter of some functions that should always be second. “ r”:某些功能的参数,应始终为第二个。 In a template 在模板中
  • p3-p5: A set of parameters from template; p3-p5:模板中的一组参数; should always be at end. 应该总是在最后。
    • These start with "s", "a", and "r", respectively 它们分别以“ s”,“ a”和“ r”开头

I have not been able to get it into proper order: The most common order is n, p3-p5, r. 我无法将其设置为正确的顺序:最常见的顺序是n,p3-p5,r。 If I remove n, I get p3-p5, r. 如果删除n,则得到p3-p5,r。 If I have 2 n's, I get n, p3-p5, n, r. 如果我有2个n,则得到n,p3-p5,n,r。 If I have 2 r's and no n's, I get p3-p5, r, r. 如果我有2个r而没有n,我得到p3-p5,r,r。

Any advice on how to fix this. 有关如何解决此问题的任何建议。 If you think it has to do with the current layout, it's: 如果您认为这与当前布局有关,则为:

#' @templateVar ... ...
#' @param n ...
#' @template t1 # Template for r
#' @template t2 # Template for p3-p5
#' @details  ... 
#' ...

where t2's layout is: t2的布局是:

#' @param p3
#' @param p4
#' @param p5
#' @details ...
#' @return  ...
#' ...

Other fixes for this I have found do not seem to work. 我发现的其他修复似乎无效。 Also, I would love for n to be part of the t2 template, but I assume that's unreasonable. 另外,我希望n成为t2模板的一部分,但我认为这是不合理的。

Well, congratulate me, because I spend a good 45 minutes trying to figure this out without realizing that the parameters are ordered to sync with the function usage parameter, and r was not supposed to be there anyways. 好吧,恭喜我,因为我花了45分钟的时间试图弄清楚这一点,却没有意识到这些参数已与功能使用参数同步,并且r始终不应该存在。

Fix ended up being that "r" (or the parameter that "r" stands for) did not directly match any of the parameters of the function, so it got thrown to the end. 修复最终导致“ r”(或“ r”代表的参数)与该函数的任何参数都不直接匹配,因此将其扔到了最后。 I feel stupid. 我觉得我好笨。 Whatever, though. 无论如何。 Maybe this will be a good warning for future users. 也许这将是对未来用户的一个很好的警告。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM