Skip to content

docs(api[components]): Registry-aware docutils component reference#461

Merged
tony merged 3 commits into
masterfrom
more-docutils-and-sphinx
Jun 7, 2026
Merged

docs(api[components]): Registry-aware docutils component reference#461
tony merged 3 commits into
masterfrom
more-docutils-and-sphinx

Conversation

@tony
Copy link
Copy Markdown
Owner

@tony tony commented Jun 7, 2026

Summary

  • Add docs/api/lib/components.md — a registry-aware reference covering every docutils component django-docutils ships: DjangoDocutilsWriter, DjangoDocutilsHTMLTranslator, the CodeTransform/Contents/SanitizeTransform transforms, the Pygments CodeBlock directive, and all twelve roles. Entries render with per-type kind badges and registry facts — transform default_priority as an outlined badge, the writer's resolved translator class, and the translator's own visit/depart overrides (including visit_icon, the translator-handled-node case that motivated the upstream feature).
  • Enable the sphinx_autodoc_docutils and sphinx_autodoc_sphinx extensions and pin the component autodoc stack — sphinx-autodoc-docutils, sphinx-autodoc-sphinx, sphinx-ux-autodoc-layout, sphinx-ux-badges — at the released ==0.0.1a29 in the dev and docs dependency groups.
  • Cross-link the component entries and the existing automodule pages both ways: each component-bearing module page gains a seealso pointing at its registry entry (api/lib/directives/code/components/#directive-codeblock, role pages → #role-<name>, …), and each components-page section links back to the full API page.

Companion

Design decisions

  • One components page, not per-page embeds: embedding registry entries on each automodule page would register duplicate cross-reference targets; a single canonical page owns the anchors and the module pages link to them.
  • sphinx_autodoc_sphinx enabled but inventory-empty: django-docutils registers nothing with Sphinx itself (no builders, domains, or config values) — the components page states this plainly so the docutils family reads as the complete inventory.
  • Role names: entries derive names from the callables (github_rolegithub); prose notes that the names actually registered with docutils come from the DJANGO_DOCUTILS_LIB_RST roles mapping.

Test plan

  • cd docs && just html builds clean with the released 0.0.1a29 autodoc stack installed; the components page renders the per-type kind badges, the transform priority badge, and the translator Overrides fact list (own handlers only)
  • uv lock --check consistent; all four packages resolve to 0.0.1a29 from PyPI with no prerelease warnings
  • CI: ruff / mypy / pytest on the branch

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.26%. Comparing base (fe006b5) to head (d078226).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #461   +/-   ##
=======================================
  Coverage   84.26%   84.26%           
=======================================
  Files          48       48           
  Lines        1487     1487           
=======================================
  Hits         1253     1253           
  Misses        234      234           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

tony added a commit to git-pull/gp-sphinx that referenced this pull request Jun 7, 2026
Extend registry-aware autodoc from directives, roles, and config values
to the whole docutils and Sphinx extension family, so every component a
project ships gets the same polished, cross-linked reference card.
Motivated by django-docutils, which documents a writer, translator,
three transforms, and a custom node with plain automodule today.

What's new:

- **docutils components**: sphinx-autodoc-docutils gains autotransform,
  autoreader, autoparser, autowriter, autonode, and autotranslator —
  each with a single and a bulk-by-module directive — documenting
  transforms, readers, parsers, writers, custom nodes, and translators.
- **Sphinx builders and domains**: sphinx-autodoc-sphinx gains
  autobuilder and autodomain alongside its config-value support.
- **Cross-reference roles**: two new Sphinx domains, docutils and
  sphinxext, make every documented component linkable from prose, each
  with a grouped component index.
- **Linked facts**: fact values that name a documented object — Python
  paths, translator classes, transform sets, handler overrides, config
  types, option validators, registering setup() entry points — render
  as cross-references that resolve locally or via intersphinx and
  degrade to plain chips where no target exists. List-valued facts
  render as individual chips; container config defaults render as
  Pygments-highlighted blocks.

Design:

- **Real ObjectDescription directives** per domain, so anchors, TOC
  entries, xref targets, and layout profiles come from Sphinx's own
  machinery rather than retagged markup.
- **Graceful degradation as a contract**: linked literals carry
  refwarn-off pending_xrefs, so the same fact row is a live link where
  the inventory is mapped and a plain chip where it isn't. docutils
  ships no intersphinx inventory, so its internal names degrade by
  design.
- **Recorder-replay discovery with module-scan fallback**: registered
  components surface real metadata; directly-instantiated ones are
  found by scanning. Discovery never raises at build time.

Shared layer: build_linked_literal / build_chip_paragraph inline
helpers and per-component layout profiles in sphinx-ux-autodoc-layout;
per-type badge palette with a dark-block parity guard in
sphinx-ux-badges; reference pages and demo-module autodoc sections so
every fact target resolves on gp-sphinx's own site.

Companion PR: tony/django-docutils#461
Closes #52
@tony tony force-pushed the more-docutils-and-sphinx branch from 1cbad76 to 0b6a80d Compare June 7, 2026 20:23
@tony tony force-pushed the more-docutils-and-sphinx branch from 0b6a80d to 7c103c0 Compare June 7, 2026 20:37
tony added 3 commits June 7, 2026 17:02
why: The writer, translator, transforms, directive, and roles were
documented only as plain automodule output. gp-sphinx's component
autodoc renders each with its registry metadata — transform
priorities, the writer's resolved translator class, the translator's
own visit/depart overrides — and registers docutils-domain
cross-reference targets prose can link to.

what:
- Add docs/api/lib/components.md covering every docutils component
  django-docutils ships: DjangoDocutilsWriter,
  DjangoDocutilsHTMLTranslator, CodeTransform, Contents,
  SanitizeTransform, CodeBlock, and the twelve role callables
- Enable sphinx_autodoc_docutils and sphinx_autodoc_sphinx in
  conf.py extra_extensions; django-docutils registers nothing with
  Sphinx itself, so the docutils family is the complete inventory
why: The registry-aware component entries and the automodule pages
documented the same objects with no path between them — a reader on
lib.roles.github had no link to the role's registry entry, and the
components page offered no route to full API docs.

what:
- Add a seealso on each component-bearing module page (writers,
  sanitize, both transforms, the code directive, and the eleven role
  pages) linking its registry-aware entries via domain roles
- Add "Full API" backlinks from each components-page section to the
  matching automodule page
…ence

why: docs/conf.py enables the sphinx_autodoc_docutils and
sphinx_autodoc_sphinx extensions and docs/api/lib/components.md renders
the docutils component reference through them; those packages must be
installed for the docs build to import the extensions. gp-sphinx
0.0.1a29 publishes the component autodoc family on PyPI.

what:
- Pin sphinx-autodoc-docutils, sphinx-autodoc-sphinx,
  sphinx-ux-autodoc-layout, sphinx-ux-badges at ==0.0.1a29 (dev + docs
  groups)
- Relock
@tony tony force-pushed the more-docutils-and-sphinx branch from 7a87459 to d078226 Compare June 7, 2026 22:04
@tony tony force-pushed the more-docutils-and-sphinx branch from d078226 to 26028a4 Compare June 7, 2026 22:06
@tony tony merged commit 26028a4 into master Jun 7, 2026
8 checks passed
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