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