Expand description
sphinx.ext.intersphinx — cross-project references resolved through
other projects’ objects.inv inventories.
Ported from Sphinx 9.1.0’s sphinx/ext/intersphinx/ (_load.py,
_resolve.py, _shared.py); every message text, ordering rule and
fallback below is cited to the file:line it mirrors, collected in
docs/superpowers/plans/2026-08-31-m2-wave4-research-spec-inventory-intersphinx.md
§3-§4.
The three phases, in the order a build runs them:
- Validation (
validate_mapping) normalisesintersphinx_mappingat configuration load. Any failure is aConfigErrorin Sphinx, which aborts the build — here it aborts config loading, which the CLI turns into exit code 2. - Loading (
load_mappings) reads each project’s inventory: local files always, remote ones through anInventoryFetcherwith an on-disk cache. The merged “main” inventory plus the per-name ones are theIntersphinxData. - Resolution (
Intersphinx::resolve_detectand friends) runs from the reference resolver, standing exactly where Sphinx’smissing-referenceevent does: after the local domain has failed and before the dangling-reference warning.
Re-exports§
pub use fetch::HttpConfig;pub use fetch::InventoryFetcher;pub use fetch::TlsCacerts;pub use fetch::UreqFetcher;pub use fetch::DEFAULT_USER_AGENT;
Modules§
- fetch
- The one place intersphinx touches the network, behind a trait so every test can stay offline.
Structs§
- Diagnostic
- A diagnostic resolution wants logged, with the
type.subtypecategory Sphinx gives it. - Intersphinx
- The loaded inventories plus the two configuration values resolution consults.
- Intersphinx
Data - The loaded inventories: the merged “main” one every un-named lookup goes
through, and the per-project ones an
inv:targetor:external+inv:reference names (_shared.py:114-149,InventoryAdapter). - Load
Outcome - What loading produced, plus the diagnostics it wants reported.
- Load
Request - Everything
load_mappingsneeds from the build. - Resolution
- A reference into another project.
- Xref
Query - The
pending_xrefattributes resolution reads.
Enums§
- External
Role - What the parse layer should build for an
:external:...:role. - Hook
Outcome - What the missing-reference hook decided.
Constants§
- CACHE_
DIR_ NAME - The on-disk cache directory, relative to the doctree/cache directory
(
app.doctreedir / '__intersphinx_cache__',_load.py:186-190). Sphinx documents that “the location of this cache directory must not be relied upon externally”; ours rides the fingerprint-wiped cache dir, so a configuration change clears it along with everything else.
Functions§
- domain_
and_ role _get_domain_role(_resolve.py:508-521): no colon is a bare role name, one colon splits domain from role, two or more is unusable.- external_
inventory_ missing - The inventory-existence check
IntersphinxRole.runmakes first (_resolve.py:385-390), deferred to resolution time because that is where this port knows what got loaded. - external_
not_ found - The failure
IntersphinxRoleResolverreports for a stamped node nothing matched (_resolve.py:557-565), logged withtype='ref'andsubtype=reftype. - external_
role - The role-name half of
IntersphinxRole.run(_resolve.py:378-463), minus the inventory-existence check — that one needs the loaded inventories, and is applied at resolution time byexternal_inventory_missingso its warning still wins the race Sphinx gives it (it is checked first). - inventory_
and_ name_ suffix get_inventory_and_name_suffix(_resolve.py:486-506): splitexternal[+inv]:suffixinto its inventory name anddomain:namesuffix.- is_
external_ role - Whether a role name is one
IntersphinxDispatcherclaims (_resolve.py:358-366). The name is the one the author wrote: the inventory name inside it is case-sensitive. - load_
mappings - Read every configured inventory (
load_mappings,_load.py:139-208). - mapping_
config_ error - The
ConfigErrorSphinx raises once validation has logged its errors (_load.py:131-136). - redirect_
target_ uri - The redirect rule (
_load.py:410-419), kept pure: after a fetch that ended somewhere other than where it started, the target URI is rewritten only when it was pointing at the inventory’s own directory. - safe_
url _get_safe_url(_load.py:439-461): the password is dropped from auser:password@hostURL before it reaches a log line.- strip_
basic_ auth _strip_basic_auth(_load.py:464-482):user[:pass]@hostnamein the netloc becomeshostname.- validate_
mapping - Validate and normalise a raw
intersphinx_mappingvalue as parsed fromconf.py, returning the entries that survived and the error messages for the ones that did not.
Type Aliases§
- Intersphinx
Mapping - The normalised
intersphinx_mapping: project name -> (target URI, inventory locations). Sphinx stores{name: (name, (uri, locations))}with the name duplicated inside the value (_load.py:129); the key is the same string, so this drops the duplicate.