31
31
from sphinx .util .nodes import split_explicit_title
32
32
from sphinx .writers .text import TextWriter , TextTranslator
33
33
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
35
40
36
41
# Support for checking for suspicious markup
37
42
@@ -238,17 +243,18 @@ def needs_arglist(self):
238
243
return False
239
244
240
245
241
- class PyDecoratorFunction (PyDecoratorMixin , PyModulelevel ):
246
+ class PyDecoratorFunction (PyDecoratorMixin , PyFunction ):
242
247
def run (self ):
243
248
# a decorator function is a function after all
244
249
self .name = 'py:function'
245
- return PyModulelevel .run (self )
250
+ return PyFunction .run (self )
246
251
247
252
248
- class PyDecoratorMethod (PyDecoratorMixin , PyClassmember ):
253
+ # TODO: Use sphinx.domains.python.PyDecoratorMethod when possible
254
+ class PyDecoratorMethod (PyDecoratorMixin , PyMethod ):
249
255
def run (self ):
250
256
self .name = 'py:method'
251
- return PyClassmember .run (self )
257
+ return PyMethod .run (self )
252
258
253
259
254
260
class PyCoroutineMixin (object ):
@@ -265,31 +271,31 @@ def handle_signature(self, sig, signode):
265
271
return ret
266
272
267
273
268
- class PyCoroutineFunction (PyCoroutineMixin , PyModulelevel ):
274
+ class PyCoroutineFunction (PyCoroutineMixin , PyFunction ):
269
275
def run (self ):
270
276
self .name = 'py:function'
271
- return PyModulelevel .run (self )
277
+ return PyFunction .run (self )
272
278
273
279
274
- class PyCoroutineMethod (PyCoroutineMixin , PyClassmember ):
280
+ class PyCoroutineMethod (PyCoroutineMixin , PyMethod ):
275
281
def run (self ):
276
282
self .name = 'py:method'
277
- return PyClassmember .run (self )
283
+ return PyMethod .run (self )
278
284
279
285
280
- class PyAwaitableFunction (PyAwaitableMixin , PyClassmember ):
286
+ class PyAwaitableFunction (PyAwaitableMixin , PyFunction ):
281
287
def run (self ):
282
288
self .name = 'py:function'
283
- return PyClassmember .run (self )
289
+ return PyFunction .run (self )
284
290
285
291
286
- class PyAwaitableMethod (PyAwaitableMixin , PyClassmember ):
292
+ class PyAwaitableMethod (PyAwaitableMixin , PyMethod ):
287
293
def run (self ):
288
294
self .name = 'py:method'
289
- return PyClassmember .run (self )
295
+ return PyMethod .run (self )
290
296
291
297
292
- class PyAbstractMethod (PyClassmember ):
298
+ class PyAbstractMethod (PyMethod ):
293
299
294
300
def handle_signature (self , sig , signode ):
295
301
ret = super (PyAbstractMethod , self ).handle_signature (sig , signode )
@@ -299,7 +305,7 @@ def handle_signature(self, sig, signode):
299
305
300
306
def run (self ):
301
307
self .name = 'py:method'
302
- return PyClassmember .run (self )
308
+ return PyMethod .run (self )
303
309
304
310
305
311
# Support for documenting version of removal in deprecations
0 commit comments