Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop Sphinx automethod prefixing method name with class name

When I use Sphinx automethod to document a specific method like so:

.. automethod:: my_module.MyClass.my_method

The resulting docs append the class name to the method name like this:

MyClass.my_method(kwarg1=None, kwarg2=None)

    This is the docstring for my_method...

Is there any way to tell automethod to not prefix the method name with the class name, such that the resulting docs look like this:

my_method(kwarg1=None, kwarg2=None)

    This is the docstring for my_method...

?

like image 688
amorphic Avatar asked Sep 30 '15 06:09

amorphic


2 Answers

Add this line in your conf.py file

add_module_names = False

like image 106
yuanzhen dai Avatar answered Oct 06 '22 16:10

yuanzhen dai


In addition to

add_module_names = False

use

.. autofunction:: my_module.MyClass.my_method

instead of automodule and the class name is omitted in the generated doc.

like image 29
PhilippReist Avatar answered Oct 06 '22 15:10

PhilippReist