-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Docstring implicit inheritance can render cross-reference targets ambiguous. #6211
Comments
I looked a bit into how to resolve this (and other similar issues, e.g. Derived classes in other modules losing the ability to refer to things defined in the module of the parent class). Unfortunately, it looks like by the time the references are getting resolved (in
It may help if :py:class: gained the ability to record base classes, e.g.
(one can't use |
Describe the bug
When a subclass is added, implicit docstring inheritance by its methods can create ambiguous cross-reference targets in the docstrings of the methods of the parent class.
To Reproduce
Start with a minimal project:
Edit
index.rst
to includeand write the following
themodule.py
:Build the docs with
themodule.py
in the PYTHONPATH (PYTHONPATH=. make html
) -- things work fine; in particular the doc ofA.dothis
correctly links toA.dothat
.Now let's say someone adds (in the same module) a subclass of
A
that overridesdothis
, but doesn't bother with a docstring:Trying to build the docs now results in a warning:
i.e.
B.dothis
inheritedA.dothis
's docstring, but doesn't know what ":obj:`.dothat`" is supposed to refer to. I believe it should actually resolve it to meanB.dothat
(which happens to be equal toA.dothat
). (emphasis as this is the actual issue at hand) Indeed, if B also definesdothat
:then the docstring of
B.dothis
does link toB.dothat
.Expected behavior
In
B.dothis
's docstring, ":obj:`.dothat`" should link toA.dothat
(ifB.dothat
does not exist).Your project
n/a
Screenshots
n/a
Environment info
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: