Skip to content

autosummary generates classes on python <=3.8 but stops working on python >3.8 #10182

@FirefoxMetzger

Description

@FirefoxMetzger

Describe the bug

When adding lazy importing of members to a module, sphinx fails to build the docs correctly in python 3.9 and 3.10, but works as expected up until python <=3.8.

How to Reproduce

$ git clone -b add-lazy-importing https://github.com/FirefoxMetzger/sphinx-39-bug.git
$ cd sphinx-39-bug
$ pip install sphinx
$ sphinx-build -W ./doc/source ./doc/build

Output on python >3.8:

Running Sphinx v4.4.0
making output directory... done
[autosummary] generating autosummary for: index.rst
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 1 source files that are out of date
updating environment: [new config] 1 added, 0 changed, 0 removed
reading sources... [100%] index                                                                                                                                                                                                                                      

Warning, treated as error:
docstring of demp_project:5:autosummary: stub file not found 'demp_project.Foo'. Check your autosummary_generate setting.

Alternatively, you can check the logs of the CI that I attached to the repo to build the docs on major python versions: FirefoxMetzger/sphinx-39-bug#3

Expected behavior

The docs should build cleanly, no matter which python version is being used.

Your project

https://github.com/FirefoxMetzger/sphinx-39-bug

Screenshots

No response

OS

Tested on Windows 11 and ubuntu 20.04

Python version

3.7 - 3.10

Sphinx version

4.4.0

Sphinx extensions

No response

Extra tools

No response

Additional context

I also posted this as a question on StackOverflow: https://stackoverflow.com/questions/70978404/why-does-sphinx-autosummary-not-create-a-toctree-when-used-inside-a-class

I got some help from a user called mzjn; however, he couldn't reproduce the faulty behavior locally, which makes me wonder if I might just be going about this the wrong way.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions