Reputation: 351
I started working on a python module and wanted to document the code "in place". So i set up sphinx in a subdirectory with sphinx-quickstart resulting in this directory structure (only the files i edited are shown):
My index.rst contains:
Welcome to My Module's documentation!
=====================================
.. toctree::
:maxdepth: 2
:caption: Contents:
.. automodule:: myproject
:members:
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
When i run
make html
i get a documentation that is missing the automodule part allthough i documented every class and every method in main.py like this:
class Thing:
"""This class represents Things
:param color: how the thing should look like
"""
def __init__(self, color):
pass
def color(self):
"""Tells you the color of the thing.
:returns: Color string
:rtype: str or unicode
"""
pass
Sys.path is also setup correctly, as it throws now error when making
sys.path.insert(0, os.path.abspath('../../'))
If it is relevant i also include the setup.py:
from setuptools import setup
setup(name='My Module',
version='0.1',
description='Internet of Things',
url='https://example.com',
author='Master Yoda',
author_email='[email protected]',
license='GPLv3',
packages=['mymodule'],
zip_safe=False)
What can i change to make autodoc work?
Upvotes: 13
Views: 16265
Reputation: 2721
If your class is imported into __init__.py
you may also need :imported-members:
like so:
.. automodule:: myproject
:imported-members:
:members:
:undoc-members:
:show-inheritance:
Upvotes: 12
Reputation: 51012
The main
module is in the myproject
package. In order to document main
, you need the following:
.. automodule:: myproject.main
:members:
Upvotes: 7