Skip to content

Commit 02f1485

Browse files
committed
bpo-35293: Remove RemovedInSphinx40Warning
1 parent 8af239e commit 02f1485

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

Doc/tools/extensions/pyspecific.py

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,16 @@
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 PyMethod
37+
except ImportError:
38+
from sphinx.domains.python import PyClassmember as PyMethod
39+
40+
try:
41+
from sphinx.domains.python import PyFunction
42+
except ImportError:
43+
from sphinx.domains.python import PyModulelevel as PyFunction
3544

3645
# Support for checking for suspicious markup
3746

@@ -271,17 +280,18 @@ def needs_arglist(self):
271280
return False
272281

273282

274-
class PyDecoratorFunction(PyDecoratorMixin, PyModulelevel):
283+
class PyDecoratorFunction(PyDecoratorMixin, PyFunction):
275284
def run(self):
276285
# a decorator function is a function after all
277286
self.name = 'py:function'
278-
return PyModulelevel.run(self)
287+
return PyFunction.run(self)
279288

280289

281-
class PyDecoratorMethod(PyDecoratorMixin, PyClassmember):
290+
# TODO: Use sphinx.domains.python.PyDecoratorMethod when possible
291+
class PyDecoratorMethod(PyDecoratorMixin, PyMethod):
282292
def run(self):
283293
self.name = 'py:method'
284-
return PyClassmember.run(self)
294+
return PyMethod.run(self)
285295

286296

287297
class PyCoroutineMixin(object):
@@ -298,31 +308,31 @@ def handle_signature(self, sig, signode):
298308
return ret
299309

300310

301-
class PyCoroutineFunction(PyCoroutineMixin, PyModulelevel):
311+
class PyCoroutineFunction(PyCoroutineMixin, PyFunction):
302312
def run(self):
303313
self.name = 'py:function'
304-
return PyModulelevel.run(self)
314+
return PyFunction.run(self)
305315

306316

307-
class PyCoroutineMethod(PyCoroutineMixin, PyClassmember):
317+
class PyCoroutineMethod(PyCoroutineMixin, PyMethod):
308318
def run(self):
309319
self.name = 'py:method'
310-
return PyClassmember.run(self)
320+
return PyMethod.run(self)
311321

312322

313-
class PyAwaitableFunction(PyAwaitableMixin, PyClassmember):
323+
class PyAwaitableFunction(PyAwaitableMixin, PyFunction):
314324
def run(self):
315325
self.name = 'py:function'
316-
return PyClassmember.run(self)
326+
return PyFunction.run(self)
317327

318328

319-
class PyAwaitableMethod(PyAwaitableMixin, PyClassmember):
329+
class PyAwaitableMethod(PyAwaitableMixin, PyMethod):
320330
def run(self):
321331
self.name = 'py:method'
322-
return PyClassmember.run(self)
332+
return PyMethod.run(self)
323333

324334

325-
class PyAbstractMethod(PyClassmember):
335+
class PyAbstractMethod(PyMethod):
326336

327337
def handle_signature(self, sig, signode):
328338
ret = super(PyAbstractMethod, self).handle_signature(sig, signode)
@@ -332,7 +342,7 @@ def handle_signature(self, sig, signode):
332342

333343
def run(self):
334344
self.name = 'py:method'
335-
return PyClassmember.run(self)
345+
return PyMethod.run(self)
336346

337347

338348
# 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+
Remove RemovedInSphinx40Warning when building sphinx. Patch by Dong-hee Na.

0 commit comments

Comments
 (0)