27
27
from sphinx .writers .html import HTMLTranslator
28
28
from sphinx .writers .text import TextWriter , TextTranslator
29
29
from sphinx .writers .latex import LaTeXTranslator
30
- from sphinx .domains .python import PyModulelevel , PyClassmember
30
+
31
+ try :
32
+ from sphinx .domains .python import PyFunction , PyMethod
33
+ except ImportError :
34
+ from sphinx .domains .python import PyClassmember as PyMethod
35
+ from sphinx .domains .python import PyModulelevel as PyFunction
31
36
32
37
# Support for checking for suspicious markup
33
38
@@ -142,17 +147,18 @@ def needs_arglist(self):
142
147
return False
143
148
144
149
145
- class PyDecoratorFunction (PyDecoratorMixin , PyModulelevel ):
150
+ class PyDecoratorFunction (PyDecoratorMixin , PyFunction ):
146
151
def run (self ):
147
152
# a decorator function is a function after all
148
153
self .name = 'py:function'
149
- return PyModulelevel .run (self )
154
+ return PyFunction .run (self )
150
155
151
156
152
- class PyDecoratorMethod (PyDecoratorMixin , PyClassmember ):
157
+ # TODO: Use sphinx.domains.python.PyDecoratorMethod when possible
158
+ class PyDecoratorMethod (PyDecoratorMixin , PyMethod ):
153
159
def run (self ):
154
160
self .name = 'py:method'
155
- return PyClassmember .run (self )
161
+ return PyMethod .run (self )
156
162
157
163
158
164
class PyCoroutineMixin (object ):
@@ -162,19 +168,19 @@ def handle_signature(self, sig, signode):
162
168
return ret
163
169
164
170
165
- class PyCoroutineFunction (PyCoroutineMixin , PyModulelevel ):
171
+ class PyCoroutineFunction (PyCoroutineMixin , PyFunction ):
166
172
def run (self ):
167
173
self .name = 'py:function'
168
- return PyModulelevel .run (self )
174
+ return PyFunction .run (self )
169
175
170
176
171
- class PyCoroutineMethod (PyCoroutineMixin , PyClassmember ):
177
+ class PyCoroutineMethod (PyCoroutineMixin , PyMethod ):
172
178
def run (self ):
173
179
self .name = 'py:method'
174
- return PyClassmember .run (self )
180
+ return PyMethod .run (self )
175
181
176
182
177
- class PyAbstractMethod (PyClassmember ):
183
+ class PyAbstractMethod (PyMethod ):
178
184
179
185
def handle_signature (self , sig , signode ):
180
186
ret = super (PyAbstractMethod , self ).handle_signature (sig , signode )
@@ -184,7 +190,7 @@ def handle_signature(self, sig, signode):
184
190
185
191
def run (self ):
186
192
self .name = 'py:method'
187
- return PyClassmember .run (self )
193
+ return PyMethod .run (self )
188
194
189
195
190
196
# Support for documenting version of removal in deprecations
0 commit comments