Open rossellhayes opened 1 year ago
This error actually occurs anytime there is a dangling final setup chunk not being used anywhere else in the tutorial:
---
title: "Tutorial with unused setup chunk"
output: learnr::tutorial
runtime: shiny_prerendered
---
```{r setup, include=FALSE}
library(learnr)
x <- 2
y <- x + 1
will yield:
Error: Chunk 'second_setup' is not being used by any exercise or exercise setup chunk.
Please remove chunk 'second_setup' or reference 'second_setup' with exercise.setup = 'second_setup'
This error was initially put in place just as a safeguard that users might accidentally forget to use a setup chunk, but authors might want a warning instead to nudge them instead of totally halting rendering of document to check other things.
But, we'll need to look at [these lines](https://github.com/rstudio/learnr/blob/1ffad2a752b21a782da54bd243221e325f489e0c/R/knitr-hooks.R#L127-L133) and that general function for chained setup chunks to verify if there are other reasons to error. 🤔
Using an
exercise.setup
option in a-solution
results in an error if the chunk is not referenced in theexercise.setup
option of another chunk.Exercise 1
Exercise 2
Exercise 3
Created on 2023-04-14 with reprex v2.0.2
This can cause problems for authors who are testing an unfinished exercise that uses setup chaining. They will have to remember not to add an
exercise.setup
option toexercise-3-solution
until after they've writtenexercise-4
.Would it cause any issues if this threw a warning instead of an error?