From cac774c072a3d7e12ac89d3e5661c02eaa1f3725 Mon Sep 17 00:00:00 2001 From: Ashley Whetter Date: Sun, 21 Apr 2019 22:45:29 -0700 Subject: [PATCH] Added type annotation support to autodoc directives --- autoapi/documenters.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/autoapi/documenters.py b/autoapi/documenters.py index b2e746c..1b18b04 100644 --- a/autoapi/documenters.py +++ b/autoapi/documenters.py @@ -92,6 +92,16 @@ class AutoapiFunctionDocumenter(AutoapiDocumenter, autodoc.FunctionDocumenter): def format_args(self): 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): objtype = "apiclass" @@ -131,6 +141,16 @@ class AutoapiMethodDocumenter(AutoapiDocumenter, autodoc.MethodDocumenter): def format_args(self): 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): result = super(AutoapiMethodDocumenter, self).import_object()