Repository navigation
Description
Describe the bug
As of release 7.4.4, a new warning was added in autosummary in the line
sphinx/sphinx/ext/autosummary/__init__.py
Line 644 in 1e13565
| msg = __('Summarised items should not include the current module. ' |
I run Sphinx builds in CI and on readthedocs.org with -W --keep-going flags to ensure that documents are properly built. The pipelines have started failing for the new release with no changes to the documentation itself.
The builds use autosummary for the entire package recursively:
.. autosummary::
:toctree: python/<package_name>
:recursive:
<package_name>
The warnings are emitted because the generated documentation uses autosummary directive inside an automodule directive. This is a snippet from the generated documentation.
.. automodule:: <package_name>
.. autosummary::
:toctree:
:recursive:
<package_name>.<module0>
<package_name>.<module1>
How to Reproduce
conf.py
from pathlib import Path
import sys
__this_dir = Path(__file__).absolute().parent
sys.path.append(__this_dir)
project = "foo"
extensions = [
"sphinx.ext.autosummary",
]
# Python configuration
autodoc_default_options = {"members": True}
index.rst
.. autosummary::
:toctree: docs/pkg
:recursive:
pkg
Create the pkg with
mkdir -p pkg/mod0 pkg/mod1
touch pkg/__init__.py pkg/mod0/__init__.py pkg/mod1/__init__.py
Run sphinx with
PYTHONPATH=. sphinx-build . _build/
It emits warnings and fails build with -W.
WARNING: Summarised items should not include the current module. Replace 'pkg.mod0' with 'mod0'.
WARNING: Summarised items should not include the current module. Replace 'pkg.mod1' with 'mod1'.
There doesn't seem to be a way to ignore only certain warnings in Sphinx, so I would like to keep the -W flag in my builds. Is there a way to avoid the warning or does something within autosummary need to be updated to not include the package name when documenting it?
Environment Information
Please paste all output below into the bug report template
Platform: linux; (Linux-6.9.9-arch1-1-x86_64-with-glibc2.39)
Python version: 3.12.4 (main, Jun 7 2024, 06:33:07) [GCC 14.1.1 20240522])
Python implementation: CPython
Sphinx version: 7.4.4
Docutils version: 0.21.2
Jinja2 version: 3.1.4
Pygments version: 2.18.0
Sphinx extensions
`["sphinx.ext.autosummary"]`Additional context
No response
Activity
[-]New warning in version 7.4.4 from autosummary causing automated builds to fail[/-][+]New warning in version 7.4 from autosummary causing automated builds to fail[/+]AA-Turner commentedon Jul 15, 2024
Hi @munircontractor, have you tried
in your
conf.py?See https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-warning-control
A
mun1r0b0t commentedon Jul 15, 2024
Oh, thanks for that. I could not find it when searching for a fix for this.
valeriupredoi commentedon Jul 16, 2024
hi @AA-Turner and cheers for that sight! I believe adding the ignore in
conf.pyis a bit of a workaround, what is the actual fix, and will it be done in Sphinx or is it the user's responsibility? Cheers 🍺ilan-gold commentedon Jul 16, 2024
+1
AA-Turner commentedon Jul 17, 2024
Please see #12609, which addresses the underlying issue. I'd be grateful for any testing.
A
AA-Turner commentedon Jul 18, 2024
I have released Sphinx 7.4.6 with a fix.
A
larsoner commentedon Jul 18, 2024
I am using 7.4.6 and am still hitting this issue, see this build which just used 7.4.6:
https://app.circleci.com/pipelines/github/mne-tools/mne-bids/6225/workflows/dc1e1c11-de2a-4ac0-b4d8-b3e8ee98b740/jobs/8445?invite=true#step-107-8950_109
Maybe it wasn't caught by this fix because of the
autolinkdefault role in https://github.com/mne-tools/mne-bids/blob/3c020d9c6b734d8f8f13a293bd11b175192a7ae1/doc/conf.py#L77 ? Not sure. It only happens on refs likeRefs with explicit prefixes like
:class:are fine.AA-Turner commentedon Jul 18, 2024
Hi @larsoner, are you able to provide a reproducer please? I'll reopen the issue.
A
larsoner commentedon Jul 19, 2024
Not minimal by any means but something like this:
should show the
in about 20s.
electric-coder commentedon Jul 19, 2024
@larsoner
I have to agree with the comment in the line of code you linked, namely:
That's why I never use
default_role, when something goes wrong I don't have to second guess those default roles.larsoner commentedon Jul 19, 2024
Updated my comment since mne-bids has since in
mainit now has some workarounds (e.g., explicit roles) and pins, so checking out3c020d9c6b734d8f8f13a293bd11b175192a7ae1shows more relevant errors.AA-Turner commentedon Jul 20, 2024
If I replace
default_role = "autolink"withdefault_role = "py:obj", the "Summarised items should not include the current module" warnings go away (and a new set of resolution errors appear), which indicates that the problem is indeed with autolink.A
AA-Turner commentedon Jul 20, 2024
Sphinx 7.4.7 has been released with a fix.
A
abey79 commentedon Jul 23, 2024
Thanks for looking into this issue. I'm however still seeing it with sphinx 7.4.7:
(requires poetry,
pipx install poetryis fine)The commit comes from this dependabot PR: abey79/vpype#754
Previously using 7.3.7 with no issue.
lagru commentedon Aug 5, 2024
We are also still seeing this for 7.4.7 on scikit-image's side, scikit-image/scikit-image#7485.
rossbar commentedon Aug 15, 2024
NetworkX is still seeing this as well with sphinx 7.4.7. FWIW networkx's docs are configured with
objas the default role.AA-Turner commentedon Aug 15, 2024
A minimal reproducer would be really helpful -- there are a lot of moving parts in
autosummary, so reducing the problem domain does help a lot.A
rossbar commentedon Aug 15, 2024
In NetworkX's case it turns out this was the warning working as intended. There were indeed autosummary directives that specified the redundant parent module in file where the
.. currentmodulehad already been set (xref networkx/networkx#7599). I only noticed this after a bit of grepping the doc source, as my first pass through the sphinx build log didn't give any indication where the warnings originated. Apologies for the noise!docs: Ignore `autosummary.import_cycle` warnings
docs: Ignore `autosummary.import_cycle` warnings
docs: Ignore `autosummary.import_cycle` warnings