mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #4662: any refs with term targets crash when an ambiguity is encountered
This commit is contained in:
parent
6701676ddb
commit
c41e746b7a
2
CHANGES
2
CHANGES
@ -42,6 +42,8 @@ Bugs fixed
|
||||
* #4655: Fix incomplete localization strings in Polish
|
||||
* #4653: Fix error reporting for parameterless ImportErrors
|
||||
* #4664: Reading objects.inv fails again
|
||||
* #4662: ``any`` refs with ``term`` targets crash when an ambiguity is
|
||||
encountered
|
||||
|
||||
Testing
|
||||
--------
|
||||
|
@ -135,10 +135,12 @@ class ReferencesResolver(SphinxTransform):
|
||||
if not results:
|
||||
return None
|
||||
if len(results) > 1:
|
||||
nice_results = ' or '.join(':%s:`%s`' % (name, role["reftitle"])
|
||||
for name, role in results)
|
||||
def stringify(name, node):
|
||||
reftitle = node.get('reftitle', node.astext())
|
||||
return ':%s:`%s`' % (name, reftitle)
|
||||
candidates = ' or '.join(stringify(name, role) for name, role in results)
|
||||
logger.warning(__('more than one target found for \'any\' cross-'
|
||||
'reference %r: could be %s'), target, nice_results,
|
||||
'reference %r: could be %s'), target, candidates,
|
||||
location=node)
|
||||
res_role, newnode = results[0]
|
||||
# Override "any" class with the actual role type to get the styling
|
||||
|
Loading…
Reference in New Issue
Block a user