Skip to main content

Module genindex

Module genindex 

Source
Expand description

The index domain and the general index it feeds: Sphinx’s IndexDomain (domains/index.py) collection half, and IndexEntries.create_index (environment/adapters/indexentries.py:54-197) — the assembly half that turns the collected 5-tuples into the grouped, sorted structure genindex.html renders.

See docs/superpowers/plans/2026-08-31-m2-wave4-research-spec-sphinx-env-toctree-domains.md §6 for the attribute-by-attribute mapping this port is drawn from.

What feeds it. Everything here reads index nodes out of a finished doctree, so its fidelity is bounded by the parse layer’s. Two gaps are known and belong to that layer, not this one (neither is exercised by the environment-oracle corpus):

  • The :index: role (IndexRole, domains/index.py:97-117) is not implemented, so :index:text`` parses as problematic and indexes nothing.
  • .. index:: with a :name: should anchor its entries on the id docutils’ note_explicit_target gives the named target (domains/index.py:78-83), and consume no index-N serial. This crate’s :name:-optioned targets carry a name but no id throughout the parse layer, so those entries anchor on index-N instead — and because the serial is consumed, every later index-N in the same document is shifted up by one as well, so the divergence is not confined to the named directive’s own entries.

Unicode caveat. The sort and grouping keys normalize to NFD and lowercase exactly where Sphinx does, but two primitives are Rust’s rather than Python’s:

  • str::to_lowercase/char::to_uppercase are full Unicode case mappings, like Python’s str.lower()/str.upper() (both expand U+0130 to i + combining dot, both special-case final sigma). No divergence is known for the corpus, and none is expected outside locale-sensitive mappings (Turkish dotless i), which neither applies.
  • [py_isalpha] approximates Python’s str.isalpha() (general category L*) with Rust’s char::is_alphabetic (the Alphabetic derived property). The two differ for Nl (Ⅷ, ↀ) and for Other_Alphabetic combining marks — which NFD produces — so an entry starting with a Devanagari vowel sign, or a Roman-numeral character, would be grouped under itself here and under Symbols by Sphinx. Closing that needs a general-category table this crate does not carry.

Structs§

IndexEntry
One top-level index entry with its targets and sub-entries.
IndexGroup
One letter (or category-key) heading of the general index.
IndexMessage
A diagnostic create_index raises, located at a whole document (location=docname, which renders as the source path with no line).
IndexSubItem

Functions§

create_index
IndexEntries.create_index(builder, group_entries=True) (environment/adapters/indexentries.py:54-197).
process_doc
IndexDomain.process_doc (domains/index.py:48-61).
snapshot
The finished index as JSON, in the oracle fixture’s genindex shape. Infallible: every field of these structs is a plain string, option or vector.

Type Aliases§

IndexTarget
One (main, uri) target: main is Sphinx’s literal "main"/"".