blast_radius(): add include arg for @examples and vignettes (#19)#20
Merged
Conversation
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.
|
Hello @TroyHernandez This is a fantastic move ! Making my day to fix {plotluck}. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an
includeargument toblast_radius()so callers can extend the search beyond R source into roxygen@examplesblocks and vignette code chunks:"r"(default): existing R-source behavior across target and downstream projects."examples":@examples/@examplesIfblocks in the target project'sR/*.Rfiles. Thecallercolumn is the documented function name.\dontrun{}/\donttest{}wrapped code is scanned too."vignettes": R code chunks invignettes/andinst/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
sourcecolumn ("r"/"example"/"vignette"), so all hits live in one frame.Matching is regex based (
fnfollowed by(, with a negative lookbehind that rejects identifier characters) so it handlespkg::fn(),eval=FALSEchunks,\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 coverinclude = "examples",include = "vignettes", combined, invalid-value error, and thesourcecolumntinypkgr::check()— 0 errors, 0 warnings, 0 notesblast_radius("default_exclude", project = ".", include = c("r", "examples", "vignettes"), ...)finds the usage inside the@examplesblock ofutils.R