Sphinx doesn't process python classes -


gooday, i'm having trouble @ autogenerating python documentation. project layout following:

project_folder

  • package
    • module1.py
    • module2.py
  • doc
    • make.bat
    • build
    • source
      • index.rst
      • package.rst
      • modules.rst
      • conf.py

inside module1.py , module2.py there classes (with docstrings). i've added in conf.py following line:

sys.path.insert(0, os.path.abspath('../../package')) 

both modules.rst , package.rst have been generating calling:

sphinx-apidoc -o doc/source package/ 

inside folder. finally, i've added "modules" inside index.rst file displayed below (not whole index.rst, generated sphinx-quickstart):

contents:  .. toctree::    :maxdepth: 2     modules 

i have several issues:

1) when call sphinx-autodoc doc/ directory documentation isn't generated. in order correctly generate documentaiton, have replace package.module1 module1 inside package.rst:

#before .. automodule:: package.module1     :members:     :undoc-members:     :show-inheritance: #after .. automodule:: module1     :members:     :undoc-members:     :show-inheritance: 

how can automatically perform operation? or setup faulty?

2) if module1.py contains bunch of defs, documentation generated correctly. however, if put class inside it, documentation isn't generated @ (note package.rst file remains unchanged after running second time sphinx-apidoc). can display class documentation?

thanks

ok, after viewing sphinx logs (my bad not posting them out) realized answer first issue: if want use sphinx-apidoc output have add in conf.py parent of "package" package, not package itself

sys.path.insert(0, os.path.abspath('../../')) #documentation detected sys.path.insert(0, os.path.abspath('../../package')) #documentation isn't detected 

in way python import folder in pythonpath, thereby solving "package.module1"/"package.module2" path. issue #2, realized (again, bad) sphinx generated documentation public members , class had dunder methods (like __ init__). if want document methods (like me), sure add in .rst files :special-members: under module loaded:

.. automodule:: package.module2     :members:     :undoc-members:     :show-inheritance:     :private-members: # if want document __x attributes     :special-members: # if want document __xxx__ dunder methods 

Comments