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

Account for child files in Rmd #499

Merged
merged 25 commits into from
Aug 31, 2023
Merged

Account for child files in Rmd #499

merged 25 commits into from
Aug 31, 2023

Conversation

zkamvar
Copy link
Contributor

@zkamvar zkamvar commented Aug 15, 2023

This will address #497 by allowing child file changes to cause the rebuild of a parent file. This is done in three steps:

  1. The accounting for child documents now occurs right after the intial hashes are taken.
  2. We search for child documents only in R Markdown documents
  3. We take the hash of the combined hashes of the child documents and the parent file using rlang::hash() so if one of those hashes changes, then the parent file is rebuilt, but if none change, then the parent file remains.

In addition, this modifies serve() and build_lesson() to take into account the situation when someone passes a child file to build_lesson() so that the correct parent file is found to rebuild.

To test this locally, with a lesson, you can install it with:

remotes::install_github("carpentries/sandpaper#499")

To test this in a live lesson, you can use this in your config.yaml

sandpaper: carpentries/sandpaper@use-child-files-for-db

To run the development tests, you can use the PR commands from usethis inside the sandpaper repository:

library("usethis")
pr_fetch(499)
devtools::test()

When you are done, run this to get back to the main branch.

pr_finish()

zkamvar added 20 commits August 15, 2023 11:00
This moves some code out of build_markdown so that I can use it in other
contexts
If we take the md5 sums of the child files and then use that to provide
the hash of hashes before the comparison, then we can get these files to
rebuild reliably
This does a few things:

1. The accounting for child documents now occurs right after the intial
   hashes are taken.
2. We search for child documents only in R Markdown documents
3. We take the hash of the combined hashes of the child documents and
   the parent file so if one of those hashes changes, then the parent
   file is rebuilt, but if none change, then the parent file remains.
4. Removes the child file accounting in the comparison step
This will not compute the hash of the hash if there are no child
documents
@zkamvar zkamvar marked this pull request as ready for review August 29, 2023 18:46
if a config file is edited, then the whole lesson gets rebuilt
This takes care of the situation where a child file could be passed to
`build_lesson()` In this case, we need to find the parent file to
process it.
@zkamvar zkamvar mentioned this pull request Aug 31, 2023
@zkamvar zkamvar merged commit c205663 into main Aug 31, 2023
@zkamvar zkamvar deleted the use-child-files-for-db branch August 31, 2023 18:57
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