17

I try to create a html documentation for a project containing several thousand classes using sphinx and it's autodoc plugin. sphinx-apidoc creates wonderful rst-files, but lacks of an automatic creation of autoclasses and automethods.

Is there a way/command/utility in sphinx to auto-include all variables, functions, classes and decorators in the documentation?

Some sample code of one rst-file:

tagger Package
=================

:mod:`tagger` Package
------------------------
.. automodule:: project.tagger
    :members:


:mod:`client` Module
--------------------
.. automodule:: project.analyzers.tagger.client
    :members:
Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Jon
  • 11,356
  • 5
  • 40
  • 74
  • Have you already checked the [`autodoc` extension](http://sphinx-doc.org/ext/autodoc.html#module-sphinx.ext.autodoc)? – Rik Poggi Jan 02 '13 at 10:23
  • the autodoc extension is added in the conf.py: extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode'] Sphinx detects all modules but it doesn't list the classes and it methods. – Jon Jan 02 '13 at 10:28
  • 1
    According to above autodoc extension 'Members without docstrings will be left out, unless you give the undoc-members flag option' – intotecho Aug 30 '15 at 01:39

1 Answers1

5

There is a Sphinx extension which will help you in this called autodoc.

If you want to include the class then you have to write:

.. autoclass:: <ClassName>

Similarly for a method:

.. automethod:: <MethodName>
Moot
  • 2,195
  • 2
  • 17
  • 14
Nilesh
  • 20,521
  • 16
  • 92
  • 148
  • 11
    I use autodoc. This means that I would have to add ..autoclass more than thousand times or create a script. Isn't there an autodetection? – Jon Jan 02 '13 at 10:35
  • 3
    You can use `automodule` If you want to automatically document members, there’s a members option. Please check the link. There are many option in the autodoc extension. – Nilesh Jan 02 '13 at 10:40
  • 1
    for me adding :members: and :undoc-members: did the trick – mluerig Mar 11 '20 at 09:49