From f6649ebde45225da101276076250b9120cd92bcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=B7=E6=9C=88=E8=BD=A9?= Date: Sun, 6 Oct 2019 03:39:50 +0800 Subject: [PATCH] Include methods in child class (#176) --- autoapi/mappers/go.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/autoapi/mappers/go.py b/autoapi/mappers/go.py index 5b65f5f..180c522 100644 --- a/autoapi/mappers/go.py +++ b/autoapi/mappers/go.py @@ -65,7 +65,7 @@ class GoSphinxMapper(SphinxMapperBase): _type Set the object class - consts, types, vars, funcs + consts, types, vars, funcs, methods Recurse into :py:meth:`create_class` to create child object instances @@ -96,7 +96,7 @@ class GoSphinxMapper(SphinxMapperBase): else: # Recurse for children obj = cls(data, jinja_env=self.jinja_env) - for child_type in ["consts", "types", "vars", "funcs"]: + for child_type in ["consts", "types", "vars", "funcs", "methods"]: for child_data in data.get(child_type, []): obj.children += list( self.create_class( @@ -104,7 +104,8 @@ class GoSphinxMapper(SphinxMapperBase): _type=child_type.replace("consts", "const") .replace("types", "type") .replace("vars", "variable") - .replace("funcs", "func"), + .replace("funcs", "func") + .replace("methods", "method"), ) ) yield obj @@ -128,6 +129,7 @@ class GoPythonMapper(PythonMapperBase): obj.get("parameters", []), ) self.parameters = list(temp_parameters) + self.results = obj.get("results", []) self.docstring = obj.get("doc", "") # Go Specific @@ -172,6 +174,10 @@ class GoMethod(GoPythonMapper): type = "method" ref_directive = "meth" + def __init__(self, obj, **kwargs): + super(GoMethod, self).__init__(obj, **kwargs) + self.receiver = obj.get("recv") + class GoConstant(GoPythonMapper): type = "const"