Try out sphinx-exercise for exercise formatting #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
https://ebp-sphinx-exercise.readthedocs.io/en/latest/ This allows nice formatting and referencing of exercises on the rendered website. I tested things out with https://tutorial.xarray.dev/fundamentals/02.3_aligning_data_objects.html#alignment-putting-data-on-the-same-grid
Unfortunately the more special myst and sphinx markup in .ipynb files can lead to somewhat odd appearance in JupyterLab. But I think requiring a bit of effort to reveal the solution is good to force thinking it through. Some screenshots below on how this looks unrendered and rendered:
Rendered: Current (left) and This PR (right):
Code: What a user sees in JupyterLab (left), actual markdown (right)
If solutions don't require code execution (variables from earlier in a given notebook), they could be rendered on an entirely separate page (reference/exercise_solutions.md)...
A more lightweight solution is just to have separate mardown cells with headers (###solution) and use the 'hide-output' metadata tag to reveal on the website