Imagine I want to import functions or classes directly from the top-level 
package, i. e. my_package.PublicClass. To keep an internal structure, I 
don't want to dump everything into __init__.py but rather split the 
functionality in a _private_module.py and simply import it. From the python 
perspective this works as intended, but I face problem with the 
documentation. TL;DR Is there a way to alias the autogenerated link from 
my_package._private_module.PublicClass 
to my_package.PublicClass?

---

I've created a sample repository 
<https://github.com/pmeier/sphinx_alias_reference> for my problem. Still, 
for completeness, I include the important parts here.

Consider the following python package:

my_package/
├── __init__.py
└── _private_module.py


with the following content:

__init__.py

from ._private_module import *

and 

_private_module.py

__all__ = ["PublicClass", "PublicSubclass"]


class PublicClass:
    pass


class PublicSubclass(PublicClass):
    """:class:`my_package.PublicClass`"""
    pass

The documentation is built with the following 

index.rst


.. automodule:: my_package

.. autoclass:: PublicClass
.. autoclass:: PublicSubclass
 :show-inheritance:


As you can see in the built documentation 
<https://sphinx-alias-reference.readthedocs.io/en/latest/> the reference in 
the doc string works fine. The inheritance on the other hand references 
my_package._private_module.PublicClass 
which is not only misleading, but also breaks the link to 
my_package.PublicClass. Thus, I repeat the question from above: Is there a 
way to replace the autogenerated link from 
my_package._private_module.PublicClass 
with links my_package.PublicClass?



-- 
You received this message because you are subscribed to the Google Groups 
"sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sphinx-users/3a84cdc0-3842-4ad3-ba8f-1d7da399dfd7%40googlegroups.com.

Reply via email to