Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

py domain: Ignore aliases for resolving :any: cross-references #10089

Merged
merged 4 commits into from Jun 26, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES
Expand Up @@ -32,6 +32,9 @@ Bugs fixed
* #10520: HTML Theme: Fix use of sidebar classes in ``agogo.css_t``.
* #6679: HTML Theme: Fix inclusion of hidden toctrees in the agogo theme.
* #10566: HTML Theme: Fix enable_search_shortcuts does not work
* #9577, #10088: py domain: Fix warning for duplicate Python references when
using :any:
and autodoc
AA-Turner marked this conversation as resolved.
Show resolved Hide resolved

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