mirror of
https://github.com/readthedocs/sphinx-autoapi
synced 2024-11-17 21:25:35 +00:00
Added type annotation support to autodoc directives
This commit is contained in:
parent
b90284f0fe
commit
cac774c072
@ -92,6 +92,16 @@ class AutoapiFunctionDocumenter(AutoapiDocumenter, autodoc.FunctionDocumenter):
|
|||||||
def format_args(self):
|
def format_args(self):
|
||||||
return "(" + self.object.args + ")"
|
return "(" + self.object.args + ")"
|
||||||
|
|
||||||
|
def format_signature(self):
|
||||||
|
# Set "introspected" attributes at the last possible minute
|
||||||
|
if not self.args:
|
||||||
|
self.args = self.object.args
|
||||||
|
|
||||||
|
if not self.retann:
|
||||||
|
self.retann = self.object.return_annotation
|
||||||
|
|
||||||
|
return super(AutoapiFunctionDocumenter, self).format_signature()
|
||||||
|
|
||||||
|
|
||||||
class AutoapiClassDocumenter(AutoapiDocumenter, autodoc.ClassDocumenter):
|
class AutoapiClassDocumenter(AutoapiDocumenter, autodoc.ClassDocumenter):
|
||||||
objtype = "apiclass"
|
objtype = "apiclass"
|
||||||
@ -131,6 +141,16 @@ class AutoapiMethodDocumenter(AutoapiDocumenter, autodoc.MethodDocumenter):
|
|||||||
def format_args(self):
|
def format_args(self):
|
||||||
return "(" + self.object.args + ")"
|
return "(" + self.object.args + ")"
|
||||||
|
|
||||||
|
def format_signature(self):
|
||||||
|
# Set "introspected" attributes at the last possible minute
|
||||||
|
if not self.args:
|
||||||
|
self.args = self.object.args
|
||||||
|
|
||||||
|
if not self.retann:
|
||||||
|
self.retann = self.object.return_annotation
|
||||||
|
|
||||||
|
return super(AutoapiMethodDocumenter, self).format_signature()
|
||||||
|
|
||||||
def import_object(self):
|
def import_object(self):
|
||||||
result = super(AutoapiMethodDocumenter, self).import_object()
|
result = super(AutoapiMethodDocumenter, self).import_object()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user