Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve indentation/wrapping for named vectors/lists in \usage{} blocks #1617

Open
simpar1471 opened this issue May 2, 2024 · 0 comments
Open

Comments

@simpar1471
Copy link

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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant