File: Add-support-for-Sphinx-9.patch

package info (click to toggle)
python-autodocsumm 0.2.14-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 576 kB
  • sloc: python: 999; makefile: 171; sh: 21
file content (100 lines) | stat: -rw-r--r-- 3,531 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
From: Dmitry Shachnev <mitya57@debian.org>
Date: Mon, 23 Mar 2026 00:50:47 +0300
Subject: Add support for Sphinx 9

Update imports and force the legacy autodoc interface.

Forwarded: https://github.com/Chilipp/autodocsumm/pull/109
---
 autodocsumm/__init__.py | 47 ++++++++++++++++++++++++++++++++++-------------
 pyproject.toml          |  2 +-
 2 files changed, 35 insertions(+), 14 deletions(-)

diff --git a/autodocsumm/__init__.py b/autodocsumm/__init__.py
index 29843d7..40bcd38 100755
--- a/autodocsumm/__init__.py
+++ b/autodocsumm/__init__.py
@@ -49,12 +49,20 @@ from docutils import nodes
 
 import sphinx
 
-from sphinx.util.docutils import SphinxDirective
-
+from sphinx.errors import PycodeError
 from sphinx.ext.autodoc import (
-    ClassDocumenter, ModuleDocumenter, ALL, PycodeError,
-    ModuleAnalyzer, AttributeDocumenter, DataDocumenter, Options, ExceptionDocumenter,
-    Documenter, prepare_docstring)
+    ALL,
+    AttributeDocumenter,
+    ClassDocumenter,
+    DataDocumenter,
+    Documenter,
+    ExceptionDocumenter,
+    ModuleDocumenter,
+    Options,
+)
+from sphinx.pycode import ModuleAnalyzer
+from sphinx.util.docstrings import prepare_docstring
+from sphinx.util.docutils import SphinxDirective
 import sphinx.ext.autodoc as ad
 
 signature = Signature = None
@@ -713,8 +721,29 @@ class AutoDocSummDirective(SphinxDirective):
         return node.children
 
 
+def _before_config_inited(app, config):
+    # Enable the legacy (``Documenter``) autodoc implementation
+    # for all users of the extension.
+    config.autodoc_use_legacy_class_based = True
+
+
+def _after_config_inited(app, config):
+    # make sure to allow inheritance when registering new documenters
+    registry = app.registry.documenters
+    for cls in [AutoSummClassDocumenter, AutoSummModuleDocumenter,
+                CallableAttributeDocumenter, NoDataDataDocumenter,
+                NoDataAttributeDocumenter, AutoSummExceptionDocumenter]:
+        if not issubclass(registry.get(cls.objtype), cls):
+            app.add_autodocumenter(cls, override=True)
+
+
 def setup(app):
     """setup function for using this module as a sphinx extension"""
+    # Run before sphinx.ext.autodoc._register_directives().
+    app.connect("config-inited", _before_config_inited, priority=400)
+    # Run after sphinx.ext.autodoc._register_directives().
+    app.connect("config-inited", _after_config_inited, priority=600)
+
     app.setup_extension('sphinx.ext.autosummary')
     app.setup_extension('sphinx.ext.autodoc')
     app.add_directive('autoclasssumm', AutoDocSummDirective)
@@ -729,14 +758,6 @@ def setup(app):
         [option for option in AutoSummClassDocumenter.option_spec
          if option not in AUTODOC_DEFAULT_OPTIONS])
 
-    # make sure to allow inheritance when registering new documenters
-    registry = app.registry.documenters
-    for cls in [AutoSummClassDocumenter, AutoSummModuleDocumenter,
-                CallableAttributeDocumenter, NoDataDataDocumenter,
-                NoDataAttributeDocumenter, AutoSummExceptionDocumenter]:
-        if not issubclass(registry.get(cls.objtype), cls):
-            app.add_autodocumenter(cls, override=True)
-
     # group event
     app.add_event('autodocsumm-grouper')
 
diff --git a/pyproject.toml b/pyproject.toml
index 387fea4..7323ca7 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -33,7 +33,7 @@ classifiers = [
 
 requires-python = '>= 3.7'
 dependencies = [
-    'Sphinx >= 4.0, < 9.0',
+    'Sphinx >= 4.0, < 10.0',
 ]
 
 [project.urls]