-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Milestone
Description
Subject: it is currently impossible to determine canonical class name from the template
Problem
- When classes to be included in the summary are referenced by non-canonical paths,
:show-inheritance:parameter forautoclassblock produces code referencing the canonical name of the class, but{{ objname }}value is the non-canonical one. - As a result, the link to parent class in
Bases:is broken and is not clickable. - If there would be an option to determine canonical name (
myclass.__module__ + '.' + myclass.__name__) then I could include that as a TOC entry or something like that.
Procedure to reproduce the problem
I'll illustrate it with the following minimum example:
# mypkg/__init__.py
from .parent import Parent
from .child import Child
# mypkg/parent.py
class Parent:
pass
# mypkg/child.py
from .parent import Parent
class Child(Parent):
pass
# docs/_templates/autosummary/class.rst
{{ fullname | escape | underline }}
.. autoclass:: {{objname}}
:show-inheritance:
:members:
# docs/index.rst
.. autosummary::
:toctree: _autosummary
mypkg.Parent
mypkg.Child
Error logs / results
- Build the docs and observe that class referenced as
mypkg.Childis displayed as so, but its base class is listed asmypkg.parent.Parentand it not clickable.
Expected results
It should be possible to determine canonical class name, or class' actual module name.
For now, template variable module is derieved from the textual name given as the input. It is not currently possible to access myobject.__module__.
Environment info
- OS: Arch Linux
- Python version: 3.6, 3.7
- Sphinx version: Sphinx==1.8.0
MuellerSeb, eric-wieser, embray, felix-hilden, raccoonmonk and 1 more