I have the following project structure with my code and documentation:
├───docs
│ ├───_build
│ ├───_static
│ ├───...
│ ├───conf.py
│ ├───index.srt
│ ├───make.bat
| └───Makefile
├───source
│ ├───script1.py
│ ├───script2.py
| └───script3.py
my conf.py:
import os
import sys
sys.path.insert(0, os.path.abspath('../source'))
...
extensions = ['sphinx.ext.autodoc']
I am running sphinx-apidoc -o . ../source
inside the docs folder. It generates a new file .rst
file for each of my scripts.
And I am adding modules
to the index.rst
file
After that I'm running make html
to generate my documentation. But it's raising a warning and not generating docs for an specific file:
WARNING: autodoc: failed to import module 'script3'; the following exception was raised:
No module named 'source'
I isolate the problem to an import statement made inside script3.py code:
from source.scripts2 import MyClass
So it seems that since the folder is not a module is raising the error. But I am not sure how to fix it.
I have tried to create empty __init__.py
file in the project and in the source folder, but the error persist
How could I fix it?