roxygen2
roxygen2 copied to clipboard
Improve indentation/wrapping for named vectors/lists in `\usage{}` blocks
The issue
When writing a function with a long argument (i.e. one that spans several lines), the .Rd file produced performs no formatting on the the argument, leading to less-comprehensible documentation).
Consider this dummy function, where in the raw R code there are named vectors/lists which are indented for legibility:
#' An example function for this issue
#' @param long_arg A named list
myfunction <- function(
long_arg_vctr = c(one = "1",
two = "2",
three = "3",
four = "4",
five = "5",
six = "6",
seven = "7"),
long_arg_list = list(one = c("foo", "bar"),
two = "baz",
three = c("a", "b", "c", "d"),
four = c(1, 2, 3, 4))
) {
"Placeholder text so this function runs"
}
The resulting .Rd file loses that indentation, which reduces legibility:
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/growth_classify.R
\name{myfunction}
\alias{myfunction}
\title{An example function for this issue}
\usage{
myfunction(
long_arg_vctr = c(one = "1", two = "2", three = "3", four = "4", five = "5", six = "6",
seven = "7"),
long_arg_list = list(one = c("foo", "bar"), two = "baz", three = c("a", "b", "c", "d"),
four = c("1", "2", "3", "4"))
)
}
\arguments{
\item{long_arg_vctr}{A named vector}
\item{long_arg_list}{A named list}
}
\description{
An example function for this issue
}
A nicer(?) outcome
I think it may be prefereable to format the \usage{} blocks to format named vectors/lists more nicely, so that they appear more legible in the final .Rd output. Something like this, perhaps:
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/growth_classify.R
\name{myfunction}
\alias{myfunction}
\title{An example function for this issue}
\usage{
myfunction(
long_arg_vctr = c(one = "1",
two = "2",
three = "3",
four = "4",
five = "5",
six = "6",
seven = "7"),
long_arg_list = list(one = c("foo", "bar"),
two = "baz",
three = c("a", "b", "c", "d"),
four = c(1, 2, 3, 4))
)
}
\arguments{
\item{long_arg_vctr}{A named vector}
\item{long_arg_list}{A named list}
}
\description{
An example function for this issue
}