Skip to content

Support for @inheritParams R6Class$method in other doc entries #1502

@MichaelChirico

Description

@MichaelChirico

Related: #931

It is fairly common in my (admittedly limited) experience to have something like:

# In R6.R

#' @param x An object
#' @export
R6Class("MyClass",
  public = list(
    x = NULL
    my_method = \(x) {
      self$x <- my_method_impl(x)
      self
    }
  )
)

# my_method.R

#' @inheritParams MyClass$my_method
#' @noRd
my_method_impl <- function(x) x

The point is my_method_impl and MyClass$my_method share parameters, but are documented in separate source files. I believe (untested) that @inheritParams MyClass will work today, but this only helps with the user-facing documentation -- my suggestion is for helping other developers reading the code.

In this simple case, it's easy to guess where to look for a description of x, but may be harder for complicated classes with many methods.

So in my mind, @inheritParams MyClass$my_method is pure syntax -- the roxygenize() backend simply removes $my_method and proceeds the same as @inheritParams MyClass.

As a workaround, I find myself using non-roxygen comments:

#' @inheritParams MyClass
#.' <specifically, the my_method method>
#' @noRd
my_method_impl <- function(x) x

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