Skip to content

Move notebook examples to sphinx-gallery#371

Open
willGraham01 wants to merge 25 commits intomainfrom
wgraham/354-sphinx-gallery
Open

Move notebook examples to sphinx-gallery#371
willGraham01 wants to merge 25 commits intomainfrom
wgraham/354-sphinx-gallery

Conversation

@willGraham01
Copy link
Collaborator

@willGraham01 willGraham01 commented Mar 12, 2026

Resolves #354 |

Adds sphinx-gallery to the documentation build, which allows us to write examples in .py format using syntax similar to notebooks, but in plaintext files.

These scripts are then run when the documentation is built, and inserted into a gallery view (html) along with links to downloadable notebook versions of these scripts. Notebooks do not re-run if they are unchanged between builds, however some of the examples (notably spherical_harmonic_transform.py) are quite slow and somewhat resource intensive due to the data they need to load and plot.

TDLR;

  • We no longer need nbsphinx or nbsphinx-link. These have been dropped for sphinx-gallery.
  • Similarly, the notebooks/ directory and its contents can be removed and replaced with equivalent scripts in exmaples/.
    • JAX_CUDA_HEALPix.ipynb has been left alone since this notebook needs to run on a CUDA-enabled machine, which the docs build currently doesn't do. The gallery index page has a placeholder hard-link to this notebook inserted so it is still visible in the docs build.
    • notebooks/plotting_functions.py also still remains, despite not being used anywhere in the package or notebook code. This file could be removed though.
    • notebooks/data has moved to examples/data.
  • docs/tutorials has been removed, since we no longer need to nblink everything.
    • This directory has also been added to the .gitignore, since the build will now auto-populate it when run.
  • cartopy is required for the docs build since one of the examples depends on it, and this dependency was not listed previously in the pyproject.toml. Similarly, torch is also needed.
    • Rather than lump these into the docs dependency, a new optional dependency as been made (examples) to save on bloat. It also means that anyone with the docs dependency should be able to build the documentation so long as they tell sphinx-gallery not to run the scripts and just render them. Installing docs,exmaples will enable a full documentation build complete with the notebook rendering by sphinx-gallery.
  • Minor tweaks have been made to the README.md and some other user-facing pages to be consistent with the new location and format of the examples.

@codecov

This comment was marked as resolved.

@willGraham01 willGraham01 marked this pull request as ready for review March 13, 2026 10:43
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.

Investigate using sphinx-gallery to include tutorial examples in docs

1 participant