Repository navigation
Inherit parameter types from source topics and preserve donors during Rename - #899
renkun-ken wants to merge 8 commits into
Conversation
eitsupi
left a comment
There was a problem hiding this comment.
Reviewed by ChatGPT.
Two concerns regarding compatibility with roxygen2:
-
Package-qualified inheritance references
In roxygen2 8.1.0,
@inheritParams mypkg::donorresolves to the installed package's documentation, even whenmypkgis the package currently being developed. Seeget_rd()in R/rd-inherit.R.The current implementation instead resolves such references to the local source topic and updates them during Rename. This does not match roxygen2's semantics.
Package-qualified references should not be resolved against local source topics or rewritten during Rename. Supporting inheritance from installed packages can remain outside the scope of this PR.
-
Interaction with
@inheritParameter documentation can also be inherited through
@inherit donor paramsor an unrestricted@inherit donor.For example:
#' @param x (`First`) Input. first <- function(x) x #' @param x (`Second`) Input. second <- function(x) x #' @inherit first params #' @inheritParams second consumer <- function(x) x
Ignoring
@inheritcan lead to inferred types that differ from the documentation generated by roxygen2. Rename may also leave affected inheritance references unchanged.Full support for
@inheritis not necessary in this PR, but inference and Rename should conservatively handle unsupported inheritance directives rather than assume that@inheritParamsdescribes all relevant dependencies.
Please add regression tests covering these cases.
Part 5 of the review split for #894. This PR targets
masterafter #898 merged.This adds
@inheritParamstype propagation and its Rename handling together. A recipient can inherit matching formals from a unique source topic in the same file or package. Local@paramdocumentation takes precedence, including a prose-only description. Unrestricted@inherit donorand@inherit donor paramsalso contribute parameter descriptions. A directive such as@inherit donor titleparticipates in donor Rename without supplying parameter types.Renaming an implicit
donortopic updates the verified donor token in the directive. The selector is preserved. A qualified donor such asmypkg::donorpoints to installed help, including when developingmypkg. Local Rename leaves that spelling alone. A fixed@namehas its own documentation identity. Rename declines ambiguous ownership, capture, unverifiable edits and formal changes that would invalidate inherited documentation. These protections also apply when documentation-derived inference is disabled.The package index records consumers by unqualified donor spelling. Parameter inference follows roxygen2’s donor order and applies argument selectors from
@inheritParams. The reviewer’s two-donor example selects the first donor, as verified against roxygen2 8.1.0. Tests exercise opened, closed, unsaved and restored source files.