-
Notifications
You must be signed in to change notification settings - Fork 236
Closed
Labels
Description
#196 was closed as a "duplicate" of #388 and I was very excited when the latter was closed and released with v7.0.0. Unfortunately, even with v7.0.0, base reference classes method documentation tags all get clumped together into single sections.
Modifying the example from https://roxygen2.r-lib.org/articles/rd.html#r6 slightly:
#' Reference Class Representing a Dog
#'
#' @description
#' A dog has a name and a hair color.
#'
#' @details
#' A dog can also greet you.
Dog <- setRefClass(
"Dog",
fields = list(
#' @field name First or full name of the dog
name = "character",
#' @field hair Hair color of the dog
hair = "character"
),
methods = list(
#' @description
#' Create a new dog object.
#' @param name Name.
#' @param hair Hair color.
#' @return A new `Dog` object.
initialize = function(name = NA_character_, hair = NA_character_) {
.self$name <- name
.self$hair <- hair
.self$greet()
},
#' @description
#' Change hair color.
#' @param val New hair color.
#' @return The old hair color, invisibly.
#' @examples
#' d <- Dog("Rover", "black")
#' d$hair
#' d$set_hair("red")
#' d$hair
set_hair = function(val) {
old <- .self$hair
.self$hair <- val
invisible(old)
},
#' @description
#' Say hi.
greet = function() {
cat(paste0("Woof, my name is ", .self$name, ".\n"))
}
)
)
Is there any plan to port the R6 functionality over to RC? Given the high similarity between RC and R6, would it be too wishful to assume that this wouldn't be much more lift? Or - is there just something I'm missing to get it to work already?