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

list automatically all s3 methods + individual s3 method documentations #1513

Open
MaximilianPi opened this issue Sep 15, 2023 · 1 comment
Labels
feature a feature request or enhancement rd ✍️

Comments

@MaximilianPi
Copy link

Hi @hadley, hi roxygen2 developer team,

It would be very useful for users to see the associated methods listed in a S3 function constructor, and at the same time have the individual documentation for the methods. Of course, this can be done manually, but for large packages it becomes messy at some point.

So, is there a way to automatically list all methods of a s3 class in the documentation and at the same time provide individual documentation for the methods?

@DescribeIn solves the first problem, but then suppresses individual documentation for the methods:

#' MyClass
#'
#'
#' @export
MyClass <- function() {
  out = list()
  class(out) = "MyClass"
}


#' Print class citodnn
#'
#' @param x a model created by MyClass
#' @param ... additional arguments
#' @describeIn MyClass print method
#' @export
print.MyClass <- function(x,...){
  return("MyClass")
}

The print method is listed in the MyClass documentation, but there is no independent documentation for print.Myclass anymore. The descriptions are also mixed.

Thanks for your help,
Max

@hadley hadley added the feature a feature request or enhancement label Nov 1, 2023
@hadley
Copy link
Member

hadley commented Nov 1, 2023

This is possible to automate already using the tools in https://roxygen2.r-lib.org/articles/reuse.html#inline-code, combined with careful application of methods(). And that's what we do in dplyr: https://github.com/tidyverse/dplyr/blob/main/R/doc-methods.R

But it's really hard to get all the details right, so it would be nice if roxygen2 offered more tools here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement rd ✍️
Projects
None yet
Development

No branches or pull requests

2 participants