Skip to content

blast_radius(): add include arg for @examples and vignettes (#19)#20

Merged
TroyHernandez merged 2 commits into
mainfrom
blast-radius-documentation
Apr 24, 2026
Merged

blast_radius(): add include arg for @examples and vignettes (#19)#20
TroyHernandez merged 2 commits into
mainfrom
blast-radius-documentation

Conversation

@TroyHernandez
Copy link
Copy Markdown
Contributor

Summary

Adds an include argument to blast_radius() so callers can extend the search beyond R source into roxygen @examples blocks and vignette code chunks:

blast_radius("fn", include = c("r", "examples", "vignettes"))
  • "r" (default): existing R-source behavior across target and downstream projects.
  • "examples": @examples / @examplesIf blocks in the target project's R/*.R files. The caller column is the documented function name. \dontrun{} / \donttest{} wrapped code is scanned too.
  • "vignettes": R code chunks in vignettes/ and inst/doc/ (Rmd, qmd, Rnw). Prose outside chunks is ignored.

Documentation scanning is target-project only. Downstream scanning stays R-source only (scope per the issue thread).

The returned data frame now has a source column ("r" / "example" / "vignette"), so all hits live in one frame.

Matching is regex based (fn followed by (, with a negative lookbehind that rejects identifier characters) so it handles pkg::fn(), eval=FALSE chunks, \dontrun{} blocks, and other cases R's parser would choke on.

Closes #19.

Test plan

  • tinytest::test_package("saber") — all existing tests still pass; new tests cover include = "examples", include = "vignettes", combined, invalid-value error, and the source column
  • tinypkgr::check() — 0 errors, 0 warnings, 0 notes
  • Smoke test on saber itself: blast_radius("default_exclude", project = ".", include = c("r", "examples", "vignettes"), ...) finds the usage inside the @examples block of utils.R

Extends blast_radius() with an `include` parameter so callers can ask
for references beyond R source:

  blast_radius("fn", include = c("r", "examples", "vignettes"))

- "r" (default): existing R-source behavior (target + downstream).
- "examples": roxygen @examples / @examplesIf blocks in the target
  project's R/*.R files. The `caller` column is the documented
  function name. \dontrun{} / \donttest{} wrappers are scanned too.
- "vignettes": R code chunks in vignettes/ and inst/doc/ for Rmd, qmd,
  and Rnw files. Prose outside chunks is ignored.

Documentation scanning is target-project only; it does not walk
downstream projects' docs.

Output adds a `source` column ("r" / "example" / "vignette"), so all
hits live in a single data frame. Existing callers are backward
compatible: default `include = "r"` reproduces the old row set plus
the new column.

Matching is regex based (fn followed by an open paren, with a negative
lookbehind that rejects identifier characters so `pkg::fn(` matches
but `myfn(` does not). That keeps detection fast and handles
`eval=FALSE` chunks, \dontrun{} blocks, and Rd directives that R's
parser would choke on.

Closes #19.
@cregouby
Copy link
Copy Markdown

Hello @TroyHernandez

This is a fantastic move ! Making my day to fix {plotluck}.
Thanks!

@TroyHernandez TroyHernandez merged commit 63b3a0d into main Apr 24, 2026
4 checks passed
@TroyHernandez TroyHernandez deleted the blast-radius-documentation branch April 24, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Please add a documentation option to blast_radius()

2 participants