Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sphinx- How to autodoc .py files located within multiple folders?

I am new to both Python and Sphinx and am attempting to autodoc python files located in a directory structured similar to the following:

Project
├── Sphinx
|   ├── index.rst
|   ├── autodoc.rst
|   └──  conf.py
├── Scripts
|   ├── file1.py
|   └──  file2.py
|   ├── folder
|   |   └── file3.py

My conf.py file contains:

sys.path.insert(0, os.path.abspath("../Scripts/"))

And autodoc contains:

.. automodule:: file1
  :members:

.. automodule:: file2
  :members:

.. automodule:: folder.file3
  :members:

File3.py is not autodoc'ing correctly (Error: No module named metric.billpay)

I've also tried:

.. automodule:: folder/file3
  :members:

But I receive

WARNING: invalid signature for automodule (u'folder/file3')

WARNING: don't know which module to import for autodocumenting u'folder/file3' (try placing a "module" or "currentmodule" directive in the document, or giving an explicit module name)

Does anyone know how to fix this? I am new to Python, Sphinx, and StackOverflow, so my apologies if there are problems with this question.

like image 992
B. Evans Avatar asked Mar 05 '23 23:03

B. Evans


1 Answers

In addition too:

sys.path.insert(0, os.path.abspath("..Scripts/"))

I added this afterward:

sys.path.insert(0, os.path.abspath("..Scripts/Folder/"))

Which allowed me to access files in Folder with autodoc.

like image 195
B. Evans Avatar answered May 02 '23 03:05

B. Evans