{# ================================================================================ Autodoc Members Partial (Kida-Native) ================================================================================ Renders collapsible member cards for methods, attributes, etc. With status dots, counts, return types, and internal method separation. TEMPLATE VARIABLES: - members: list of DocElements (required) - title: str (default: 'Members') - member_type: str (default: 'method') - first_open: bool (default: true) - auto-open first member Uses the `member_view` filter to normalize each member's properties, providing a consistent API regardless of how data is stored in DocElements. MemberView properties: - name, signature, description, return_type, return_description - params (tuple of ParamView with name, type, default, description) - is_async, is_property, is_classmethod, is_staticmethod, is_abstract - is_deprecated, is_private, href, decorators ================================================================================ #} {# Template configuration with defaults #} {# Filter out members with empty/falsy names - prevents bloat from malformed autodoc data #} {% let section_title = title ?? 'Members', section_member_type = member_type ?? 'method', auto_open_first = first_open ?? true, all_members = (members ?? []) | selectattr('name') | list %} {# Separate public and internal members using is_private from MemberView #} {# NOTE: Must use {% export %} to promote from loop scope to template scope #} {% let public_members = [] %} {% let internal_members = [] %} {% for el in all_members %} {% let m = el | member_view %} {% if m.name %} {% if m.is_private %} {% export internal_members = internal_members + [m] %} {% else %} {% export public_members = public_members + [m] %} {% end %} {% end %} {% end %} {# HELPER: Render a single member detailed card using MemberView #} {% def render_member(m, section_member_type, is_open=false) %}
{# Status dot #} {# Content wrapper #}
{{ m.name }} {# Parameter count badge #} {% let param_count = m.params | length %} {{ param_count }} {# Return type with arrow #} {% if m.return_type and m.return_type != 'None' %} {{ m.return_type | truncate(25, True, '…') }} {% end %} {# Toggle indicator #}
{# Description preview (for scanning) #} {% if m.description %} {{ m.description | striptags | truncate(80, True, '…') }} {% end %}
{# Badges - using MemberView properties directly #} {% let member_badges = [ 'async' if m.is_async, 'classmethod' if m.is_classmethod, 'staticmethod' if m.is_staticmethod, 'property' if m.is_property, 'abstract' if m.is_abstract, 'deprecated' if m.is_deprecated, ] | compact %} {% if member_badges | length > 0 %} {% for badge in member_badges %} {{ badge }} {% end %} {% end %}
{# Signature (copy-paste ready) #} {% if m.signature %}
{{ m.signature }}
{% end %} {# Full description - only show if truncated in header #} {% let desc_stripped = (m.description | striptags | trim) if m.description else '' %} {% if m.description and desc_stripped | length > 77 %}
{{ m.description | markdownify | safe }}
{% end %} {# Member parameters - using ParamView from MemberView.params #} {% if m.params | length > 0 %}
Parameters
{% for p in m.params %} {% end %}
Name Type Description
{{ p.name }} {{ p.type if p.type else '—' }} {{ (p.description | markdownify | safe) if p.description else '' }} {% if p.default is not none and p.default != '' %} Default: {{ p.default }} {% end %}
{% end %} {# Member return type (detailed) - only show if has description OR non-trivial type #} {% let is_nontrivial_return = m.return_type and m.return_type not in ('None', 'none', 'void', '') %} {% if m.return_description or is_nontrivial_return %}
Returns
{{ m.return_type }} {% if m.return_description %} {{ m.return_description }} {% end %}
{% end %}
{% end %} {% if all_members | length > 0 %}
{% if section_title %}

{{ section_title }}

{% end %} {# Public members #} {% if public_members | length > 0 %}
{% for m in public_members %} {{ render_member(m, section_member_type, is_open=(auto_open_first and loop.first)) }} {% end %}
{% end %} {# Internal members (collapsed by default) #} {% if internal_members | length > 0 %}
Internal Methods {{ internal_members | length }}
{% for m in internal_members %} {{ render_member(m, section_member_type) }} {% end %}
{% end %}
{% end %}