Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate legacy intersphinx_mapping format #11247

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 23 additions & 11 deletions doc/usage/extensions/intersphinx.rst
Expand Up @@ -63,17 +63,7 @@ linking:
When fetching remote inventory files, proxy settings will be read from
the ``$HTTP_PROXY`` environment variable.

**Old format for this config value**

This is the format used before Sphinx 1.0. It is still recognized.

A dictionary mapping URIs to either ``None`` or an URI. The keys are the
base URI of the foreign Sphinx documentation sets and can be local paths or
HTTP URIs. The values indicate where the inventory file can be found: they
can be ``None`` (at the same location as the base URI) or another local or
HTTP URI.

**New format for this config value**
**Format**

.. versionadded:: 1.0

Expand Down Expand Up @@ -136,6 +126,28 @@ linking:
('../../otherbook/build/html/objects.inv', None)),
}

**Old format for this config value**

.. deprecated:: 6.2

.. RemovedInSphinx80Warning

.. caution:: This is the format used before Sphinx 1.0.
It is deprecated and will be removed in Sphinx 8.0.

A dictionary mapping URIs to either ``None`` or an URI. The keys are the
base URI of the foreign Sphinx documentation sets and can be local paths or
HTTP URIs. The values indicate where the inventory file can be found: they
can be ``None`` (at the same location as the base URI) or another local or
HTTP URI.

Example:

.. code:: python

intersphinx_mapping = {'https://docs.python.org/': None}


.. confval:: intersphinx_cache_limit

The maximum number of days to cache remote inventories. The default is
Expand Down
8 changes: 8 additions & 0 deletions sphinx/ext/intersphinx.py
Expand Up @@ -617,7 +617,15 @@ def normalize_intersphinx_mapping(app: Sphinx, config: Config) -> None:
continue
else:
# old format, no name
# xref RemovedInSphinx80Warning
name, uri, inv = None, key, value
logger.warning(
"The pre-Sphinx 1.0 'intersphinx_mapping' format is "
"deprecated and will be removed in Sphinx 8. Update to the "
"current format as described in the documentation. "
f"Hint: \"intersphinx_mapping = {{'<name>': {(uri, inv)!r}}}\"."
"https://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html#confval-intersphinx_mapping", # NoQA: E501
)

if not isinstance(inv, tuple):
config.intersphinx_mapping[key] = (name, (uri, (inv,)))
Expand Down
5 changes: 4 additions & 1 deletion tests/test_ext_intersphinx.py
Expand Up @@ -390,7 +390,10 @@ def test_load_mappings_warnings(tempdir, app, status, warning):
# load the inventory and check if it's done correctly
normalize_intersphinx_mapping(app, app.config)
load_mappings(app)
assert warning.getvalue().count('\n') == 1
warnings = warning.getvalue().splitlines()
assert len(warnings) == 2
assert "The pre-Sphinx 1.0 'intersphinx_mapping' format is " in warnings[0]
assert 'intersphinx identifier 12345 is not string. Ignored' in warnings[1]


def test_load_mappings_fallback(tempdir, app, status, warning):
Expand Down