resampling-stats / resampling-with

Source repository for third edition of "Resampling: The New Statistics"
https://resampling-stats.github.io
Other
11 stars 9 forks source link

`ninja` does not reset `_variables.yml` when switching back to e.g Python build #146

Open matthew-brett opened 11 months ago

matthew-brett commented 11 months ago

I often find myself building the Python page, then building the R page, and then going back to the Python page. The profile and variable config stuff works correctly for the initial Python page build, then switching to the R build, but the switching script does not get called when switching back from the R to the Python build (I assume the same is true the other way round).

So let's say I start with:

make ninja-config
cd source

The initial build works fine:

$ ninja ../python-book/significance.html
[25/34] ../scripts/set_version.py --output=_quarto-python.yml python
Writing configuration to _quarto-python.yml...
Writing _variables.yml...
...
[34/34] quarto render significance.Rmd --no-clean --to html --profile python

All good. Switching to the R build also works fine - including the Writing configuration ... stuff to switch versions:

$ ninja ../r-book/significance.html
[1/2] ../scripts/set_version.py --output=_quarto-r.yml r
Writing configuration to _quarto-r.yml...
Writing _variables.yml...
[1/2] quarto render significance.Rmd --no-clean --to html --profile r

So far, no problem. But now, if I switch back to the Python page build:

$ touch significance.Rmd 
$ ninja ../python-book/significance.html
[1/1] quarto render significance.Rmd --no-clean --to html --profile python

Notice there is no Writing configuration ... step here - so the resulting built page uses the R variables written into _variables.yml, and because of that, the _common.R utilities will assume this is an R build, and filter out the Python blocks instead of the R blocks.

I can work round this by running:

../scripts/set_version.py --output=_quarto-python.yml python

manually, but it would be good not to have to do that. Any insights?

stefanv commented 4 weeks ago

https://github.com/quarto-dev/quarto-cli/issues/5954

stefanv commented 4 weeks ago

We can consider switching to meta, and putting the variables directly in the _quarto.yml?

https://quarto.org/docs/authoring/variables.html#meta