Skip to content

Update AutoNumbering transform.#14400

Open
gmilde wants to merge 5 commits intosphinx-doc:masterfrom
gmilde:ids
Open

Update AutoNumbering transform.#14400
gmilde wants to merge 5 commits intosphinx-doc:masterfrom
gmilde:ids

Conversation

@gmilde
Copy link
Copy Markdown
Contributor

@gmilde gmilde commented Apr 16, 2026

Purpose

a) Ensure that enumerable elements (tables, figures and literal_blocks)
have an ID. (In Docutils > 0.22, nodes.document.note_implicit_target()
does not genereate an ID if legacy_ids_ is False.)

b) Title-derived IDs for enumerable elements:

"Enumerable elements" get an auto-ID in the AutoNumbering SphinxTransform
and a self-link (¶) after the caption/title in the HTML document.

Currently, the ID is made of the "auto-id-prefix" + a running number
(id1, id2, ...). The generated IDs are not stable -- inserting/removing
an enuerable element, footnote, or section with non-Latin heading will
change the running number!

Base the generated IDs on the caption or title text instead (similar to
sections). To avoid changed IDs when documents are re-compiled, this
only happens if legacy_ids_ is False.

For user-visible changes, remember to add an entry to CHANGES.rst.

CHANGES.rst is still the 9.1.0-final version so I'll postpone this step.

References

.. _legacy_ids: https://docutils.sf.net/docs/user/config.html#legacy-ids

This is part of ongoing work in Docutils around better IDs:
https://sourceforge.net/p/docutils/bugs/207/
#8709

gmilde added 5 commits April 16, 2026 10:19
a) Ensure that enumerable elements (tables, figures and literal_blocks)
   have an ID. (In Docutils > 0.22, `nodes.document.note_implicit_target()`
   does not genereate an ID if `legacy_ids`_ is False.)

b) Title-derived IDs for enumerable elements:

   "Enumerable elements" get an auto-ID in the `AutoNumbering` SphinxTransform
   and a self-link (¶) after the caption/title in the HTML document.

   Currently, the ID is made of the "auto-id-prefix" + a running number
   (id1, id2, ...).  The generated IDs are not stable -- inserting/removing
   an enuerable element, footnote, or section with non-Lating heading will
   change the running number!

   Base the generated IDs on the caption or title text instead (similar to
   sections).  To avoid changed IDs when documents are re-compiled, this
   only happens if `legacy_ids`_ is False.

.. _legacy_ids: https://docutils.sf.net/docs/user/config.html#legacy-ids
Break long code line.
Delete whitespace around `:` binary operator.
This is the style expected by flake8 but fails upstream...
@gmilde
Copy link
Copy Markdown
Contributor Author

gmilde commented Apr 17, 2026

See PR #14399 for a fix for the failing Python 3.15 tests.

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