Is there a way to document the S4 class and its constructor separately using Roxygen2

I am trying to create an S4 class using my own initialization method and separately document them using Roxygen2. Assuming my class is defined as:

#' This is the classA
#' @name classA-class
#' @rdname classA-class
######## @aliases NULL
#' @exportClass classA
classA <- setClass(Class = "classA", slots = list(member = "ANY"))

Using the initialization method:

#' This is the constructor
#' @name classA
#' @rdname classA
#' @export classA
setMethod("initialize", "classA", function(.Object, x) {
             .Object@member = x
             return(.Object)
         })

After compiling the package with Roxygen2. I have 2 .Rd files with 3 help pages:

  • classA-class: this is classA
  • classA: This is classA
  • classA: This is the constructor

Both class?classAand ?classAwill show help page classA-class. This is definitely what I want, because, as I hope, class?classAwill lead to classA-class: This is the classA, and ?classAwill lead to classA: This is the constructor.

So my question is how to separate the documentation of classes and constructor documentation with Roxygen2? Thank you so much for your help.

( , Roxygen2 S4, @aliases NULL, classA-class: This is the classA , classA: This is the constructor)

+4
1

, , , setClass . , initialize, classA, @rdname classA, classA-method.

:

-, Roxygen2 , @name, initialize, classA.

#' \code{classA} class definition
#'
#' @slot member description of this slot here
classA <- setClass(Class = "classA", slots = list(member = "ANY"))    

#' constructor for \link{classA-class}
#' 
#' This is the constructor.
#' @name initializeClassA
#' @export
setMethod("initialize", "classA", function(.Object, x) {
    .Object@member = x
    return(.Object)
})

class ?classA ?"classA-class", , @rdname, . ?initializeClassA, , .

-, , initialize, classA, new("classA", memberValue). member, , / . ?

+3

All Articles