roxygen2 icon indicating copy to clipboard operation
roxygen2 copied to clipboard

R6: Documenting superclass's fields/active bindings in inherited/contained class

Open iferres opened this issue 4 years ago • 3 comments

Hi. First of all, thanks for adding support for documenting R6 classes!

My question is: Is there a way to document the inherited fields/active-bindings in the sub-class (R6 classes)? Documentation about methods is well inherited, but I can't see superclass's active binding documentation in the sub-class. May be I'm using wrong the nomenclature and this is not a case of inheritance, my case is:

Parent <- R6Class("Parent", 
   public = list(
      #' @description blah blah..
      initialize = function(x = 1, y = 2) ...,
      #' @description bleh bleh..
      method_1 = function () ...
   ),

   active = list(
      #' @description blih blih..
      active_1 = function() ...
   )
)

Son <- R6Class("Son", 
   inherit = Parent, 
   public = list(
      #' @description bloh bloh..
      initialize = function(x = 1, y = 2){
         super$initialize(x, y)
      },
      #' @description bluh bluh..
      method_2 = function() ...
   ),

   active = list(
      #' @description foo foo...
      active_2 = function() ...
   )
)

In the above case, the class Son will have the documentation of method_1 (from Parent class), but I would like to also "inherit" active_1 documentation. Is there any way to achieve that? If not the case, where should I (re)write the documentation of active_1 to also appear in the Son class? Initializing Son with super$initialize(...) effectively adds all the Parent fields/active bindings to the sub-class, but not the documentation.

iferres avatar Jan 07 '20 19:01 iferres

It should appear in an "Inherited active bindings" section, like the "Inherited methods" section, but you are right, that does not happen currently.

gaborcsardi avatar Jan 07 '20 20:01 gaborcsardi

Thanks for your answer @gaborcsardi . It is worth considering that these active bindings are inherited recursively (i.e. C-->B-->A), and so should be the documentation I think (documentation of C should contain active bindings from B as well as from A, or at least to make a reference to them), am I right?

Are you planning to give support for this feature in the future? Thanks again.

iferres avatar Jan 08 '20 12:01 iferres

The methods are listed recursively, so it will be the same for active bindings.

gaborcsardi avatar Jan 08 '20 12:01 gaborcsardi