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:nameis the fully-qualified object name (fullnamein Sphinx),objtypeis the bare type within its domain (nodomain:prefix — the domain name is supplied separately byInventoryFile::dump’sdomainsargument). - Inventory
- In-memory inventory data structure.
- Inventory
File - Inventory file handler - mirrors Sphinx’s InventoryFile class
- Inventory
Item - Inventory item representing a single object in the documentation
Functions§
- posix_
join - posixpath.join(uri, location) semantics: an absolute
location(leading/) replacesurioutright; otherwiselocationis appended, with a/inserted only ifuriis non-empty and doesn’t already end in one. (sphinx/util/inventory.py:79,157—location = posixpath.join(uri, location).)