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

Adding methods to another package's R6 class: how to document? #807

Closed
hongooi73 opened this issue Oct 19, 2018 · 1 comment
Closed

Adding methods to another package's R6 class: how to document? #807

hongooi73 opened this issue Oct 19, 2018 · 1 comment

Comments

@hongooi73
Copy link

hongooi73 commented Oct 19, 2018

R6 has a nifty feature where you can add new members to an existing class via set(). You can even do this to a class exported by a different package, which is very useful indeed.

For example, in package A:

#' @export
myclass <- R6::R6Class("myclass",
    public=list(
        f=function(x) { ... }
))

And in package B:

# modifying objects exported by another package must be done at runtime
.onLoad <- function(libname, pkgname)
{
    A::myclass$set("public", "g", overwrite=TRUE,
        function(y) { ... }
}

Now you can do something like

library(A)
library(B)
obj <- A::myclass$new(...)
obj$g(y=42)  # method defined by package B

How should we document the new method added by B?

@hadley
Copy link
Member

hadley commented Jul 20, 2019

Effectively a duplicate of #388, since we don't have any way to document any R6 class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants