Skip to content

Generate API reference with autodoc2, add class-hierarchy and object-model diagrams#9

Open
TomaSusi wants to merge 8 commits into
mainfrom
autodoc2-experiment
Open

Generate API reference with autodoc2, add class-hierarchy and object-model diagrams#9
TomaSusi wants to merge 8 commits into
mainfrom
autodoc2-experiment

Conversation

@TomaSusi

@TomaSusi TomaSusi commented Jul 7, 2026

Copy link
Copy Markdown
Member

Summary

Generates the API reference with sphinx-autodoc2 instead of sphinx.ext.autosummary, and adds two new diagrams to help readers orient in the API. Builds on top of #8 (based on that branch) — once #8 merges, this PR's diff will shrink to just the commits below.

  • API reference via autodoc2 (auto_mode, default docstring parsing): replaces the eval-rst autosummary tree and its custom templates. Pages generate into docs/reference/api/apidocs/ at build time (gitignored); docs/_ext/abtem_autodoc2.py resolves the installed abtem package path so it works locally, on CI, and on Read the Docs.
  • Removed the generated index.rst wrapper page (autodoc2_index_template: null) — the "API" sidebar item now links straight to the abtem package page instead of through an empty intermediate page.
  • Class-hierarchy diagrams (sphinx.ext.inheritance_diagram + Graphviz) for the five core class families (wave functions, potentials, detectors, scan patterns, CTF), moved to their own sub-page (reference/api/class_diagrams.md) so they don't push the full reference tree down the main API landing page. Diagram nodes link directly into the matching autodoc2 pages.
  • Conceptual object-model diagram on the overview page: inline SVG (theme-aware, works in light/dark mode) showing how PlaneWave/Probe, Potential, and the multislice/scan operations connect to produce the six simulation modes documented right below it.
  • Graphviz's dot binary is now a build dependency — added to both GitHub Actions workflows and .readthedocs.yml (apt_packages).

A separate, unmerged jb2 branch has a no-go assessment of migrating to Jupyter Book 2 outright (mystmd has no autodoc equivalent yet) — this PR stays on Jupyter Book 1, using autodoc2 purely as a Sphinx extension.

Test plan

  • Local build clean (no new warnings) with autodoc2 auto_mode, both API sub-pages, and both diagrams
  • Verified inheritance-diagram nodes link into the correct autodoc2-generated pages
  • Verified the object-model diagram renders correctly in both light and dark mode
  • After merge: confirm CI installs Graphviz successfully and the deployed site builds

🤖 Generated with Claude Code

TomaSusi and others added 8 commits July 7, 2026 11:22
Stable (release-built) docs remain the default at the site root; a new
deploy-dev workflow publishes main to /dev/ on every docs push. The two
versions cross-link via the footer (stable -> dev) and an announcement
banner (dev -> stable), and dev pages carry a robots noindex tag so
search engines only surface stable. The release deploy now carries the
existing /dev/ tree forward so the two publish cadences don't clobber
each other.

Also tidies docs/requirements.txt (duplicates, unused sphinx_rtd_theme/
nbsphinx), removes the dead doc_requirements.txt, and points the
repository buttons at abTEM/doc instead of the jupyter-book template.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
sphinx-autodoc2 (extension mode, auto_mode off) with a small custom
docutils parser that runs numpy-style docstrings through napoleon.
autodoc2_test.md renders abtem.waves.Probe both ways: default rST
parsing turns numpy sections into page headings; the napoleon bridge
produces field lists identical to the current autodoc output.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Replaces the eval-rst autosummary tree (and its custom templates) with
sphinx-autodoc2: MyST-native module pages generated into
reference/api/apidocs/ at build time (gitignored). A local extension
resolves the installed abtem package path at build time so the same
config works locally, on CI, and on Read the Docs. The two inline
autosummary tables in reference/config.md become autodoc2-summary
directives with abtem.config.* aliases. Drops now-unused autodoc,
napoleon, autosummary, and typehints extensions, the napoleon-bridge
parser, and the experiment test page.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
autodoc2's index.rst only held a toctree + footnote pointing at the
single top-level package; api.md now links straight to the abtem
package page, removing one navigation hop between the API sidebar
item and real content.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
sphinx.ext.inheritance_diagram (+ Graphviz) renders inheritance trees
for the five core class families (wave functions, potentials,
detectors, scan patterns, CTF) at the top of the API landing page, as
a quick map before the exhaustive autodoc2 tree. Diagram nodes link
directly into the matching autodoc2-generated class pages, since both
share the same Sphinx py-domain object inventory.

Graphviz's dot binary is now a build dependency: installed via apt in
both GitHub Actions workflows and via .readthedocs.yml apt_packages.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Inline SVG (theme-aware via pydata-sphinx-theme CSS variables, works
in both light and dark mode) showing how PlaneWave/Probe, Potential,
and the multislice/scan operations connect to produce the six
simulation modes documented below it, right where the existing
'abTEM object model' prose already describes this in words.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…rows

Probe is a Wave function like PlaneWave, so scan(potential, scan,
detectors) now leaves from the same box instead of a separate Probe
box. Potential now visibly feeds both multislice(potential) and
scan(...) via a dashed drop-line with junction dots where it meets
each arrow, rather than sitting disconnected above the pipeline.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The five inheritance diagrams pushed the full autodoc2 reference tree
far down the API landing page. They now live on their own sub-page
(reference/api/class_diagrams.md), registered as an explicit _toc.yml
section under API so it's not the page that opens by default -
api.md stays a short landing page linking to it, with the full
reference immediately below.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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