My project has the following structure.
Main_Folder:
|---- .venv_folder
|---- Documentation:
|------ source
|------ index.rst,conf.py, Module_1.rst, Module_2.rst
|------ build
|---- Modules:
|------ Module_1
|------ Module_2
In Module_1 and Module_2, I have some scripts with docstrings I want to show, in a html type of view.
In the source folder, I have
-> index.rst, with:
.. toctree::
:maxdepth: 2
Module_1
Module_2
-> conf.py, with:
import os
import sys
sys.path.insert(0, os.path.abspath('../../Modules'))
os.path.abspath('../..')
returns ~/Main_Folder
So, I've added the directory where my modules reside to sys.path.
In Module_1.rst and Module_2.rst, I have almost the same:
Module_1
===========
.. automodule:: Module_1
:members:
When I run sphinx-build -b html source build
, after having activated the venv, I get the following:
WARNING: autodoc: failed to import module 'Module_1'; the following exception was raised: No module named 'Modules' WARNING: autodoc: failed to import module 'Module_2'; the following exception was raised: No module named 'Modules'
How do I make sphinx to detect the modules?