I am adding rst files to an existing repository using Sphinx v6.1.3 with sphinx.ext.autodoc
extension.
when running make html
the new rst file causes an error:
Extension error (sphinx_automodapi.automodsumm):
Handler <function process_automodsumm_generation at 0x7fedb8d30430> for event 'builder-inited' threw an exception (exception: No module named 'pandas')
make: *** [html] Error 2
(pandas
is one import issue I'm having, but also having the issue with another import that I can't install in the environment, so using pandas
for the sake of this question)
Sphinx documentation offers the solution to use
autodoc_mock_imports = ["pandas"]
which I added to config.py
I then re-ran
$ make html
but the error persisted.
My folder structure is:
project_folder
└──doc
├── build
├── make.bat
├── Makefile
└── source
├── conf.py
├── index.rst
├── _static
└── problem
└── index.rst
└──src
└──project
└──problem
├──__init__.py
└──problem.py
my skimmed down root file (project_folder/doc/source/index.rst
) is:
Project Documentation
===============================================
.. toctree::
:maxdepth: 2
:caption: Contents:
problem/index
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
my skimmed down conf.py
(I went heavy on sys.path seeing if that would help)
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
sys.path.insert(0, os.path.abspath("../.."))
sys.path.insert(0, os.path.abspath("../../src"))
sys.path.insert(0, os.path.abspath("../../src/project"))
sys.path.insert(0, os.path.abspath("../../src/project/problem"))
autodoc_mock_imports = ['pandas']
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.imgmath',
'sphinx.ext.napoleon',
'sphinx.ext.intersphinx',
'sphinx.ext.autosummary',
'sphinx_automodapi.automodapi'
]
templates_path = ['_templates']
exclude_patterns = ['project']
html_theme = 'sphinx_rtd_theme'
pygments_style = 'sphinx'
default_role = 'py:obj'
Finally, specific rst file (project_folder/doc/source/problem/index.rst
) is:
Problem
=======
This package contains modules for Problem
Reference/API
-------------
.. module:: Project.problem
.. automodapi:: project.problem.problem
:no-inheritance-diagram:
I appreciate any input!