roxygen2忽略子类构造函数docstring

时间:2014-09-03 20:56:16

标签: r roxygen2 reference-class

我试图用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)
        }
    }
)

正如您所看到的,YourclassMyclass的子类。当加载到RStudio时,我得到了:

> ?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

显然roxygen只是忽略了子类构造函数的docstring。我在这里做错了吗?

0 个答案:

没有答案