Diagnose Exported Functions Missing Examples
Source:R/diagnostics-documentation-examples.R
lab_missing_examples.RdCRAN expects exported functions to carry a runnable \examples{} section.
Walks .Rd files via tools::parse_Rd() and reports exported function
topics that lack one. Data, class, methods, package-level, and re-export
topics are skipped, and only topics whose name appears in NAMESPACE
export() are considered (so internal helpers and S3 methods aren't
required to have examples). A function that exists only for its side effect
may be reported here even though it is fine, so use your judgement.
Value
checktor_check_result() with passed, issues, missing,
message.
Source
The CRAN Cookbook covers examples under
Structuring of Examples.
Exported functions are expected to carry an \examples{} block, a convention
rather than a rule, which is why this sits at opinion tier. See
vignette("check-sources", package = "checktor") for how every check maps to its
source.
Examples
pkg <- example_diagnose_scenario("documentation_examples/missing_examples_bad.Rd",
show_content = FALSE)
writeLines("export(undocumented_fn)", file.path(pkg, "NAMESPACE"))
lab_missing_examples(pkg, verbose = FALSE)$issues
#> [1] "missing_examples_bad.Rd"
unlink(pkg, recursive = TRUE)