Expand description
Serialized BuildEnvironment — the persistent build-state record that
mirrors Sphinx’s BuildEnvironment (environment/__init__.py), scoped to
the fields this wave’s read-and-resolve phase populates (see
docs/superpowers/plans/2026-08-31-m2-wave4-research-spec-sphinx-env-toctree-domains.md
§1 for the full attribute-by-attribute mapping this struct is drawn
from).
Persisted as bincode (bincode::serde + bincode::config::standard(),
the same config crate::doctree::to_bincode/from_bincode use) to
<cache_dir>/env.bin. That file lives inside the cache directory
governed by the .config-fingerprint wipe protocol in src/cache.rs: a
change to a content-bearing configuration value nukes the whole cache
dir, env.bin included — which is the desired behavior, since the
environment was built under the old configuration. Note that this is
broader than Sphinx, which only invalidates its environment for config
values with rebuild class 'env' and never deletes its doctrees; the
filter in builder::EXCLUDED_FROM_FINGERPRINT keeps at least the purely
operational flags (-W, -n) from triggering it.
Every collection here is a BTreeMap/BTreeSet rather than the
Hash* equivalent so that bincode bytes and BuildEnvironment::snapshot
output are deterministic across runs and processes.
Re-exports§
pub use py_domain::PyDomainData;pub use std_domain::StdDomainData;
Modules§
- dependencies
env.dependencies[docname]— the files a document is built from besides its own source, and the reason a build re-reads a document whose source never changed.- genindex
- The
indexdomain and the general index it feeds: Sphinx’sIndexDomain(domains/index.py) collection half, andIndexEntries.create_index(environment/adapters/indexentries.py:54-197) — the assembly half that turns the collected 5-tuples into the grouped, sorted structuregenindex.htmlrenders. - metadata
env.metadata[docname]— the document’s bibliographic field list, read as build metadata.- numbers
- Section and figure numbering:
TocTreeCollector.assign_section_numbersandassign_figure_numbers(sphinx/environment/collectors/toctree.py:197-378), the two halves ofget_updated_docsthe resolve phase runs once every document’s toc is in the environment. - objects
- The domains’
get_objects()(domains/__init__.py:285): every object a domain exposes to the object inventory (objects.inv) and the search index (searchindex.js), as the(name, dispname, type, docname, anchor, priority)rows Sphinx yields — plus the two per-type lookups both consumers share, the search priority (ObjType.attrs['searchprio']) and the localized type name (Domain.get_type_name). - py_
domain - The
pydomain: object and module registration with Sphinx’s duplicate semantics —PythonDomain.note_object/note_module/clear_doc/merge_domaindata(sphinx/domains/python/__init__.py:780-832and:744-757) — and the resolution half:find_obj/resolve_xref(:855-994) plus thebuiltin_resolvermissing-reference listener (:1077-1098). - resolve
- Cross-reference resolution: the
stdhalf of Sphinx’sReferencesResolverpost-transform (transforms/post_transforms/__init__.py:60-160) plusStandardDomain.resolve_xref(domains/std/__init__.py:1034-1293) and the dangling-reference warnings both of them can raise [ENV §4, §8 #4-#13]. - std_
domain - The
stddomain: cross-reference labels, glossary terms, program options and generic objects — Sphinx’sStandardDomain(domains/std/__init__.py). - toctree
- Sphinx’s toctree bookkeeping: the read-phase half of
sphinx/environment/collectors/toctree.pyplus the two pieces ofsphinx/directives/other.pyandsphinx/environment/adapters/toctree.pythat feed it.
Structs§
- Build
Environment - Persistent build-state record: the subset of Sphinx’s
BuildEnvironmentattributes this wave’s read-and-resolve phase populates. See the module doc comment for the persistence protocol. - File
Times - What
BuildEnvironment::get_outdated_filesneeds to know about the filesystem, as the three questions it actually asks — so the computation itself stays pure and the caller decides what “the source ofdocname” and “the doctree ofdocname” mean. - Index
Entry Record - One entry harvested from a document’s
indexnodes, as recorded in Sphinx’senv.domaindata['index']['entries'][docname].mainmirrors Sphinx’s literal'main'/''marker string as a bool;BuildEnvironment::snapshotconverts it back to that string form to match the oracle fixture shape. - Outdated
- The three sets
env.get_outdated_filessplits the project into (environment/__init__.py:521-554).
Constants§
- ENV_
VERSION - Bumped whenever the on-disk shape of
BuildEnvironmentchanges.BuildEnvironment::loaddiscards (returnsNonefor) any file whose storedversiondoesn’t match current — mirroring Sphinx’s ownENV_VERSIONcheck, where a stale environment is simply rebuilt from scratch rather than partially trusted.