mirror of
https://github.com/readthedocs/sphinx-autoapi
synced 2024-11-19 15:25:31 +00:00
Add parameters to output
This commit is contained in:
parent
8819b46a2f
commit
808c1a090f
@ -1,6 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
from collections import defaultdict
|
|
||||||
import json
|
import json
|
||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
from sphinx.util.osutil import ensuredir
|
from sphinx.util.osutil import ensuredir
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ class GoDomain(AutoAPIDomain):
|
|||||||
type
|
type
|
||||||
Set the object class
|
Set the object class
|
||||||
|
|
||||||
items
|
consts, types, vars, funcs
|
||||||
Recurse into :py:meth:`create_class` to create child object
|
Recurse into :py:meth:`create_class` to create child object
|
||||||
instances
|
instances
|
||||||
|
|
||||||
@ -116,7 +116,11 @@ class GoBase(AutoAPIBase):
|
|||||||
# Second level
|
# Second level
|
||||||
self.imports = obj.get('imports', [])
|
self.imports = obj.get('imports', [])
|
||||||
self.children = []
|
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', '')
|
self.docstring = obj.get('doc', '')
|
||||||
|
|
||||||
# Go Specific
|
# Go Specific
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
.. go:{{ obj.ref_type }}:: {{ obj.name }}
|
.. go:{{ obj.ref_type }}:: {{ obj.name }}
|
||||||
|
{%- if obj.type == 'func' -%}
|
||||||
|
({{ obj.parameters|map(attribute='name')|join(', ') }})
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
{% macro render() %}{{ obj.docstring }}{% endmacro %}
|
{% macro render() %}{{ obj.docstring }}{% endmacro %}
|
||||||
{{ render()|indent(4) }}
|
{{ render()|indent(4) }}
|
||||||
|
|
||||||
{%- for param in obj.parameters %}
|
{% for param in obj.parameters %}
|
||||||
:param {{ param.name }}: {{ param.desc }}
|
:param {{ param.name }}:
|
||||||
{%- if param.type %}
|
|
||||||
:type {{ param.name }}: {{ param.type }}
|
:type {{ param.name }}: {{ param.type }}
|
||||||
{%- endif %}
|
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
{%- if obj.returns %}
|
{%- if obj.returns %}
|
||||||
:rtype: {{ obj.returns.id }}
|
:rtype: {{ obj.returns.id }}
|
||||||
|
Loading…
Reference in New Issue
Block a user