Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Specify order of sourcing R files #70

Open
danielinteractive opened this issue Nov 18, 2024 · 3 comments
Open

Feature Request: Specify order of sourcing R files #70

danielinteractive opened this issue Nov 18, 2024 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@danielinteractive
Copy link

danielinteractive commented Nov 18, 2024

Feature Idea

I did not see a way to specify the sourcing order of R files. In R packages this works via the @include roxygen2 tag and subsequent update of collate directive in the DESCRIPTION file. It would be great if envsetup would have a similar way to do this.

Relevant Input

Say you have file a.R which for successful sourcing depends on code in b.R to be sourced beforehand. This arises e.g. in S4 class definitions or function factory calls.

Relevant Output

Currently this will fail. It would be great if there is a way to define that a.R depends on b.R and therefore b.R should be sourced first.

Reproducible Example/Pseudo Code

No response

@danielinteractive danielinteractive added the enhancement New feature or request label Nov 18, 2024
@nicholas-masel
Copy link
Collaborator

@danielinteractive Thanks for the comment. We should be able to add a tag to each script for this, or we can add a place in the envsetup configuration file that would allow users to overwrite the default source order.

@danielinteractive
Copy link
Author

Thank you @nicholas-masel , maybe it would even be possible to use a similar pattern as in roxygen2 by having a look how they get from the @include tag usage to the collate list order. The advantage would be to minimize the workload for the user (only need to use such tag when needed)

@nicholas-masel nicholas-masel self-assigned this Nov 22, 2024
@nicholas-masel
Copy link
Collaborator

@danielinteractive Yep, I completely agree and this looks straightforward. We'll update autos() to call roxygen:::generate_collate() to define the source order.

Here is a simple example:

#' @include inc2.R inc3.R
inc1 <- function(){
}

> roxygen2:::generate_collate("tests/testthat/ref/R")
[1] "inc3.R" "inc2.R" "inc1.R"

nicholas-masel pushed a commit that referenced this issue Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants