Skip to content

Add support for targets::tar_source() and sourceDir() - #1384

Open
lionel- wants to merge 8 commits into
oak-source/2-source-inheritancefrom
oak-source/3-source-dir
Open

Add support for targets::tar_source() and sourceDir()#1384
lionel- wants to merge 8 commits into
oak-source/2-source-inheritancefrom
oak-source/3-source-dir

Conversation

@lionel-

@lionel- lionel- commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Addresses posit-dev/positron#14790
Progress towards #1338

Source effects can now target a directory instead of a single file, which covers the two idioms for loading a folder of scripts: targets::tar_source() and the sourceDir() example from ?source.

# _targets.R
library(targets)
tar_source()                 # defaults to files = "R"
tar_target(x, my_helper())   # goto-def lands in R/my_helper.R

The resolver expands the directory into one target per script, in list.files() order. Load order within the call is respected: code/b.R sees code/a.R but not the other way around. Combined with the previous PR this also means the sourced files see each other, through the sourcing file's scope, without relying on the R/ auto-collation of the first PR.

The PR also adds ad hoc support for sourceDir() with a total hack: any calls to sourceDir() with a resolvable string causes a Source effect. This is to handle the documented pattern in ?source that people are copying around: https://github.com/search?q=sourceDir+language%3AR&type=code. Ideally we'd infer the effects from the list.files() and source() calls. One day.

Positron Release Notes

New Features

Bug Fixes

  • N/A

@lionel-

lionel- commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

Edit: See #1388 (comment)

@lionel-
lionel- requested a review from thomasp85 July 31, 2026 16:38
@lionel-
lionel- force-pushed the oak-source/3-source-dir branch 2 times, most recently from 7efc97b to f303691 Compare August 3, 2026 13:17
@lionel-
lionel- force-pushed the oak-source/3-source-dir branch from f303691 to cf3a28c Compare August 3, 2026 16:18
@lionel-
lionel- force-pushed the oak-source/3-source-dir branch from cf3a28c to bdc2a52 Compare August 3, 2026 18:19
@lionel-
lionel- removed the request for review from thomasp85 August 3, 2026 18:46
@lionel-
lionel- force-pushed the oak-source/3-source-dir branch from bdc2a52 to c58fd74 Compare August 4, 2026 03:56
@lionel-
lionel- force-pushed the oak-source/3-source-dir branch from c58fd74 to fa775fb Compare August 4, 2026 08:29
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.

1 participant