I am writing a Sphinx documentation for a Python project with a single top-level package my_package. To reference modules/classes in this package, I currently use
:mod:`my_package.my_module`
:class:`my_package.MyClass`
:class:`my_package.my_module.MyOtherClass`
These references are then generated as
my_package.my_module
my_package.MyClass
my_package.my_module.MyOtherClass
My question is: Is there a way of configuring Sphinx so that I can use shorter references, like
:mod:`my_module`
:class:`MyClass`
:class:`my_module.MyOtherClass`
which generate the references as
my_module
MyClass
my_module.MyOtherClass
In other words, can I make the top-level my_package implicit?
Include
.. currentmodule:: my_package
at the top of your rst files, then you can leave this out in references.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With