Skip to content

replace notebooks with jupytext#5195

Open
danshapero wants to merge 4 commits into
releasefrom
drs/jupytext
Open

replace notebooks with jupytext#5195
danshapero wants to merge 4 commits into
releasefrom
drs/jupytext

Conversation

@danshapero

Copy link
Copy Markdown
Contributor

Fixes #4735 . I pointed Claude at this and it got most of the way there. It saves about 6MB of rendered notebooks. I looked over the generated HTML docs and made a few minor fixes: adding top-level headings to the notebooks; removing some unnecessary preamble code; and fixing some goofed up link formatting.

There are still some warnings in the rendered sum-factorization notebook but those are because of FInAT.

danshapero and others added 4 commits June 19, 2026 16:53
Store the introductory Jupyter notebooks as jupytext py:percent scripts
instead of committing large executed .ipynb files, and render them into
the Sphinx website.

- Convert the 12 notebooks under docs/notebooks to py:percent .py files
  (source of truth) and remove the .ipynb. Add docs/notebooks/jupytext.toml
  pinning the format and preserving cell `tags`.
- Drive notebook behaviour with standard Jupyter cell tags rather than
  nbval comment markers: `raises-exception` (honoured by both nbval and
  nbconvert/nbsphinx), plus `skip-execution`/`nbval-skip` for Colab-only
  install cells and `nbval-ignore-output`. No build-time tagging script.
- Build: convert .py -> .ipynb, execute once, and render with nbsphinx
  (executed in the docs/Makefile, nbsphinx_execute='never'). Each page
  gets a "Run on Colab" badge. Rewrite notebooks.rst as a toctree index.
- Add nbsphinx/jupytext/ipykernel/ipympl to the docs extra, jupytext to
  the ci/docker extras, and install pandoc in the docs CI job.
- Update the notebook test to convert .py -> .ipynb before running nbval,
  and the colab publishing job to convert before copying.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Notebooks with several level-1 (``#``) headings produced a table of
contents that listed each heading (e.g. "Exercises", "Part II") as an
undistinguished top-level entry alongside the notebook title, because
Sphinx cannot pick a page title when a document has multiple top-level
sections.

Demote the extra top-level sections (and their subsections) in
01-spd-helmholtz, 02-poisson, 03-elasticity, 07-geometric-multigrid and
12-HPC_demo so each notebook has exactly one ``#`` title with the rest
nested beneath it. The TOC now shows one entry per notebook.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Putting `monospace text` inside a link text is broken.
@danshapero danshapero changed the title Drs/jupytext replace notebooks with jupytext Jun 20, 2026
@danshapero

Copy link
Copy Markdown
Contributor Author

The doc build is failing because of a link from the FEnICS 2015 conference to the Transport for London website.

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