Skip to main content

validate_mapping

Function validate_mapping 

Source
pub fn validate_mapping(raw: &Value) -> (IntersphinxMapping, Vec<String>)
Expand description

Validate and normalise a raw intersphinx_mapping value as parsed from conf.py, returning the entries that survived and the error messages for the ones that did not.

The messages are Sphinx’s own, verbatim (_load.py:59-125, checks 1-6 in the research spec §3). Sphinx logs each with LOGGER.error and then raises ConfigError if any fired; mapping_config_error is that final message.

Two knowing divergences, both forced by going through JSON rather than live Python objects:

  • Entries are visited in key order, not conf.py order, because the parsed dict is a sorted map. This only shows in check 5, which names the other entry that claimed a duplicate target URI.
  • %r of a sequence renders with list brackets, since a conf.py tuple and list both arrive as a JSON array. Checks 2, 3 and 6 can therefore print ['a', 'b', 'c'] where Sphinx prints ('a', 'b', 'c').

Check 1 is also narrower here than in Sphinx: a non-string key cannot reach this function, because the conf.py literal parser rejects the whole dict (with its own dropped-value warning) before it gets here. The empty string is the only identifier this check can still fire on.