roxygen2
roxygen2 copied to clipboard
Provide an opt-in way to warn if exported functions are missing `@examples` or `@returns`
This is particularly important for a first CRAN release, where this goes by silently in R CMD Check but is something CRAN will reject you for 100% of the time.
It could be part of the roxygen note bits we put in the DESCRIPTION file, like:
Roxygen: list(markdown = TRUE, warn_no_return = TRUE, warn_no_examples = TRUE)- Hadley also suggested it may be a bit more general, like
cran_warnings = TRUE
Then usethis::create_package() could set this for you automatically, or some other related usethis function.
This comes up a lot:
- https://twitter.com/JosiahParry/status/1514941441570713605?s=20&t=5j_OCKy4Se-A2fCH5wAJCQ
- It has been a part of the extra checks list for a while https://github.com/DavisVaughan/extrachecks
The only thing that would make this hard to implement is that the warning will come from an .Rd "topic", but we don't currently have a good way to refer this back to the block or blocks that generated it. So before implementing this, probably need to soup up backref to store the complete block reference (filename + line number + alias) while continuing to write just the file name (to avoid a bunch of unimportant diffs when changing code org). Would then also need to use that better info in the various @inherit warnings.
Rough outline:
- Capture more data in
roxy_tag_backref, most importantly as automatically added inblock_find_object() - Introduce new
warn_roxy_topic()that uses in this info - Use
warn_roxy_topic()inrd-inherits.R - Add final checking step to
roclet_process.roclet_rdthat warnings if no@returnsor@examplesblocks.
Then just need to figure out what option to use turn this on.
If we implemented these enhanced backrefs, we can also use for the @inherit warnings.
When/if we do this, nudge folks to replace @return with @returns (yeah?).
^ I seem to be hardwired to use @return https://cs.github.com/r-lib/clock?q=%40return, I only somewhat recently heard from Hadley that he prefers @returns