{#-
Class Methods Component

Renders class methods with comprehensive documentation including
parameters, returns, raises, examples, and inherited methods.
-#}

{% from 'macros/safe_macros.md.jinja2' import safe_section, safe_render, safe_for, rubric_shell %}
{% from 'macros/code_blocks.md.jinja2' import signature_block %}
{% from 'macros/parameter_table.md.jinja2' import parameter_table %}

{% set all_methods = item.children | selectattr('element_type', 'equalto', 'method') | list %}
{% set own_methods = all_methods | rejectattr('metadata.synthetic') | list %}
{% set inherited_methods = all_methods | selectattr('metadata.synthetic') | list %}

{% if own_methods %}
{% call safe_section("class_methods") %}
{% call rubric_shell() %}
## Methods
{% endcall %}

{% call(method_item) safe_for(own_methods, "*No methods found.*") %}
{% call safe_render("method", method_item) %}
{% if not method_item.name.startswith('_') or method_item.name.startswith('__') %}

#### `{{ method_item.name }}`{% if method_item.metadata.is_async %} @async{% endif %}{% if method_item.metadata.is_classmethod %} @classmethod{% endif %}{% if method_item.metadata.is_staticmethod %} @staticmethod{% endif %}

{{ signature_block(method_item.metadata.signature | default(''), 'method') }}

{% if method_item.description %}
{{ method_item.description | trim }}

{% else %}
*No description provided.*

{% endif %}
{% if method_item.metadata.parsed_doc.deprecated %}
:::{warning} Deprecated
{{- method_item.metadata.parsed_doc.deprecated -}}
:::

{% endif %}
{% if method_item.metadata.is_async %}
:::{info} Async Method
This is an asynchronous method. Use `await` when calling.
:::

{% endif %}
{#- Parameters section -#}
{% if method_item.metadata.args %}
{{ parameter_table(method_item.metadata.args, "Parameters", show_types=true, show_defaults=true) }}

{% endif %}
{#- Returns section -#}
{% if method_item.metadata.returns %}
{% call rubric_shell() %}
**Returns**
{% endcall %}

`{{ method_item.metadata.returns }}`{% if method_item.metadata.parsed_doc.returns %} - {{ method_item.metadata.parsed_doc.returns }}{% endif %}

{% endif %}

{#- Include shared documentation components -#}
{% with item = method_item %}
{% include 'python/partials/method_raises.md.jinja2' %}
{% include 'python/partials/method_examples.md.jinja2' %}
{% include 'python/partials/method_notes.md.jinja2' %}
{% endwith %}

{% if method_item.metadata.parsed_doc.see_also %}
**See Also:** {%- for ref in method_item.metadata.parsed_doc.see_also -%}{{- ref -}}{%- if not loop.last -%}, {%- endif -%}{%- endfor -%}
{% endif %}
{% endif %}
{% endcall %}
{% endcall %}
{% endcall %}
{% endif %}

{#- Inherited methods section -#}
{% if inherited_methods %}
{% call safe_section("inherited_methods") %}
## Inherited Members

::::{dropdown} {{ inherited_methods | length }} inherited members (click to expand)
:open: false

{% for base_class, methods in inherited_methods | groupby('metadata.inherited_from') %}
**From `{{ base_class.split('.')[-1] }}`:**

{% for method in methods %}
{% if not method.name.startswith('_') or method.name.startswith('__') %}
- **`{{ method.name }}`**{% if method.metadata.is_async %} (async){% endif %}{% if method.metadata.is_classmethod %} (classmethod){% endif %}{% if method.metadata.is_staticmethod %} (staticmethod){% endif %}
  - {{ method.description | safe_text }}
{% endif %}
{% endfor %}

{% endfor %}

::::
{% endcall %}
{% endif %}
