Skip to content

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

Merged
lionel- merged 8 commits into
mainfrom
oak-source/3-source-dir
Aug 5, 2026
Merged

Add support for targets::tar_source() and sourceDir()#1384
lionel- merged 8 commits into
mainfrom
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 2 times, most recently from 91d767a to 14aba6b Compare August 4, 2026 13:39
@lionel-
lionel- force-pushed the oak-source/3-source-dir branch from 14aba6b to cfba59a Compare August 5, 2026 16:01
@lionel-
lionel- force-pushed the oak-source/3-source-dir branch from cfba59a to 2d968b6 Compare August 5, 2026 17:17
Base automatically changed from oak-source/2-source-inheritance to main August 5, 2026 17:19
@lionel-
lionel- force-pushed the oak-source/3-source-dir branch from 2d968b6 to 0dbd67f Compare August 5, 2026 17:19
@lionel-
lionel- merged commit 8a3f312 into main Aug 5, 2026
17 checks passed
@lionel-
lionel- deleted the oak-source/3-source-dir branch August 5, 2026 17:21
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant