mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
rename intersphinx_disabled_{refs -> reftypes}
And change format for domains to {name}:*
This commit is contained in:
4
CHANGES
4
CHANGES
@@ -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
|
||||
----------
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user