diff --git a/autoapi/domains/go.py b/autoapi/domains/go.py index 3952f3f..1d7f283 100644 --- a/autoapi/domains/go.py +++ b/autoapi/domains/go.py @@ -1,6 +1,6 @@ import os -from collections import defaultdict import json +from collections import defaultdict from sphinx.util.osutil import ensuredir @@ -43,7 +43,7 @@ class GoDomain(AutoAPIDomain): type Set the object class - items + consts, types, vars, funcs Recurse into :py:meth:`create_class` to create child object instances @@ -116,7 +116,11 @@ class GoBase(AutoAPIBase): # Second level self.imports = obj.get('imports', []) self.children = [] - self.parameters = obj.get('params', []) + self.parameters = map( + lambda n: {'name': n['name'], + 'type': n['type'].lstrip('*')}, + obj.get('parameters', []) + ) self.docstring = obj.get('doc', '') # Go Specific diff --git a/autoapi/templates/go/base_member.rst b/autoapi/templates/go/base_member.rst index f7523db..b518245 100644 --- a/autoapi/templates/go/base_member.rst +++ b/autoapi/templates/go/base_member.rst @@ -1,13 +1,14 @@ .. go:{{ obj.ref_type }}:: {{ obj.name }} +{%- if obj.type == 'func' -%} + ({{ obj.parameters|map(attribute='name')|join(', ') }}) +{%- endif %} {% macro render() %}{{ obj.docstring }}{% endmacro %} {{ render()|indent(4) }} - {%- for param in obj.parameters %} - :param {{ param.name }}: {{ param.desc }} - {%- if param.type %} + {% for param in obj.parameters %} + :param {{ param.name }}: :type {{ param.name }}: {{ param.type }} - {%- endif %} {%- endfor %} {%- if obj.returns %} :rtype: {{ obj.returns.id }}