0
votes

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?

1
It seems like you are confusing Python modules with RST files. It does not seem likely that you have a module called RstFiles.mzjn
For the other problem, see stackoverflow.com/q/15249340/407651mzjn
I presume that you have a Python file called BatchDataContainer.py. Where exactly is it located in your file structure?mzjn
@mzjn the python files are located in D:\hfTools\Projects\Validation-Source\Products but Docs folder for sphinx is located at D:\hfTools\Projects\Validation-Source\DocsFelixS
But inside D:\hfTools\Projects\Validation-Source\Products I have a lot of .py files (around 400) and for each of them I have created a separately .rst fileFelixS

1 Answers

0
votes

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: