I have a module mod
with some submodule submod
and use .. automodule:: mod.submod
to generate documentation for it.
The signatures of the elements (functions, classes etc.) in the modules now show the qualified name, like mod.submod.my_function(*args, **kwargs)
.
I would instead like Sphinx to just show the name of the function, ie the signature my_function(*args, **kwargs)
.
Do I have any way to drop the leading module and submodules in the signature?
Omitting module and package names preceding functions, methods and variables is done by setting the add_module_name
configuration in your conf.py
:
add_module_names = False
This is not obvious because of the numerous autodoc configurations that together with the sphinx-napoleon configurations make you expect the configuration elsewhere.
Yes, try this in docs/mod/submod.rst
:
.. automodule:: mod.submod
.. autofunction:: my_function
See example HTML build and reST source in Pyramid documentation.
Bonus: see the Sphinx docs for Cross-referencing syntax :
If you prefix the content with
~
, the link text will only be the last component of the target. For example, :py:meth:~Queue.Queue.get
will refer toQueue.Queue.get
but only displayget
as the link text.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.