Skip to content

Commit f3e0ece

Browse files
bpo-35293: Remove RemovedInSphinx40Warning (GH-22198)
* bpo-35293: Remove RemovedInSphinx40Warning * Update Misc/NEWS.d/next/Documentation/2020-09-12-17-37-13.bpo-35293._cOwPD.rst Co-authored-by: Victor Stinner <[email protected]> * bpo-35293: Apply Victor's review Co-authored-by: Victor Stinner <[email protected]> (cherry picked from commit 6595cb0) Co-authored-by: Dong-hee Na <[email protected]>
1 parent c053402 commit f3e0ece

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

Doc/tools/extensions/pyspecific.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@
3131
from sphinx.util.nodes import split_explicit_title
3232
from sphinx.writers.text import TextWriter, TextTranslator
3333
from sphinx.writers.latex import LaTeXTranslator
34-
from sphinx.domains.python import PyModulelevel, PyClassmember
34+
35+
try:
36+
from sphinx.domains.python import PyFunction, PyMethod
37+
except ImportError:
38+
from sphinx.domains.python import PyClassmember as PyMethod
39+
from sphinx.domains.python import PyModulelevel as PyFunction
3540

3641
# Support for checking for suspicious markup
3742

@@ -238,17 +243,18 @@ def needs_arglist(self):
238243
return False
239244

240245

241-
class PyDecoratorFunction(PyDecoratorMixin, PyModulelevel):
246+
class PyDecoratorFunction(PyDecoratorMixin, PyFunction):
242247
def run(self):
243248
# a decorator function is a function after all
244249
self.name = 'py:function'
245-
return PyModulelevel.run(self)
250+
return PyFunction.run(self)
246251

247252

248-
class PyDecoratorMethod(PyDecoratorMixin, PyClassmember):
253+
# TODO: Use sphinx.domains.python.PyDecoratorMethod when possible
254+
class PyDecoratorMethod(PyDecoratorMixin, PyMethod):
249255
def run(self):
250256
self.name = 'py:method'
251-
return PyClassmember.run(self)
257+
return PyMethod.run(self)
252258

253259

254260
class PyCoroutineMixin(object):
@@ -265,31 +271,31 @@ def handle_signature(self, sig, signode):
265271
return ret
266272

267273

268-
class PyCoroutineFunction(PyCoroutineMixin, PyModulelevel):
274+
class PyCoroutineFunction(PyCoroutineMixin, PyFunction):
269275
def run(self):
270276
self.name = 'py:function'
271-
return PyModulelevel.run(self)
277+
return PyFunction.run(self)
272278

273279

274-
class PyCoroutineMethod(PyCoroutineMixin, PyClassmember):
280+
class PyCoroutineMethod(PyCoroutineMixin, PyMethod):
275281
def run(self):
276282
self.name = 'py:method'
277-
return PyClassmember.run(self)
283+
return PyMethod.run(self)
278284

279285

280-
class PyAwaitableFunction(PyAwaitableMixin, PyClassmember):
286+
class PyAwaitableFunction(PyAwaitableMixin, PyFunction):
281287
def run(self):
282288
self.name = 'py:function'
283-
return PyClassmember.run(self)
289+
return PyFunction.run(self)
284290

285291

286-
class PyAwaitableMethod(PyAwaitableMixin, PyClassmember):
292+
class PyAwaitableMethod(PyAwaitableMixin, PyMethod):
287293
def run(self):
288294
self.name = 'py:method'
289-
return PyClassmember.run(self)
295+
return PyMethod.run(self)
290296

291297

292-
class PyAbstractMethod(PyClassmember):
298+
class PyAbstractMethod(PyMethod):
293299

294300
def handle_signature(self, sig, signode):
295301
ret = super(PyAbstractMethod, self).handle_signature(sig, signode)
@@ -299,7 +305,7 @@ def handle_signature(self, sig, signode):
299305

300306
def run(self):
301307
self.name = 'py:method'
302-
return PyClassmember.run(self)
308+
return PyMethod.run(self)
303309

304310

305311
# Support for documenting version of removal in deprecations
Lines changed: 1 addition & 0 deletions
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)