diff options
| author | Jakob Lykke Andersen <Jakob@caput.dk> | 2021-10-31 13:56:26 +0100 |
|---|---|---|
| committer | Jakob Lykke Andersen <Jakob@caput.dk> | 2021-10-31 13:56:26 +0100 |
| commit | 56002be5e1e5ea712e4e34dc8f4a3b2f446a4be6 (patch) | |
| tree | a833bf953db1910035028615b622a741cc3cb782 | |
| parent | 484d74ad9773ee61c438c8f176ca16785f3a0614 (diff) | |
| download | sphinx-git-56002be5e1e5ea712e4e34dc8f4a3b2f446a4be6.tar.gz | |
rename intersphinx_disabled_{refs -> reftypes}
And change format for domains to {name}:*
| -rw-r--r-- | CHANGES | 4 | ||||
| -rw-r--r-- | doc/usage/extensions/intersphinx.rst | 13 | ||||
| -rw-r--r-- | sphinx/ext/intersphinx.py | 10 | ||||
| -rw-r--r-- | tests/test_ext_intersphinx.py | 10 |
4 files changed, 19 insertions, 18 deletions
@@ -47,11 +47,11 @@ Features added * #9695: More CSS classes on Javascript domain descriptions * #9683: Revert the removal of ``add_stylesheet()`` API. It will be kept until the Sphinx-6.0 release -* #2068, add :confval:`intersphinx_disabled_refs` for disabling +* #2068, add :confval:`intersphinx_disabled_reftypes` for disabling interphinx resolution of cross-references that do not have an explicit inventory specification. Specific types of cross-references can be disabled, e.g., ``std:doc`` or all cross-references in a specific domain, - e.g., ``std``. + e.g., ``std:*``. Bugs fixed ---------- diff --git a/doc/usage/extensions/intersphinx.rst b/doc/usage/extensions/intersphinx.rst index 745127971..a3e65bed6 100644 --- a/doc/usage/extensions/intersphinx.rst +++ b/doc/usage/extensions/intersphinx.rst @@ -148,24 +148,25 @@ linking: exception is raised if the server has not issued a response for timeout seconds. -.. confval:: intersphinx_disabled_refs +.. confval:: intersphinx_disabled_reftypes .. versionadded:: 4.3 A list of strings being either: - - the name of a specific reference type, + - the name of a specific reference type in a domain, e.g., ``std:doc``, ``py:func``, or ``cpp:class``, - - the name of a whole domain, e.g., ``std``, ``py``, or ``cpp``, or - - the special name ``*``. + - the name of a domain, and a wildcard, e.g., + ``std:*``, ``py:*``, or ``cpp:*``, or + - simply a wildcard ``*``. The default value is an empty list. When a cross-reference without an explicit inventory specification is being - resolved by intersphinx, skip resolution it matches one of the + resolved by intersphinx, skip resolution if it matches one of the specifications in this list. - For example, with ``intersphinx_disabled_refs = ['std:doc']`` + For example, with ``intersphinx_disabled_reftypes = ['std:doc']`` a cross-reference ``:doc:`installation``` will not be attempted to be resolved by intersphinx, but ``:doc:`otherbook:installation``` will be attempted to be resolved in the inventory named ``otherbook`` in diff --git a/sphinx/ext/intersphinx.py b/sphinx/ext/intersphinx.py index 331acc641..d5f92d6fb 100644 --- a/sphinx/ext/intersphinx.py +++ b/sphinx/ext/intersphinx.py @@ -340,7 +340,7 @@ def _resolve_reference_in_domain(env: BuildEnvironment, # now that the objtypes list is complete we can remove the disabled ones if honor_disabled_refs: - disabled = env.config.intersphinx_disabled_refs + disabled = env.config.intersphinx_disabled_reftypes objtypes = [o for o in objtypes if o not in disabled] # without qualification @@ -363,14 +363,14 @@ def _resolve_reference(env: BuildEnvironment, inv_name: Optional[str], inventory # disabling should only be done if no inventory is given honor_disabled_refs = honor_disabled_refs and inv_name is None - if honor_disabled_refs and '*' in env.config.intersphinx_disabled_refs: + if honor_disabled_refs and '*' in env.config.intersphinx_disabled_reftypes: return None typ = node['reftype'] if typ == 'any': for domain_name, domain in env.domains.items(): if honor_disabled_refs \ - and domain_name in env.config.intersphinx_disabled_refs: + and (domain_name + ":*") in env.config.intersphinx_disabled_reftypes: continue objtypes = list(domain.object_types) res = _resolve_reference_in_domain(env, inv_name, inventory, @@ -386,7 +386,7 @@ def _resolve_reference(env: BuildEnvironment, inv_name: Optional[str], inventory # only objects in domains are in the inventory return None if honor_disabled_refs \ - and domain_name in env.config.intersphinx_disabled_refs: + and (domain_name + ":*") in env.config.intersphinx_disabled_reftypes: return None domain = env.get_domain(domain_name) objtypes = domain.objtypes_for_role(typ) @@ -494,7 +494,7 @@ def setup(app: Sphinx) -> Dict[str, Any]: app.add_config_value('intersphinx_mapping', {}, True) app.add_config_value('intersphinx_cache_limit', 5, False) app.add_config_value('intersphinx_timeout', None, False) - app.add_config_value('intersphinx_disabled_refs', [], True) + app.add_config_value('intersphinx_disabled_reftypes', [], True) app.connect('config-inited', normalize_intersphinx_mapping, priority=800) app.connect('builder-inited', load_mappings) app.connect('missing-reference', missing_reference) diff --git a/tests/test_ext_intersphinx.py b/tests/test_ext_intersphinx.py index 4d5c08ed6..e820730a1 100644 --- a/tests/test_ext_intersphinx.py +++ b/tests/test_ext_intersphinx.py @@ -45,7 +45,7 @@ def reference_check(app, *args, **kwds): def set_config(app, mapping): app.config.intersphinx_mapping = mapping app.config.intersphinx_cache_limit = 0 - app.config.intersphinx_disabled_refs = [] + app.config.intersphinx_disabled_reftypes = [] @mock.patch('sphinx.ext.intersphinx.InventoryFile') @@ -338,19 +338,19 @@ def test_missing_reference_disabled_domain(tempdir, app, status, warning): assert_(rn, 'func()') # the base case, everything should resolve - assert app.config.intersphinx_disabled_refs == [] + assert app.config.intersphinx_disabled_reftypes == [] case(term=True, doc=True, py=True) # disabled a single ref type - app.config.intersphinx_disabled_refs = ['std:doc'] + app.config.intersphinx_disabled_reftypes = ['std:doc'] case(term=True, doc=False, py=True) # disabled a whole domain - app.config.intersphinx_disabled_refs = ['std'] + app.config.intersphinx_disabled_reftypes = ['std:*'] case(term=False, doc=False, py=True) # disabled all domains - app.config.intersphinx_disabled_refs = ['*'] + app.config.intersphinx_disabled_reftypes = ['*'] case(term=False, doc=False, py=False) |
