# {{ language }} API Reference

{% for module in modules | sort(attribute='module_path') -%}
- [{{ module.module_path }}](#{{ module.module_path | lower | replace('/', '-') | replace('.', '-') | regex_replace('[^a-z0-9\\-_]', '') | regex_replace('-+', '-') | trim('-') }})
{% endfor %}

{% for module in modules | sort(attribute='module_path') -%}
## {{ module.module_path }}

{% if module.module_docstring -%}
{{ module.module_docstring | dedent }}

{% endif -%}

{# Constants section #}
{% if module.constants -%}
### Constants

{% for constant_name, constant_node in module.constants -%}
#### {{ constant_name }}

{% endfor -%}
{% endif -%}

{# Types section #}
{% for typ in module.types | sort(attribute='simple_name') -%}
### {{ typ.simple_name }}

```go
{{ typ.kind }} {{ typ.simple_name }}

```

{% if typ.docstring -%}
{{ typ.docstring | dedent }}

{% endif -%}
{% endfor -%}

{# Functions section #}
{% set valid_functions = module.functions | rejectattr('is_method') | selectattr('simple_name') | reject('match', '^(anonymous|default)$', attribute='simple_name') | reject('match', '^.{256,}$', attribute='simple_name') | list -%}
{% if valid_functions -%}
### Functions

{% for func in valid_functions | sort(attribute='simple_name') -%}
#### {{ func.simple_name }}

```go
func {{ func.simple_name }}({{ func.parameters | join(', ') }})
{%- if func.return_type %} {{ func.return_type }}{% endif %}

```

{% if func.docstring -%}
{{ func.docstring | dedent }}

{% endif -%}
{% endfor -%}
{% endif -%}

{# Classes (structs in Go) #}
{% for cls in module.classes | sort(attribute='simple_name') -%}
### {{ cls.simple_name }}

```go
type {{ cls.simple_name }} struct

```

{% if cls.docstring -%}
{{ cls.docstring | dedent }}

{% endif -%}

{# Methods for this type #}
{% set type_methods = module.functions | selectattr('is_method') | list -%}
{% set valid_methods = type_methods | selectattr('simple_name') | reject('match', '^(anonymous|default)$', attribute='simple_name') | list -%}
{% if valid_methods -%}
#### Methods

{% for method in valid_methods | sort(attribute='simple_name') -%}
##### {{ method.simple_name }}

```go
func (receiver) {{ method.simple_name }}({{ method.parameters | join(', ') }})
{%- if method.return_type %} {{ method.return_type }}{% endif %}

```

{% if method.docstring -%}
{{ method.docstring | dedent }}

{% endif -%}
{% endfor -%}
{% endif -%}
{% endfor -%}
{% endfor -%}
