Skip to content

Class attribute in subclass inherits attribute docstring in Sphinx 5.0.1 #10538

@oscarbenjamin

Description

@oscarbenjamin

Describe the bug

As of Sphinx 5.0.1 the SymPy docs build gives lots of warnings like this:

docstring of sympy.polys.domains.field.Field.is_Field:14: WARNING: more than one target found for cross-reference 'is_Ring': sympy.polys.domains.domain.Domain.is_Ring, sympy.polys.domains.ring.Ring.is_Ring

Full output in CI can be seen here:
https://github.com/sympy/sympy/runs/6784391829?check_suite_focus=true

The problem seems to be that there is a class Domain which has a documented attribute is_Ring:
https://github.com/sympy/sympy/blob/a96dce8b55675a0529d9bed479e2569126e27149/sympy/polys/domains/domain.py#L245-L262
You can see that in the docs here:
https://docs.sympy.org/dev/modules/polys/domainsref.html#sympy.polys.domains.domain.Domain.is_Ring

Then there is a class Ring which is a subclass of Domain and changes the value of the class attribute but does not document it:
https://github.com/sympy/sympy/blob/a96dce8b55675a0529d9bed479e2569126e27149/sympy/polys/domains/ring.py#L13

In previous versions of Sphinx the Ring class would not show the is_Ring attribute:
https://docs.sympy.org/dev/modules/polys/domainsref.html#sympy.polys.domains.ring.Ring

Now with Sphinx 5.0.1 though it seems that the Sphinx build decides to document the Ring.is_Ring attribute with the docstring inherited from the superclass Domain. Then the see also references to is_Ring fail due to multiple targets.

How to Reproduce

$ git clone https://github.com/sympy/sympy.git
$ cd sympy/doc
$ pip install -r requirements.txt
$ make html
$ # open _build/html/modules/polys/domainsref.html

Expected behavior

The attribute is_Ring in the subclass Ring would not be documented and there would be only one target for is_Ring pointing to the Domain.is_Ring attribute.

Your project

https://github.com/sympy/sympy

Screenshots

No response

OS

Any

Python version

3.8-3.10

Sphinx version

5.0.1

Sphinx extensions

Sphinx 5.0.1 sphinx-autobuild 2021.3.14 sphinx-basic-ng 0.0.1a11 sphinx-copybutton 0.5.0 sphinx-math-dollar 1.2.1 sphinx-press-theme 0.8.0 sphinx-reredirects 0.0.1 sphinxcontrib-applehelp 1.0.2 sphinxcontrib-devhelp 1.0.2 sphinxcontrib-htmlhelp 2.0.0 sphinxcontrib-jsmath 1.0.1 sphinxcontrib-qthelp 1.0.3 sphinxcontrib-serializinghtml 1.1.5

Extra tools

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions