Skip to content
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

Document RC methods analogous to R6 #964

Closed
d-sci opened this issue Nov 13, 2019 · 2 comments
Closed

Document RC methods analogous to R6 #964

d-sci opened this issue Nov 13, 2019 · 2 comments
Labels
feature a feature request or enhancement R6 6️⃣

Comments

@d-sci
Copy link
Contributor

d-sci commented Nov 13, 2019

#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"))
    }
  )
)

Renders this:
Screen Shot 2019-11-13 at 7 43 58 AM

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?

@gaborcsardi
Copy link
Member

Thanks! Sorry for the misleading issue references.

As we are not using RC classes actively, and RC support seems to be rather involved, ideally this would go into its own roxygen2 extension package, maintained by someone else.

We'll come back to this the next time we work on roxygen2, probably is 1-2 months.

@hadley hadley added feature a feature request or enhancement R6 6️⃣ labels Nov 20, 2019
@hadley
Copy link
Member

hadley commented Nov 20, 2019

Agreed with @gaborcsardi; since we don't use reference classes ourselves, this would be better maintained by someone else.

@hadley hadley closed this as completed Nov 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement R6 6️⃣
Projects
None yet
Development

No branches or pull requests

3 participants