FelixS
FelixS

Reputation: 33

Sphinx doesn't find the modules from a specific directory

I have faced a problem with Sphinx in Python. Even if I have followed the instructions from https://groups.google.com/forum/#!topic/sphinx-users/lO4CeNJQWjg I was not able to solve it.

I have Docs/source folder which contains:

  1. conf.py
  2. index.rst
  3. RstFiles (the folder which contains .rst files for each module).

In conf.py I specify the abs path in the following way: sys.path.insert(0, os.path.abspath('..'))

In index.rst I call all the modules from RstFiles folder in the following way:

.. toctree::
   :maxdepth: 2
   :caption: Contents:

   BatchDataContainer.rst
   BatchDefaultValues.rst
   BatchTypes.rst

And finally, the content of each .rst file is in the following way:

BatchDataContainer 
==================
.. automodule:: RstFiles.BatchDataContainer
   :members:

When I run sphinx-build I get 2 main errors:

D:\hfTools\Projects\Validation-Source\Docs\source\RstFiles\BatchDataContainer.rst: WARNING: document isn't included in any toctree

and

WARNING: autodoc: failed to import module 'BatchDataContainer' from module 'RstFiles'; the following exception was raised: No module named 'RstFiles'

Any ideas what might be wrong cause I have tried different things already and nothing has helped?

Upvotes: 1

Views: 2834

Answers (1)

mzjn
mzjn

Reputation: 50947

If conf.py is located in this directory,

D:\hfTools\Projects\Validation-Source\Docs\source,

and the project's Python modules (including BatchDataContainer.py) are in

D:\hfTools\Projects\Validation-Source\Products,

then you need sys.path.insert(0, os.path.abspath('../..')) in conf.py.

The automodule directive needs to be updated as well:

.. automodule:: Products.BatchDataContainer
   :members:

Upvotes: 1

Related Questions