@@ -98,7 +98,7 @@ def format_signature(self, **kwargs):
9898
9999
100100class AutoapiFunctionDocumenter (
101- AutoapiDocumenter , autodoc .FunctionDocumenter , _AutoapiDocstringSignatureMixin
101+ AutoapiDocumenter , _AutoapiDocstringSignatureMixin , autodoc .FunctionDocumenter
102102):
103103 objtype = "apifunction"
104104 directivetype = "function"
@@ -147,9 +147,7 @@ def format_args(self, **kwargs):
147147 return "(" + to_format + ")"
148148
149149
150- class AutoapiClassDocumenter (
151- AutoapiDocumenter , autodoc .ClassDocumenter , _AutoapiDocstringSignatureMixin
152- ):
150+ class AutoapiClassDocumenter (AutoapiDocumenter , autodoc .ClassDocumenter ):
153151 objtype = "apiclass"
154152 directivetype = "class"
155153 doc_as_attr = False
@@ -174,9 +172,18 @@ def add_directive_header(self, sig):
174172 bases = ", " .join (f":class:`{ base } `" for base in self .object .bases )
175173 self .add_line (f" Bases: { bases } " , sourcename )
176174
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+
177184
178185class AutoapiMethodDocumenter (
179- AutoapiDocumenter , autodoc .MethodDocumenter , _AutoapiDocstringSignatureMixin
186+ AutoapiDocumenter , _AutoapiDocstringSignatureMixin , autodoc .MethodDocumenter
180187):
181188 objtype = "apimethod"
182189 directivetype = "method"
@@ -230,16 +237,16 @@ def add_directive_header(self, sig):
230237 autodoc .ClassLevelDocumenter .add_directive_header (self , sig )
231238
232239 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-
236240 for property_type in (
237241 "abstractmethod" ,
238242 "classmethod" ,
239243 ):
240244 if property_type in self .object .properties :
241245 self .add_line (f" :{ property_type } :" , sourcename )
242246
247+ if self .object .annotation :
248+ self .add_line (f" :type: { self .object .annotation } " , sourcename )
249+
243250
244251class AutoapiDataDocumenter (AutoapiDocumenter , autodoc .DataDocumenter ):
245252 objtype = "apidata"
@@ -254,14 +261,16 @@ def add_directive_header(self, sig):
254261 autodoc .ModuleLevelDocumenter .add_directive_header (self , sig )
255262 sourcename = self .get_sourcename ()
256263 if not self .options .annotation :
257- # TODO: Change sphinx to allow overriding of object description
258264 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 )
260266 elif self .options .annotation is autodoc .SUPPRESS :
261267 pass
262268 else :
263269 self .add_line (f" :annotation: { self .options .annotation } " , sourcename )
264270
271+ if self .object .annotation :
272+ self .add_line (f" :type: { self .object .annotation } " , sourcename )
273+
265274
266275class AutoapiAttributeDocumenter (AutoapiDocumenter , autodoc .AttributeDocumenter ):
267276 objtype = "apiattribute"
@@ -277,14 +286,16 @@ def add_directive_header(self, sig):
277286 autodoc .ClassLevelDocumenter .add_directive_header (self , sig )
278287 sourcename = self .get_sourcename ()
279288 if not self .options .annotation :
280- # TODO: Change sphinx to allow overriding of object description
281289 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 )
283291 elif self .options .annotation is autodoc .SUPPRESS :
284292 pass
285293 else :
286294 self .add_line (f" :annotation: { self .options .annotation } " , sourcename )
287295
296+ if self .object .annotation :
297+ self .add_line (f" :type: { self .object .annotation } " , sourcename )
298+
288299
289300class AutoapiModuleDocumenter (AutoapiDocumenter , autodoc .ModuleDocumenter ):
290301 objtype = "apimodule"
0 commit comments