@@ -98,7 +98,7 @@ def format_signature(self, **kwargs):
98
98
99
99
100
100
class AutoapiFunctionDocumenter (
101
- AutoapiDocumenter , autodoc .FunctionDocumenter , _AutoapiDocstringSignatureMixin
101
+ AutoapiDocumenter , _AutoapiDocstringSignatureMixin , autodoc .FunctionDocumenter
102
102
):
103
103
objtype = "apifunction"
104
104
directivetype = "function"
@@ -147,9 +147,7 @@ def format_args(self, **kwargs):
147
147
return "(" + to_format + ")"
148
148
149
149
150
- class AutoapiClassDocumenter (
151
- AutoapiDocumenter , autodoc .ClassDocumenter , _AutoapiDocstringSignatureMixin
152
- ):
150
+ class AutoapiClassDocumenter (AutoapiDocumenter , autodoc .ClassDocumenter ):
153
151
objtype = "apiclass"
154
152
directivetype = "class"
155
153
doc_as_attr = False
@@ -174,9 +172,18 @@ def add_directive_header(self, sig):
174
172
bases = ", " .join (f":class:`{ base } `" for base in self .object .bases )
175
173
self .add_line (f" Bases: { bases } " , sourcename )
176
174
175
+ def format_signature (self , ** kwargs ):
176
+ # Set "manual" attributes at the last possible moment.
177
+ # This is to let a manual entry or docstring searching happen first,
178
+ # and falling back to the discovered signature only when necessary.
179
+ if self .args is None :
180
+ self .args = self .object .args
181
+
182
+ return super ().format_signature (** kwargs )
183
+
177
184
178
185
class AutoapiMethodDocumenter (
179
- AutoapiDocumenter , autodoc .MethodDocumenter , _AutoapiDocstringSignatureMixin
186
+ AutoapiDocumenter , _AutoapiDocstringSignatureMixin , autodoc .MethodDocumenter
180
187
):
181
188
objtype = "apimethod"
182
189
directivetype = "method"
@@ -230,16 +237,16 @@ def add_directive_header(self, sig):
230
237
autodoc .ClassLevelDocumenter .add_directive_header (self , sig )
231
238
232
239
sourcename = self .get_sourcename ()
233
- if self .options .annotation and self .options .annotation is not autodoc .SUPPRESS :
234
- self .add_line (f" :type: { self .options .annotation } " , sourcename )
235
-
236
240
for property_type in (
237
241
"abstractmethod" ,
238
242
"classmethod" ,
239
243
):
240
244
if property_type in self .object .properties :
241
245
self .add_line (f" :{ property_type } :" , sourcename )
242
246
247
+ if self .object .annotation :
248
+ self .add_line (f" :type: { self .object .annotation } " , sourcename )
249
+
243
250
244
251
class AutoapiDataDocumenter (AutoapiDocumenter , autodoc .DataDocumenter ):
245
252
objtype = "apidata"
@@ -254,14 +261,16 @@ def add_directive_header(self, sig):
254
261
autodoc .ModuleLevelDocumenter .add_directive_header (self , sig )
255
262
sourcename = self .get_sourcename ()
256
263
if not self .options .annotation :
257
- # TODO: Change sphinx to allow overriding of object description
258
264
if self .object .value is not None :
259
- self .add_line (f" :annotation: = { self .object .value } " , sourcename )
265
+ self .add_line (f" :value: { self .object .value } " , sourcename )
260
266
elif self .options .annotation is autodoc .SUPPRESS :
261
267
pass
262
268
else :
263
269
self .add_line (f" :annotation: { self .options .annotation } " , sourcename )
264
270
271
+ if self .object .annotation :
272
+ self .add_line (f" :type: { self .object .annotation } " , sourcename )
273
+
265
274
266
275
class AutoapiAttributeDocumenter (AutoapiDocumenter , autodoc .AttributeDocumenter ):
267
276
objtype = "apiattribute"
@@ -277,14 +286,16 @@ def add_directive_header(self, sig):
277
286
autodoc .ClassLevelDocumenter .add_directive_header (self , sig )
278
287
sourcename = self .get_sourcename ()
279
288
if not self .options .annotation :
280
- # TODO: Change sphinx to allow overriding of object description
281
289
if self .object .value is not None :
282
- self .add_line (f" :annotation: = { self .object .value } " , sourcename )
290
+ self .add_line (f" :value: { self .object .value } " , sourcename )
283
291
elif self .options .annotation is autodoc .SUPPRESS :
284
292
pass
285
293
else :
286
294
self .add_line (f" :annotation: { self .options .annotation } " , sourcename )
287
295
296
+ if self .object .annotation :
297
+ self .add_line (f" :type: { self .object .annotation } " , sourcename )
298
+
288
299
289
300
class AutoapiModuleDocumenter (AutoapiDocumenter , autodoc .ModuleDocumenter ):
290
301
objtype = "apimodule"
0 commit comments