Skip to main content

Module numbers

Module numbers 

Source
Expand description

Section and figure numbering: TocTreeCollector.assign_section_numbers and assign_figure_numbers (sphinx/environment/collectors/toctree.py:197-378), the two halves of get_updated_docs the resolve phase runs once every document’s toc is in the environment.

  • assign_section_numbers walks env.tocs from every :numbered: toctree, filling env.toc_secnumbers[docname][anchorname] and stamping a secnumber attribute onto the very reference nodes super::toctree::build_toc created (plus the document’s title node, so rellinks can show its number).
  • assign_figure_numbers walks the doctrees in document order, following toctrees depth-first, and numbers every enumerable node (figure/table/captioned code-block) into env.toc_fignumbers[docname][figtype][id].

Both return the docnames whose numbers differ from the previous environment — Sphinx’s env-get-updated contribution, which widens the write set on an incremental build.

NOT here: the numref role’s use of these tables (std domain resolution) and numfig_format rendering. This module only assigns the numbers.

Structs§

NumberingWarning
One diagnostic from assign_section_numbers.
SectionNumbering
What assign_section_numbers produced.

Functions§

assign_figure_numbers
Assign a figure number to every enumerable node reachable from the root document.
assign_section_numbers
Assign a section number to every heading under a :numbered: toctree.

Type Aliases§

DoctreeLoader
How the numbering passes reach a document’s doctree.