Skip to content

Commit 56002be

Browse files
committed
rename intersphinx_disabled_{refs -> reftypes}
And change format for domains to {name}:*
1 parent 484d74a commit 56002be

File tree

4 files changed

+19
-18
lines changed

4 files changed

+19
-18
lines changed

CHANGES

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ Features added
4747
* #9695: More CSS classes on Javascript domain descriptions
4848
* #9683: Revert the removal of ``add_stylesheet()`` API. It will be kept until
4949
the Sphinx-6.0 release
50-
* #2068, add :confval:`intersphinx_disabled_refs` for disabling
50+
* #2068, add :confval:`intersphinx_disabled_reftypes` for disabling
5151
interphinx resolution of cross-references that do not have an explicit
5252
inventory specification. Specific types of cross-references can be disabled,
5353
e.g., ``std:doc`` or all cross-references in a specific domain,
54-
e.g., ``std``.
54+
e.g., ``std:*``.
5555

5656
Bugs fixed
5757
----------

doc/usage/extensions/intersphinx.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,24 +148,25 @@ linking:
148148
exception is raised if the server has not issued a response for timeout
149149
seconds.
150150

151-
.. confval:: intersphinx_disabled_refs
151+
.. confval:: intersphinx_disabled_reftypes
152152

153153
.. versionadded:: 4.3
154154

155155
A list of strings being either:
156156

157-
- the name of a specific reference type,
157+
- the name of a specific reference type in a domain,
158158
e.g., ``std:doc``, ``py:func``, or ``cpp:class``,
159-
- the name of a whole domain, e.g., ``std``, ``py``, or ``cpp``, or
160-
- the special name ``*``.
159+
- the name of a domain, and a wildcard, e.g.,
160+
``std:*``, ``py:*``, or ``cpp:*``, or
161+
- simply a wildcard ``*``.
161162

162163
The default value is an empty list.
163164

164165
When a cross-reference without an explicit inventory specification is being
165-
resolved by intersphinx, skip resolution it matches one of the
166+
resolved by intersphinx, skip resolution if it matches one of the
166167
specifications in this list.
167168

168-
For example, with ``intersphinx_disabled_refs = ['std:doc']``
169+
For example, with ``intersphinx_disabled_reftypes = ['std:doc']``
169170
a cross-reference ``:doc:`installation``` will not be attempted to be
170171
resolved by intersphinx, but ``:doc:`otherbook:installation``` will be
171172
attempted to be resolved in the inventory named ``otherbook`` in

sphinx/ext/intersphinx.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ def _resolve_reference_in_domain(env: BuildEnvironment,
340340

341341
# now that the objtypes list is complete we can remove the disabled ones
342342
if honor_disabled_refs:
343-
disabled = env.config.intersphinx_disabled_refs
343+
disabled = env.config.intersphinx_disabled_reftypes
344344
objtypes = [o for o in objtypes if o not in disabled]
345345

346346
# without qualification
@@ -363,14 +363,14 @@ def _resolve_reference(env: BuildEnvironment, inv_name: Optional[str], inventory
363363
# disabling should only be done if no inventory is given
364364
honor_disabled_refs = honor_disabled_refs and inv_name is None
365365

366-
if honor_disabled_refs and '*' in env.config.intersphinx_disabled_refs:
366+
if honor_disabled_refs and '*' in env.config.intersphinx_disabled_reftypes:
367367
return None
368368

369369
typ = node['reftype']
370370
if typ == 'any':
371371
for domain_name, domain in env.domains.items():
372372
if honor_disabled_refs \
373-
and domain_name in env.config.intersphinx_disabled_refs:
373+
and (domain_name + ":*") in env.config.intersphinx_disabled_reftypes:
374374
continue
375375
objtypes = list(domain.object_types)
376376
res = _resolve_reference_in_domain(env, inv_name, inventory,
@@ -386,7 +386,7 @@ def _resolve_reference(env: BuildEnvironment, inv_name: Optional[str], inventory
386386
# only objects in domains are in the inventory
387387
return None
388388
if honor_disabled_refs \
389-
and domain_name in env.config.intersphinx_disabled_refs:
389+
and (domain_name + ":*") in env.config.intersphinx_disabled_reftypes:
390390
return None
391391
domain = env.get_domain(domain_name)
392392
objtypes = domain.objtypes_for_role(typ)
@@ -494,7 +494,7 @@ def setup(app: Sphinx) -> Dict[str, Any]:
494494
app.add_config_value('intersphinx_mapping', {}, True)
495495
app.add_config_value('intersphinx_cache_limit', 5, False)
496496
app.add_config_value('intersphinx_timeout', None, False)
497-
app.add_config_value('intersphinx_disabled_refs', [], True)
497+
app.add_config_value('intersphinx_disabled_reftypes', [], True)
498498
app.connect('config-inited', normalize_intersphinx_mapping, priority=800)
499499
app.connect('builder-inited', load_mappings)
500500
app.connect('missing-reference', missing_reference)

tests/test_ext_intersphinx.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def reference_check(app, *args, **kwds):
4545
def set_config(app, mapping):
4646
app.config.intersphinx_mapping = mapping
4747
app.config.intersphinx_cache_limit = 0
48-
app.config.intersphinx_disabled_refs = []
48+
app.config.intersphinx_disabled_reftypes = []
4949

5050

5151
@mock.patch('sphinx.ext.intersphinx.InventoryFile')
@@ -338,19 +338,19 @@ def assert_(rn, expected):
338338
assert_(rn, 'func()')
339339

340340
# the base case, everything should resolve
341-
assert app.config.intersphinx_disabled_refs == []
341+
assert app.config.intersphinx_disabled_reftypes == []
342342
case(term=True, doc=True, py=True)
343343

344344
# disabled a single ref type
345-
app.config.intersphinx_disabled_refs = ['std:doc']
345+
app.config.intersphinx_disabled_reftypes = ['std:doc']
346346
case(term=True, doc=False, py=True)
347347

348348
# disabled a whole domain
349-
app.config.intersphinx_disabled_refs = ['std']
349+
app.config.intersphinx_disabled_reftypes = ['std:*']
350350
case(term=False, doc=False, py=True)
351351

352352
# disabled all domains
353-
app.config.intersphinx_disabled_refs = ['*']
353+
app.config.intersphinx_disabled_reftypes = ['*']
354354
case(term=False, doc=False, py=False)
355355

356356

0 commit comments

Comments
 (0)