Arguments descriptions order in .Rd file when using the roxygen2 tag @inheritParams
Asked Answered
C

1

7

Let's say I am writing a small R package including two functions with exaclty the same arguments except one. Here is an example:

fct1 <- function(r, K){...}
fct2 <- function(r, p, K){...}

In my roxygen2 documentation of the first function I use the following tags:

#' @param r description of argument r
#' @param K description of argument K

For the second function, I use the following tags:

#' @param p description of argument p
#' @inheritParams fct1

After processing my code with roxygenize, the .Rd file for the function fct2 presents the arguments in the following order: p, r, K. I would like them to be in the same order than in the usage section, that is: r, p, K. How can I get this order without manually changing the .Rd file?

I insist on using @inheritParams to avoid copying and pastings.

Thanks!

Cherellecheremis answered 28/11, 2011 at 16:42 Comment(3)
File a bug at github.com/klutometis/roxygen/issuesBorglum
@hadley, is it possible to report a bug without an account on github? ThanksCherellecheremis
No. But accounts are free and easy to set up. Unfortunately accounts are requirement in these spam-filled days.Borglum
S
2

I have the same problem. For now I use little trick to avoid wrong arguments order.

Use code (e.g. in seperate .R file):

#' Function arguments
#'
#' @keywords integral
#'
#' @name fargs
#'
#' @param r ..
#' @param p ..
#' @param K ..
#' 
#' 
NULL

and use

#' @inheritParams fargs

for both functions.

In this case it was easy, but in more complicated examples U can use many blocks of this code (separate block for every type of arguments). Maybe it is not so simple way but you do not repeat the same code anywhere. I store that block in seperate args.R file so every inherit arguments is in one file.

Another way is using templates but this method is not flexible and for every block you must create separate .R file. So I advice u to use simmilary blocks of code.

Saxton answered 5/12, 2014 at 15:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.