Skip to content

Commit 2902c6c

Browse files
authored
Deprecate legacy intersphinx_mapping format (#11247)
This format was made obsolete in Sphinx 1.0, but never formally deprecated.
1 parent 7a4ce71 commit 2902c6c

File tree

3 files changed

+35
-12
lines changed

3 files changed

+35
-12
lines changed

doc/usage/extensions/intersphinx.rst

+23-11
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,7 @@ linking:
6363
When fetching remote inventory files, proxy settings will be read from
6464
the ``$HTTP_PROXY`` environment variable.
6565

66-
**Old format for this config value**
67-
68-
This is the format used before Sphinx 1.0. It is still recognized.
69-
70-
A dictionary mapping URIs to either ``None`` or an URI. The keys are the
71-
base URI of the foreign Sphinx documentation sets and can be local paths or
72-
HTTP URIs. The values indicate where the inventory file can be found: they
73-
can be ``None`` (at the same location as the base URI) or another local or
74-
HTTP URI.
75-
76-
**New format for this config value**
66+
**Format**
7767

7868
.. versionadded:: 1.0
7969

@@ -136,6 +126,28 @@ linking:
136126
('../../otherbook/build/html/objects.inv', None)),
137127
}
138128

129+
**Old format for this config value**
130+
131+
.. deprecated:: 6.2
132+
133+
.. RemovedInSphinx80Warning
134+
135+
.. caution:: This is the format used before Sphinx 1.0.
136+
It is deprecated and will be removed in Sphinx 8.0.
137+
138+
A dictionary mapping URIs to either ``None`` or an URI. The keys are the
139+
base URI of the foreign Sphinx documentation sets and can be local paths or
140+
HTTP URIs. The values indicate where the inventory file can be found: they
141+
can be ``None`` (at the same location as the base URI) or another local or
142+
HTTP URI.
143+
144+
Example:
145+
146+
.. code:: python
147+
148+
intersphinx_mapping = {'https://docs.python.org/': None}
149+
150+
139151
.. confval:: intersphinx_cache_limit
140152

141153
The maximum number of days to cache remote inventories. The default is

sphinx/ext/intersphinx.py

+8
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,15 @@ def normalize_intersphinx_mapping(app: Sphinx, config: Config) -> None:
617617
continue
618618
else:
619619
# old format, no name
620+
# xref RemovedInSphinx80Warning
620621
name, uri, inv = None, key, value
622+
logger.warning(
623+
"The pre-Sphinx 1.0 'intersphinx_mapping' format is "
624+
"deprecated and will be removed in Sphinx 8. Update to the "
625+
"current format as described in the documentation. "
626+
f"Hint: \"intersphinx_mapping = {{'<name>': {(uri, inv)!r}}}\"."
627+
"https://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html#confval-intersphinx_mapping", # NoQA: E501
628+
)
621629

622630
if not isinstance(inv, tuple):
623631
config.intersphinx_mapping[key] = (name, (uri, (inv,)))

tests/test_ext_intersphinx.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,10 @@ def test_load_mappings_warnings(tempdir, app, status, warning):
390390
# load the inventory and check if it's done correctly
391391
normalize_intersphinx_mapping(app, app.config)
392392
load_mappings(app)
393-
assert warning.getvalue().count('\n') == 1
393+
warnings = warning.getvalue().splitlines()
394+
assert len(warnings) == 2
395+
assert "The pre-Sphinx 1.0 'intersphinx_mapping' format is " in warnings[0]
396+
assert 'intersphinx identifier 12345 is not string. Ignored' in warnings[1]
394397

395398

396399
def test_load_mappings_fallback(tempdir, app, status, warning):

0 commit comments

Comments
 (0)