Generate items with multiple arguments in R documentation via roxygen2

To create the R documentation file ( .Rd ), I use the RStudio / Document package with the parameters R 3.0.2, Linux 3.11, devtools 1.5, roxygen2 4.0.1.

goal

I want to describe several function arguments in a documentation file, for example, in this example:

 \arguments{ \item{arg1, arg2}{Description} } 

Here, the arguments arg1 and arg2 are separated by a space character. This causes the line to break automatically in the HTML version.

Problem

Using the RStudio / Document parameter, a space between the two arguments places the second in the Description part, for example:

 #' @param arg1, arg2 Description 

will become

 \arguments{ \item{arg1,}{arg2 Description} } 

Inappropriate decision

The only way I decided to keep both arguments inside the β€œargument” part is not to use space-separated ones, for example:

 #' @param arg1,arg2 Description 

will become

 \arguments{ \item{arg1,arg2}{Description} } 

This is not required because with a large number of arguments, the column with the argument uses a lot of space. I tried to avoid space with \ or \\ , and also include all arguments with \code{...} , but none of them worked as desired.

Question

Is there a way to create a conclusion like in my goal ? Maybe some kind of escape character that introduces a space?

Thanks.
Sven

+5
source share
1 answer

I did not find a way to convince roxygen2 to give you the opportunity to generate a line with a space between the arguments, but you can always manually update the Rd file after calling roxygenize .

 library(stringr) filename <- "your package root/man/your_function.Rd" lines <- readLines(filename) lines <- str_replace(lines, fixed("\item{arg1,arg2}"), "\item{arg1, arg2}") writeLines(lines, filename) 

Of course, documenting several things at a time is potentially confusing for the reader. It is almost always better to stick to the conventions of one argument per line, as the reader expects.

+4
source

Source: https://habr.com/ru/post/1200318/


All Articles