roxygen2 icon indicating copy to clipboard operation
roxygen2 copied to clipboard

context-aware @evalRd?

Open MichaelChirico opened this issue 2 years ago • 2 comments

We've got an Rd helper that takes the name of the attached function as an argument:

https://github.com/r-lib/lintr/blob/ab5ab94b0ef33c7c66f270b4dd2b4b10cea53840/R/class_equals_linter.R#L10-L13

essentially

#' @evalRd rd_tags("class_equals_linter")
class_equals_linter <- function() {
}

This works well, but the problem I've noticed is when we sometimes rename the function, it's easy to forget to update the name twice.

This could be avoided if @evalRd was context aware. I'm thinking like .onLoad / .onAttach get the package/lib name along, the @evalRd execution could "receive" some metadata as well.

I'm not sure the right API for this (maybe it needs to be a new @ token?) but it would save us some inconvenience.

MichaelChirico avatar Mar 30 '22 16:03 MichaelChirico

Relate to to #1243. We could probably add some new equivalent to roxy_meta_get() that provided information about the current block.

hadley avatar Mar 31 '22 15:03 hadley

Great! feel free to close if you think this is fully subsumed by that issue (it may or may not be)

MichaelChirico avatar Mar 31 '22 15:03 MichaelChirico