Include methods in child class (#176)

pull/185/head
谷月轩 5 years ago committed by Ashley Whetter
parent 900072e99b
commit f6649ebde4

@ -65,7 +65,7 @@ class GoSphinxMapper(SphinxMapperBase):
_type _type
Set the object class Set the object class
consts, types, vars, funcs consts, types, vars, funcs, methods
Recurse into :py:meth:`create_class` to create child object Recurse into :py:meth:`create_class` to create child object
instances instances
@ -96,7 +96,7 @@ class GoSphinxMapper(SphinxMapperBase):
else: else:
# Recurse for children # Recurse for children
obj = cls(data, jinja_env=self.jinja_env) 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, []): for child_data in data.get(child_type, []):
obj.children += list( obj.children += list(
self.create_class( self.create_class(
@ -104,7 +104,8 @@ class GoSphinxMapper(SphinxMapperBase):
_type=child_type.replace("consts", "const") _type=child_type.replace("consts", "const")
.replace("types", "type") .replace("types", "type")
.replace("vars", "variable") .replace("vars", "variable")
.replace("funcs", "func"), .replace("funcs", "func")
.replace("methods", "method"),
) )
) )
yield obj yield obj
@ -128,6 +129,7 @@ class GoPythonMapper(PythonMapperBase):
obj.get("parameters", []), obj.get("parameters", []),
) )
self.parameters = list(temp_parameters) self.parameters = list(temp_parameters)
self.results = obj.get("results", [])
self.docstring = obj.get("doc", "") self.docstring = obj.get("doc", "")
# Go Specific # Go Specific
@ -172,6 +174,10 @@ class GoMethod(GoPythonMapper):
type = "method" type = "method"
ref_directive = "meth" ref_directive = "meth"
def __init__(self, obj, **kwargs):
super(GoMethod, self).__init__(obj, **kwargs)
self.receiver = obj.get("recv")
class GoConstant(GoPythonMapper): class GoConstant(GoPythonMapper):
type = "const" type = "const"

Loading…
Cancel
Save