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

feature request: documenting default argument values #819

Closed
IndrajeetPatil opened this issue Nov 3, 2018 · 3 comments
Closed

feature request: documenting default argument values #819

IndrajeetPatil opened this issue Nov 3, 2018 · 3 comments

Comments

@IndrajeetPatil
Copy link
Contributor

Is there any possibility that roxygen2 can automatically add the default values for function arguments in the .Rd files?

For example,let's see this is the function:

foo <- function(x, d = 1) {
return(x + d)
}

In this case, I usually write something like-

#' @param x A numeric.
#' @param d A constant numeric value to add to `x` (Default : `1`).

But typically there are scores of such arguments with set default values and manually doing it means-

  • this will be highly time-consuming
  • this will be highly error-prone since I can change the default value (d = 2) and forget to update the documentation

If roxygen2 can automatically add the default values at the end of the param description text, that would be really neat.

@gaborcsardi
Copy link
Member

Well, the defaults are already in the manual, in the Usage section. I agree that it can be nice to have them in the Arguments section as well, but I am not sure how easy that would be to implement. Probably not too bad.

this will be highly error-prone since I can change the default value (d = 2) and forget to update the documentation

Yes, R CMD check will catch discrepancies in the Usage section, though.

@hadley
Copy link
Member

hadley commented Jul 20, 2019

To me, repeating in the argument section is not terribly useful, and will require a decent amount of work because we'd need some package wide option to control the behaviour and give the user control over the precise appearance.

@hadley hadley closed this as completed Jul 20, 2019
@IndrajeetPatil
Copy link
Contributor Author

FWIW, {plumber} annotations do this.

For example, annotations for the following function signature:

Screenshot 2023-09-20 at 12 17 26

are rendered in the docs like so:

Screenshot 2023-09-20 at 12 16 19

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

3 participants