Skip to content

fix: Allow nipype.sphinx.ext.apidoc Config to work with Sphinx 8.2.1+ #3716

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 27 additions & 9 deletions nipype/sphinxext/apidoc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# vi: set ft=python sts=4 ts=4 sw=4 et:
"""Settings for sphinxext.interfaces and connection to sphinx-apidoc."""
import re
from packaging.version import Version

import sphinx
from sphinx.ext.napoleon import (
Config as NapoleonConfig,
_patch_python_domain,
Expand Down Expand Up @@ -39,13 +42,24 @@

"""

_config_values = {
"nipype_skip_classes": (
["Tester", "InputSpec", "OutputSpec", "Numpy", "NipypeTester"],
"env",
),
**NapoleonConfig._config_values,
}
if Version(sphinx.__version__) >= Version("8.2.1"):
_config_values = (
(
"nipype_skip_classes",
["Tester", "InputSpec", "OutputSpec", "Numpy", "NipypeTester"],
"env",
frozenset({list[str]}),
),
*NapoleonConfig._config_values,
)
else:
_config_values = {
"nipype_skip_classes": (
["Tester", "InputSpec", "OutputSpec", "Numpy", "NipypeTester"],
"env",
),
**NapoleonConfig._config_values,
}


def setup(app):
Expand Down Expand Up @@ -82,8 +96,12 @@
app.connect("autodoc-process-docstring", _process_docstring)
app.connect("autodoc-skip-member", _skip_member)

for name, (default, rebuild) in Config._config_values.items():
app.add_config_value(name, default, rebuild)
if Version(sphinx.__version__) >= Version("8.2.1"):
for name, default, rebuild, types in Config._config_values:
app.add_config_value(name, default, rebuild, types=types)

Check warning on line 101 in nipype/sphinxext/apidoc/__init__.py

View check run for this annotation

Codecov / codecov/patch

nipype/sphinxext/apidoc/__init__.py#L99-L101

Added lines #L99 - L101 were not covered by tests
else:
for name, (default, rebuild) in Config._config_values.items():
app.add_config_value(name, default, rebuild)

Check warning on line 104 in nipype/sphinxext/apidoc/__init__.py

View check run for this annotation

Codecov / codecov/patch

nipype/sphinxext/apidoc/__init__.py#L103-L104

Added lines #L103 - L104 were not covered by tests
return {"version": __version__, "parallel_read_safe": True}


Expand Down