From b0e9ed529f68408b0c6b10cf3b1aa824f83158c5 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Thu, 21 May 2026 14:18:40 +0100 Subject: [PATCH] Adjust to cope with Sphinx 9 There might be some way to make this extension work with the new `sphinx.ext.autodoc` implementation, but if so I don't know what it is; see https://github.com/sphinx-doc/sphinx/issues/14089. For now, this seems to get things going again. `sphinx.ext.autodoc.stringify_signature` was only ever a re-export from `sphinx.util.inspect`, so importing it directly from there should be safe with all the Sphinx versions that worked before. --- docs/conf.py | 1 + invocations/autodoc.py | 6 +++++- tests/autodoc/_support/conf.py | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index b0199d9..1962dea 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -41,6 +41,7 @@ } # Other extension configs +autodoc_use_legacy_class_based = True autodoc_default_options = { "members": True, "special-members": True, diff --git a/invocations/autodoc.py b/invocations/autodoc.py index fbff267..30e72e0 100644 --- a/invocations/autodoc.py +++ b/invocations/autodoc.py @@ -26,6 +26,9 @@ - As noted above, this only works for modules that are importable, like any other Sphinx autodoc use case. + - For now, add ``autodoc_use_legacy_class_based = True`` to your + ``conf.py`` (see `sphinx-doc/sphinx#14089 + `__). - Unless you want to opt-in which module members get documented, use ``:members:`` or add ``"members": True`` to your ``conf.py``'s ``autodoc_default_options``. @@ -47,6 +50,7 @@ # For sane mock patching. Meh. from sphinx.ext import autodoc +from sphinx.util.inspect import stringify_signature class TaskDocumenter( @@ -68,7 +72,7 @@ def format_args(self): # after which point "call tasks as raw functions" may be less common. # TODO: also, it may become moot-ish if we turn this all into emission # of custom domain objects and/or make the CLI arguments the focus - return autodoc.stringify_signature(inspect.signature(function)) + return stringify_signature(inspect.signature(function)) def document_members(self, all_members=False): # Neuter this so superclass bits don't introspect & spit out autodoc diff --git a/tests/autodoc/_support/conf.py b/tests/autodoc/_support/conf.py index a33252e..5e30750 100644 --- a/tests/autodoc/_support/conf.py +++ b/tests/autodoc/_support/conf.py @@ -7,4 +7,5 @@ master_doc = "index" extensions = ["invocations.autodoc"] +autodoc_use_legacy_class_based = True autodoc_default_options = dict(members=True)