Added type annotation support to autodoc directives

This commit is contained in:
Ashley Whetter 2019-04-21 22:45:29 -07:00
parent b90284f0fe
commit cac774c072

View File

@ -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()