sphinx
sphinx copied to clipboard
Recursive autosummary fails when a module contains a reference to itself.
Describe the bug
Recursive autosummary produces broken documentation and emits a WARNING: autosummary: stub file not found message when a module contains a reference to itself.
To Reproduce
Assume a Python project with the following structure:
/home/user/project
├── docs
│ ├── conf.py
│ ├── index.rst
└── src
└── aaa
├── bbb
│ ├── __init__.py
├── __init__.py
Both __init__.py files contain just a module docstring.
conf.py:
import sys
sys.path.insert(0, '/home/user/project/src')
needs_sphinx = '3.5'
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.autosummary']
autosummary_generate = True
index.rst
.. autosummary::
:toctree: api
:recursive:
aaa
Running sphinx-build for the above setup produces correct API docs.
However, if you add the line
import aaa.bbb
to src/aaa/__init__.py, Sphinx gives the warning
/home/user/project/docs/api/aaa.rst.rst:26: WARNING: autosummary: stub file not found 'aaa.aaa.bbb'. Check your autosummary_generate setting.
and fails to link aaa to aaa.bbb:
checking consistency... /home/user/project/docs/api/aaa.bbb.rst: WARNING: document isn't included in any toctree
Expected behavior Docs should be produced exactly as before, without warnings.
Environment info
- OS: Ubuntu 20.04
- Python version: 3.9.1
- Sphinx version: 3.5.1
- Sphinx extensions: ['sphinx.ext.autodoc', 'sphinx.ext.autosummary']
I am having this exact same issue. Does anyone have a workaround for this problem, or any ideas for a patch that could resolve it?
Also found this issue.
Same issue
Does anyone have a stopgap solution for this? I saw mention of placing automodule before autosummary in #9069, however I don't think that is working for me.