sphinx icon indicating copy to clipboard operation
sphinx copied to clipboard

Recursive autosummary fails when a module contains a reference to itself.

Open smite opened this issue 4 years ago • 5 comments
trafficstars

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']

smite avatar Mar 05 '21 19:03 smite

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?

roytsmart avatar Mar 04 '22 10:03 roytsmart

Also found this issue.

Rocamonde avatar Jul 24 '22 17:07 Rocamonde

Same issue

MCRE-BE avatar Aug 12 '22 14:08 MCRE-BE

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.

Naggafin avatar Jan 15 '24 17:01 Naggafin