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

Detect and Load child documents to include in validation #137

Merged
merged 42 commits into from
Sep 26, 2023

Conversation

zkamvar
Copy link
Contributor

@zkamvar zkamvar commented Sep 8, 2023

This PR will detect and load child files declared in R Markdown files. This is important because with overview lessons, and the HPC carpentry transition plan, and other community lessons, child files are heavily relied on for content, but they are not currently validated. This PR will fix #135

This is paired with carpentries/sandpaper#513

Testing

You can test this by checking out the branch and running the tests inside your local clone of {pegboard} using The usethis pull request helpers:

usethis::pr_fetch(137)
devtools::test()

Background

Child documents are defined in R Markdown documents like so:

This content is from _a child document_:

```{r child="files/the-child.md"}
```

where files/the-child.md would be relative to the parent markdown file. It is possible for a child document to have

We implemented detecting first-order children for build purposes in carpentries/sandpaper#499, but they are not loaded for validation, which leads to issues like carpentries/workbench#68.

Implementation

This implements the strategy to detect direct children by searching the code blocks for the @child attribute and extracting the file names from there when loading the Episodes.

Then, in the Lesson object, for all the episodes, each of the child files are passed through a recursive function that will load the file, gather the children (if any) and then load and append the children to the child list, recording the parents and the build parents (the source Episodes that will run the child file). With the build parents, we can query a child file and know exactly what source files it builds.

There is a method in the Lesson object that will get the entire child lineage by recursively searching the $children element until it is empty. The purpose of this is to gather the files necessary to generate the hash for the file.

This pre-processes the build parents argument so that we don't have to
constantly check for the parents of a child when it appears.
This is a bit more clever about detecting files in sub sub folders by
splitting the path and searching for the presence of the known
subfolders
I really really really like how simple this part is. I add the
collection and the machinery just works ^_^
we actually need to handle this a bit better in sandpaper as well.
zkamvar added a commit to carpentries-incubator/managing-computational-projects that referenced this pull request Sep 15, 2023
I am testing out carpentries/sandpaper#513 and carpentries/pegboard#137 to help with validation and building, which will fix carpentries/workbench#68

There was an error because the div fences were too close to the text, so I added spaces.
@zkamvar zkamvar marked this pull request as ready for review September 15, 2023 18:55
@zkamvar
Copy link
Contributor Author

zkamvar commented Sep 26, 2023

I plan to release this on Wednesday, so I will merge now

@zkamvar zkamvar merged commit 3f03e85 into main Sep 26, 2023
12 checks passed
@zkamvar zkamvar deleted the validate-children-135 branch September 26, 2023 22:07
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.

Validation needs to be reported for child files
1 participant