Skip to content

Commit

Permalink
:any: xref searches ignore aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
Joachim Jablon authored and ewjoachim committed May 29, 2022
1 parent f7a8844 commit 8459887
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Expand Up @@ -50,6 +50,8 @@ Bugs fixed
* #9096: sphinx-build: the value of progress bar for paralle build is wrong
* #10110: sphinx-build: exit code is not changed when error is raised on
builder-finished event
* #9577, #10088: Fix warning for duplicate Python references when using :any:
and autodoc

Testing
--------
Expand Down
7 changes: 7 additions & 0 deletions sphinx/domains/python.py
Expand Up @@ -1365,7 +1365,14 @@ def resolve_any_xref(self, env: BuildEnvironment, fromdocname: str, builder: Bui

# always search in "refspecific" mode with the :any: role
matches = self.find_obj(env, modname, clsname, target, None, 1)
multiple_matches = len(matches) > 1

for name, obj in matches:

if multiple_matches and obj.aliased:
# Skip duplicated matches
continue

if obj[2] == 'module':
results.append(('py:mod',
self._make_module_refnode(builder, fromdocname,
Expand Down
3 changes: 3 additions & 0 deletions tests/roots/test-domain-py/canonical.rst
Expand Up @@ -2,6 +2,9 @@ caninical
=========

:py:class:`.Foo`
:any:`Foo`
:any:`module.Foo`
:any:`original.module.Foo`

.. py:module:: canonical
Expand Down

0 comments on commit 8459887

Please sign in to comment.