'Autosummary with toctree not creating documentation for methods

I'm using sphinx with the numpydoc extension and autosummary. After some experimentation, I added the following options to my conf.py file.

autosummary_generate = True
numpydoc_show_class_members = False

This is giving me a new file for each class referenced like below, and it also creates a summary table of all of the attributes and methods.

.. autosummary::
   :toctree: generated/
   :nosignatures:

   MyClass

The problem is that while there is a summary table of the methods with the first line of the doc string, the names of the methods don't link to anything. How do I get the doc strings of the methods to also create files of their own (or at least generate the documentation in the same file as the class)?



Solution 1:[1]

First, make sure that in your conf.py file, the strings 'sphinx.ext.autodoc' and 'sphinx.ext.autosummary' are in the extensions list.

Second, you can either manually make the file with name mymodule.MyClass.rst inside the generate/ directory, which can be something like this:

mymodule.MyClass
================

.. currentmodule:: mymodule

.. autoclass:: MyClass

or, if you have a lot of classes, you can automate it using sphinx-autogen. You can run it from terminal (with cd same as the conf.py file) as :

sphinx-autogen *.rst

Solution 2:[2]

It appears that a template is needed to have sphinx generate rst files for the methods. Under _templates/autosummary I added a file named class.rst which looks like this and everything works.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Gerges
Solution 2 AnhHao Tr?n