-
Notifications
You must be signed in to change notification settings - Fork 235
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
@describeIn throws error when used with S4 methods. #1370
Comments
Would you minding having a go at creating a reprex following the advice in https://github.com/r-lib/roxygen2/blob/main/.github/SUPPORT.md#making-a-reprex ? |
library(roxygen2)
roc_proc_text(rd_roclet(),"
#' Class \\dQuote{MongoRec}
#'
setClass('MongoRec',
slots=c('_id'='character' #Mongo ID
))
#' @describeIn MongoRec Accessor for Mongo id.
setGeneric('m_id',function(x) standardGeneric('m_id'))
#' @describeIn MongoRec Accessor for Mongo id.
setMethod('m_id','MongoRec', function(x) x@'_id')
")
#> Error in merge.rd_section_minidesc(self$get_section(type), section): identical(x$value$type, y$value$type) is not TRUE Here you go. The issue appears to be related to having a generic function and a method both documented in the same object. |
Now we get a better warning, but should consider supporting this: library(roxygen2)
x <- roc_proc_text(rd_roclet(),"
#' Class \\dQuote{MongoRec}
#'
setClass('MongoRec',
slots=c('_id'='character' #Mongo ID
))
#' @describeIn MongoRec Accessor for Mongo id.
setGeneric('m_id',function(x) standardGeneric('m_id'))
#' @describeIn MongoRec Accessor for Mongo id.
setMethod('m_id','MongoRec', function(x) x@'_id')
")
#> Warning: [<text>:12] Don't know how to combine @describeIn types "function" and
#> "class" Created on 2022-07-10 by the reprex package (v2.0.1) |
That PR makes it work, but it doesn't give particularly nice labels so re-opening. |
With current PR: library(roxygen2)
roc_proc_text(rd_roclet(),"
#' Class \\dQuote{MongoRec}
#'
setClass('MongoRec',
slots=c('_id'='character' #Mongo ID
))
#' @describeIn MongoRec Accessor for Mongo id.
setGeneric('m_id',function(x) standardGeneric('m_id'))
#' @describeIn MongoRec Accessor for Mongo id.
setMethod('m_id','MongoRec', function(x) x@'_id')
")[[1]]
#> % Generated by roxygen2: do not edit by hand
#> % Please edit documentation in ./<text>
#> \docType{class}
#> \name{MongoRec-class}
#> \alias{MongoRec-class}
#> \alias{m_id}
#> \alias{m_id,MongoRec-method}
#> \title{Class \dQuote{MongoRec}}
#> \usage{
#> m_id(x)
#>
#> \S4method{m_id}{MongoRec}(x)
#> }
#> \description{
#> Class \dQuote{MongoRec}
#> }
#> \section{Methods (by generic)}{
#> \itemize{
#> \item \code{m_id(MongoRec)}: Accessor for Mongo id.
#>
#> }}
#> \section{Functions}{
#> \itemize{
#> \item \code{m_id()}: Accessor for Mongo id.
#>
#> }} Created on 2022-07-16 by the reprex package (v2.0.1) |
I thought a perfect example of a use of
@describeIn
was describing generic functions and methods in a class definition.So here is a code snippet which I thought would work:
However, I get
(This is the same error referenced in my previous issue, about there not being sufficient context information with the error).
However, I think this should be a case where
@describeIn
works (or at least it needs better documentation as to what works and why).Note, I get a similiar error, if I move the documentation to the
m_id
generic function and try to use@describeIn m_id
for the other generic and the two methods.The text was updated successfully, but these errors were encountered: