2

I am trying to document two reference classes with roxygen2:

#' myclass 
#' @field fa A number
#' @field fb A number
#' @field filename A filename
#' @field data A data frame
Myclass = setRefClass("Myclass",
                      fields = list(
                          fa = "numeric",
                          fb = "numeric",
                          data = "data.frame"
                      )
)


Myclass$methods(
    initialize = function(fa = NULL, fb = NULL, filename = NULL) {
        "constructor of myclass"
        if(!is.null(fa) && !is.null(fb) && !is.null(filename)) {
            message("Initializing object in class...")
            .self$fa = fa
            .self$fb = fb
            .self$data = read.table(.self$filename, header=TRUE)
        }
    }
)

#' A subclass of myclass
Yourclass = setRefClass("Yourclass", fields = list(msg = "character"), contains = "Myclass")

Yourclass$methods(
    initialize = function(..., msg = NULL) {
        "constructor of Yourclass, just added a message."
        callSuper(...)
        if(!is.null(msg)) {
            message(msg)
        }
    }
)

As you can see Yourclass is a subclass of Myclass. When loaded into RStudio, I got:

> ?Yourclass

Yourclass-class {collr} R Documentation
A subclass of myclass

Description

A subclass of myclass

Methods

initialize(fa = NULL, fb = NULL, filename = NULL)
constructor of myclass

Apparently roxygen just ignores the docstring of the subclass constructor. Am I doing anything wrong here?

qed
  • 22,298
  • 21
  • 125
  • 196

0 Answers0