amorphic
amorphic

Reputation: 750

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...

?

Upvotes: 9

Views: 2652

Answers (2)

PhilippReist
PhilippReist

Reputation: 76

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.

Upvotes: 6

yuanzhen dai
yuanzhen dai

Reputation: 61

Add this line in your conf.py file

add_module_names = False

Upvotes: 6

Related Questions