MaVCArt MaVCArt - 3 months ago 33
Python Question

sphinx-apidoc picks up submodules, but autodoc doesn't document them

I've been working on a project for PyQt5 ( found here: https://github.com/MaVCArt/StyledPyQt5 ) which uses a package structure to make imports a bit more logical. I've been relatively successful in documenting the code so far with Sphinx, at least up until I introduced the package structure. ( before, everything was in one folder )

The following is the problem: when I run sphinx-apidoc, everything runs fine, no errors. What's more, autodoc picks up all my submodules just fine. This is the content of one of my .rst files:

styledpyqt package
==================

Subpackages
-----------

.. toctree::
:maxdepth: 8

styledpyqt.core

Submodules
----------

styledpyqt.StyleOptions module
------------------------------

.. automodule:: styledpyqt.StyleOptions
:members:
:undoc-members:
:show-inheritance:

styledpyqt.StyleSheet module
----------------------------

.. automodule:: styledpyqt.StyleSheet
:members:
:undoc-members:
:show-inheritance:


Module contents
---------------

.. automodule:: styledpyqt
:members:
:undoc-members:
:show-inheritance:


As you can tell, all submodules are being picked up.

However, when I run make html on this, none of these modules are being documented ( meaning the headers are there, but none of the methods, classes or members are displayed ). In the generated HTML, they're just headers with nothing underneath. I know for a fact that they're properly set up in the code comments, as the code has not changed between now and the set up of the package structure, aka when the documentation did work.

Does anyone have any ideas what the cause of this might be?

Note: to help with resolving this, here's a short breakdown of my folder structure:

styledpyqt
+ core
+ + base
+ + + __init__.py ( containing a class definition )
+ + + AnimationGroups.py
+ + + Animations.py
+ + __init__.py
+ + Color.py
+ + Float.py
+ + Gradient.py
+ + Int.py
+ + String.py
+ __init__.py
+ StyleOptions.py
+ StyleSheet.py

Answer

I ended up fixing this problem eventually - it seems I was overlooking some errors, and sphinx worked just fine. I added all the paths the package contains in the conf.py and it just worked from there:

conf.py:

sys.path.insert(0, os.path.abspath('../StyledPyQt5'))
sys.path.insert(0, os.path.abspath('../StyledPyQt5/styledpyqt'))
sys.path.insert(0, os.path.abspath('../StyledPyQt5/styledpyqt/core'))
sys.path.insert(0, os.path.abspath('../StyledPyQt5/styledpyqt/core/base'))

From there, everything worked.

Comments