Skip to main content

Module inventory

Module inventory 

Source
Expand description

objects.inv reader/writer — mirrors sphinx.util.inventory (Sphinx 9.1.0).

The file is framed as: one \n-terminated ASCII header line naming the format version, followed by version-specific content. Version 2 (the only format any Sphinx release still writes, though 1 is still read) packs three more header lines and then a raw zlib-compressed byte tail — never text, never line-split, never re-encoded — that decompresses to one text record per object. Every byte-framing decision below (partition/split at \n, blind column-11 header slices, the exact regex, $-suffix expansion happening before the posixpath join, dispname - stored verbatim) mirrors sphinx/util/inventory.py InventoryFile.loads / _loads_v1 / _loads_v2 / dump byte-for-byte; see docs/superpowers/plans/2026-08-31-m2-wave4-research-spec-inventory-intersphinx.md §1 for the file:line citations this was built against.

The previous reader here decoded the whole file with String::from_utf8_lossy and iterated .lines() over it — which mangles the raw zlib payload (lossy UTF-8 replacement + line-splitting on bytes that were never text) on every real-world inventory. This rewrite never treats the compressed tail as anything but a byte slice until after zlib::decompress has run.

Structs§

InvObject
One object record to write, in the shape domain.get_objects() yields: name is the fully-qualified object name (fullname in Sphinx), objtype is the bare type within its domain (no domain: prefix — the domain name is supplied separately by InventoryFile::dump’s domains argument).
Inventory
In-memory inventory data structure.
InventoryFile
Inventory file handler - mirrors Sphinx’s InventoryFile class
InventoryItem
Inventory item representing a single object in the documentation

Functions§

posix_join
posixpath.join(uri, location) semantics: an absolute location (leading /) replaces uri outright; otherwise location is appended, with a / inserted only if uri is non-empty and doesn’t already end in one. (sphinx/util/inventory.py:79,157 — location = posixpath.join(uri, location).)