Skip to content

Inherit method documentation from R6 Superclass (even if overriding the method) #996

@s-fleck

Description

@s-fleck

I hope I'm not overlooking an existing feature. It would be great if there were a mechanism for inheriting method- and field documentation from a superclass. For me it is a very common use-case to have several subclasses of the same base class that have a similar interface but vary in the implementation details. In the following case I would want to inherit the whole documentation for ProcessorSmart$run() from Processor$run(), even if I am overriding the $run() method:

#' An Abstract Class
#' @export
Processor <- R6::R6Class(
  "Processor",
  public = list(

#' Process a dataset
#' @param x a `data.frame`
#' @return a processed`data.frame`
    run = function(x) {
      stop("Not implemented")
    })
)

#' An Real Class
#' @export
ProcessorSmart <-  R6::R6Class(
  "ProcessorSmart",
  inherit = Processor,
  public = list(

    run = function(x){
        cat("implemented")
        x
    }
  )
)

edit: edited for clarity, as non-overridden methods are inherited already and link to the base class. Though It still would be great to have the actual method documentation repeated on the subclass documentation page instead of just a link.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions