1

I am using roxygen2 for generating .Rd files. Multiple functions share the same documentation and each has their usage line described therein. However, roxygen2 automatically adds new lines in between all the functions.

Here is an example of how the functions are defined in the R file with roxygen2 comment tags:

#' @rdname name
#' @export
fun1 <- function(x, y) {
  ...
}

#' @rdname name
#' @export
fun2 <- function(x, y) {
  ...
}

#' @rdname name
#' @export
fun3 <- function(x, y) {
  ...
}

#' @rdname name
#' @export
fun4 <- function(x, y) {
  ...
}

And here is the usage section from the generated Rd:

\usage{
fun1(x, y)

fun2(x, y)

fun3(x, y)

fun4(x, y)
}

Ideally I would like to generate the following:

\usage{
fun1(x, y)
fun2(x, y)

fun3(x, y)
fun4(x, y)
}

Does roxygen2 allow to specify this somehow, or should it be done manually?

Karolis Koncevičius
  • 9,417
  • 9
  • 56
  • 89
  • did you try a `#' @usage` section almost verbatim what you have in your ideal output? not sure if that also adds lines--i'm just assuming you are omitting the `@usage` tag and letting roxygen fill in for you. depending on how complicated your functions are, it may be easier to remove lines in the rd after they are generated for you – rawr Nov 20 '21 at 18:47
  • @rawr thank you for the comment. I tried playing with @usage - I can make the usage I want to have for the first function, but other functions still have their usages auto-generated, so it becomes redundant. I tried adding empty `@usage` tags for the rest of the functions but this resulted in an error. So no luck so far. – Karolis Koncevičius Nov 20 '21 at 18:59
  • Also the creator of `roxygen2` says [here](https://stackoverflow.com/a/8879154/1953718) that any time you use `@usage` tag it should be considered a bug in roxygen. – Karolis Koncevičius Nov 20 '21 at 19:00
  • that's absurd. so it's a bug if i [don't like the way](https://github.com/raredd/rawr/blob/master/man/Reshape.Rd#L9:L15) the god tidy king has decreed man pages should look? you're free to think for yourself you know – rawr Nov 20 '21 at 19:25
  • Well, I think you misread that. The god tidy king is saying it's a bug **in roxygen**, not a bug in your code :) As for the `@usage` suggestion - that was on point, but didn't seem to work because each function generates usage and I have to specify manual `@usage` for each. But in the end they still get separated by new lines. – Karolis Koncevičius Nov 20 '21 at 19:40

0 Answers0