1

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?

5
  • It seems like you are confusing Python modules with RST files. It does not seem likely that you have a module called RstFiles. Commented Jun 12, 2020 at 9:18
  • For the other problem, see stackoverflow.com/q/15249340/407651 Commented Jun 12, 2020 at 9:19
  • I presume that you have a Python file called BatchDataContainer.py. Where exactly is it located in your file structure? Commented Jun 12, 2020 at 9:37
  • @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\Docs Commented Jun 12, 2020 at 9:49
  • 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 file Commented Jun 12, 2020 at 9:50

1 Answer 1

1

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: 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.