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
@@ -271,17 +276,18 @@ def needs_arglist(self):
271
276
return False
272
277
273
278
274
- class PyDecoratorFunction (PyDecoratorMixin , PyModulelevel ):
279
+ class PyDecoratorFunction (PyDecoratorMixin , PyFunction ):
275
280
def run (self ):
276
281
# a decorator function is a function after all
277
282
self .name = 'py:function'
278
- return PyModulelevel .run (self )
283
+ return PyFunction .run (self )
279
284
280
285
281
- class PyDecoratorMethod (PyDecoratorMixin , PyClassmember ):
286
+ # TODO: Use sphinx.domains.python.PyDecoratorMethod when possible
287
+ class PyDecoratorMethod (PyDecoratorMixin , PyMethod ):
282
288
def run (self ):
283
289
self .name = 'py:method'
284
- return PyClassmember .run (self )
290
+ return PyMethod .run (self )
285
291
286
292
287
293
class PyCoroutineMixin (object ):
@@ -298,31 +304,31 @@ def handle_signature(self, sig, signode):
298
304
return ret
299
305
300
306
301
- class PyCoroutineFunction (PyCoroutineMixin , PyModulelevel ):
307
+ class PyCoroutineFunction (PyCoroutineMixin , PyFunction ):
302
308
def run (self ):
303
309
self .name = 'py:function'
304
- return PyModulelevel .run (self )
310
+ return PyFunction .run (self )
305
311
306
312
307
- class PyCoroutineMethod (PyCoroutineMixin , PyClassmember ):
313
+ class PyCoroutineMethod (PyCoroutineMixin , PyMethod ):
308
314
def run (self ):
309
315
self .name = 'py:method'
310
- return PyClassmember .run (self )
316
+ return PyMethod .run (self )
311
317
312
318
313
- class PyAwaitableFunction (PyAwaitableMixin , PyClassmember ):
319
+ class PyAwaitableFunction (PyAwaitableMixin , PyFunction ):
314
320
def run (self ):
315
321
self .name = 'py:function'
316
- return PyClassmember .run (self )
322
+ return PyFunction .run (self )
317
323
318
324
319
- class PyAwaitableMethod (PyAwaitableMixin , PyClassmember ):
325
+ class PyAwaitableMethod (PyAwaitableMixin , PyMethod ):
320
326
def run (self ):
321
327
self .name = 'py:method'
322
- return PyClassmember .run (self )
328
+ return PyMethod .run (self )
323
329
324
330
325
- class PyAbstractMethod (PyClassmember ):
331
+ class PyAbstractMethod (PyMethod ):
326
332
327
333
def handle_signature (self , sig , signode ):
328
334
ret = super (PyAbstractMethod , self ).handle_signature (sig , signode )
@@ -332,7 +338,7 @@ def handle_signature(self, sig, signode):
332
338
333
339
def run (self ):
334
340
self .name = 'py:method'
335
- return PyClassmember .run (self )
341
+ return PyMethod .run (self )
336
342
337
343
338
344
# Support for documenting version of removal in deprecations
0 commit comments