sphinx-doc / sphinx

The Sphinx documentation generator
https://www.sphinx-doc.org/
Other
6.58k stars 2.12k forks source link

Sphinx 7.4.6: autosummary: Failed to import module #12660

Open AA-Turner opened 3 months ago

AA-Turner commented 3 months ago

Is there any chance this change would have introduced a warning by mistake? We use our own module.rst and class.rst templates, but they look awfully similar to the ones here.

We're seeing:

Warning, treated as error:
[autosummary] failed to import foo.
Possible hints:
* ModuleNotFoundError: No module named 'foo'
* KeyError: 'foo'
* ValueError: not enough values to unpack (expected 2, got 1)

good chance this is user-error, but thought I would ask (it does work just before 7.4.6)!

Originally posted by @mwalsh161 in https://github.com/sphinx-doc/sphinx/issues/12609#issuecomment-2244089627

AA-Turner commented 3 months ago

Hi Michael (@mwalsh161), thanks for writing. I haven't had any further reports of issues, so my first instinct would be to suspect the templates. The ValueError re unpacking also looks interesting.

Are you able to share either your project or a minimal reporoducer so that we might investigate?

Best, Adam

rtuck99 commented 3 months ago

I am also seeing this issue, I believe there was a change between versions 7.3.7 and 7.4.6, which causes documentation table of contents not to be generated.

I get similar warnings e.g.

WARNING: [autosummary] failed to import i03.
Possible hints:
* ValueError: not enough values to unpack (expected 2, got 1)
* KeyError: 'i03'
* ModuleNotFoundError: No module named 'i03'

Compare the following two github builds:

version 7.3.7

https://github.com/DiamondLightSource/dodal/actions/runs/9891318307/job/27321488418 which builds correctly and generates api documentation: https://diamondlightsource.github.io/dodal/1.29.3/user/reference/generated/dodal.beamlines.html

version 7.4.6

https://github.com/DiamondLightSource/dodal/actions/runs/10009596477/job/27668842307 which builds documentation that no longer includes the subpackages https://diamondlightsource.github.io/dodal/1.29.4/user/reference/generated/dodal.beamlines.html

I believe this may be related to change #12609 as the generated sources no longer appear to have prefixes e.g.

.. autosummary::
   :toctree:
   :recursive:

   i03
   i04
   i04_1
   i20_1
   i22
   i23
   i24
   p38
   p45
AA-Turner commented 3 months ago

Also xref https://github.com/scikit-image/scikit-image/pull/7297#issuecomment-2245125314 by @mkcor:

Thanks, @AA-Turner, this install worked. Unfortunately, I'm getting the same error as with 7.4.5 and 7.4.6, i.e.,

Warning, treated as error:
Summarised items should not include the current module. Replace 'skimage.color' with 'color'.
[autosummary.import_cycle]
make: *** [Makefile:50: html] Error 2