Skip to content

Commit cc36ca8

Browse files
committed
remove Sphinx40 warning
Code based on gh#python/cpython@d4f5bb9 (released upstream in 3.7.13). Fixes: bpo#46811 Patch: remove-sphinx40-warning.patch
1 parent 2f0833f commit cc36ca8

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

Doc/tools/extensions/pyspecific.py

+17-11
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@
2727
from sphinx.writers.html import HTMLTranslator
2828
from sphinx.writers.text import TextWriter, TextTranslator
2929
from sphinx.writers.latex import LaTeXTranslator
30-
from sphinx.domains.python import PyModulelevel, PyClassmember
30+
31+
try:
32+
from sphinx.domains.python import PyFunction, PyMethod
33+
except ImportError:
34+
from sphinx.domains.python import PyClassmember as PyMethod
35+
from sphinx.domains.python import PyModulelevel as PyFunction
3136

3237
# Support for checking for suspicious markup
3338

@@ -142,17 +147,18 @@ def needs_arglist(self):
142147
return False
143148

144149

145-
class PyDecoratorFunction(PyDecoratorMixin, PyModulelevel):
150+
class PyDecoratorFunction(PyDecoratorMixin, PyFunction):
146151
def run(self):
147152
# a decorator function is a function after all
148153
self.name = 'py:function'
149-
return PyModulelevel.run(self)
154+
return PyFunction.run(self)
150155

151156

152-
class PyDecoratorMethod(PyDecoratorMixin, PyClassmember):
157+
# TODO: Use sphinx.domains.python.PyDecoratorMethod when possible
158+
class PyDecoratorMethod(PyDecoratorMixin, PyMethod):
153159
def run(self):
154160
self.name = 'py:method'
155-
return PyClassmember.run(self)
161+
return PyMethod.run(self)
156162

157163

158164
class PyCoroutineMixin(object):
@@ -162,19 +168,19 @@ def handle_signature(self, sig, signode):
162168
return ret
163169

164170

165-
class PyCoroutineFunction(PyCoroutineMixin, PyModulelevel):
171+
class PyCoroutineFunction(PyCoroutineMixin, PyFunction):
166172
def run(self):
167173
self.name = 'py:function'
168-
return PyModulelevel.run(self)
174+
return PyFunction.run(self)
169175

170176

171-
class PyCoroutineMethod(PyCoroutineMixin, PyClassmember):
177+
class PyCoroutineMethod(PyCoroutineMixin, PyMethod):
172178
def run(self):
173179
self.name = 'py:method'
174-
return PyClassmember.run(self)
180+
return PyMethod.run(self)
175181

176182

177-
class PyAbstractMethod(PyClassmember):
183+
class PyAbstractMethod(PyMethod):
178184

179185
def handle_signature(self, sig, signode):
180186
ret = super(PyAbstractMethod, self).handle_signature(sig, signode)
@@ -184,7 +190,7 @@ def handle_signature(self, sig, signode):
184190

185191
def run(self):
186192
self.name = 'py:method'
187-
return PyClassmember.run(self)
193+
return PyMethod.run(self)
188194

189195

190196
# Support for documenting version of removal in deprecations
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix RemovedInSphinx40Warning when building the documentation. Patch by Dong-hee Na.

0 commit comments

Comments
 (0)