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

Issue with S3 generics and @describeIn #1482

Closed
kylebutts opened this issue May 18, 2023 · 2 comments
Closed

Issue with S3 generics and @describeIn #1482

kylebutts opened this issue May 18, 2023 · 2 comments

Comments

@kylebutts
Copy link

Hi, I'm trying to figure out how to fix this problem with S3 methods and @describeIn. When bundling func1.default and func2.default together, the functions section miswrites it as func1(default):

library(roxygen2)
roc_proc_text(rd_roclet(), r'(
  #' @export
  func1 = function(x, ...) {
    UseMethod("func1", x)
  }

  #' @title Function 1
  #' 
  #' @describeIn func2.default Function 1
  #' 
  #' @export
  func1.default = function(x, ...) {

  }

  #' @export
  func2 = function(x, ...) {
    UseMethod("func2", x)
  }

  #' @title Function 2
  #'
  #' @export
  func2.default = function(x, ...) {

  }
)')
#> $func2.default.Rd
#> % Generated by roxygen2: do not edit by hand
#> % Please edit documentation in ./<text>
#> \name{func1.default}
#> \alias{func1.default}
#> \alias{func2.default}
#> \title{Function 1}
#> \usage{
#> \method{func1}{default}(x, ...)
#> 
#> \method{func2}{default}(x, ...)
#> }
#> \description{
#> Function 1
#> 
#> Function 2
#> }
#> \section{Functions}{
#> \itemize{
#> \item \code{func1(default)}: Function 1
#> 
#> }}

Created on 2023-05-17 with reprex v2.0.2

This doesn't happen when there is no S3 generic:

library(roxygen2)
roc_proc_text(
  rd_roclet(), 
  r'(

    #' @title Function 1
    #' 
    #' @describeIn func2.default Function 1
    #' 
    #' @export
    func1.default = function(x, ...) {

    }

    #' @title Function 2
    #'
    #' @export
    func2.default = function(x, ...) {

    }
  )'
)
#> $func2.default.Rd
#> % Generated by roxygen2: do not edit by hand
#> % Please edit documentation in ./<text>
#> \name{func1.default}
#> \alias{func1.default}
#> \alias{func2.default}
#> \title{Function 1}
#> \usage{
#> func1.default(x, ...)
#> 
#> func2.default(x, ...)
#> }
#> \description{
#> Function 1
#> 
#> Function 2
#> }
#> \section{Functions}{
#> \itemize{
#> \item \code{func1.default()}: Function 1
#> 
#> }}

Created on 2023-05-17 with reprex v2.0.2

Please forgive me if I'm missing something obvious!

@hadley
Copy link
Member

hadley commented Nov 1, 2023

Sorry if I'm being dense, but what's the problem?

@kylebutts
Copy link
Author

Nope; it was me being dense. I thought it was a bug because (default) looks like you're calling the function on an objected called default. I understand now, sorry!

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

2 participants