{# Class Member Macro Renders a class as a collapsible card with status dot, count badge, and description. Uses the unified autodoc design system. Usage: {% from 'autodoc/partials/_macros/class-member.html' import class_member %} {{ class_member(cls, is_first=loop.first) }} Args: cls: Class DocElement to render (required) is_first: Whether this is the first item (to auto-open) #} {% macro class_member(cls, is_first=false) %} {% set cls_methods = (cls.children or []) | selectattr('element_type', 'eq', 'method') | list %} {# Attributes are stored as children with element_type='attribute', or sometimes properties #} {% set cls_attrs = (cls.children or []) | selectattr('element_type', 'eq', 'attribute') | list %} {% set cls_props = (cls.children or []) | selectattr('element_type', 'eq', 'property') | list %} {% set all_attrs = cls_attrs + cls_props %} {% set total_members = (cls_methods | length) + (all_attrs | length) %} {% set is_dataclass = cls.metadata.is_dataclass | default(false) %} {% set is_abstract = cls.metadata.is_abstract | default(false) %}
{# Status dot (yellow/amber for classes) #} {# Content wrapper #}
{{ cls.name }} {# Count badge #} {{ total_members }} {# Toggle indicator #}
{# Description preview #} {% if cls.description %} {{ cls.description | truncate(100, True, '…') }} {% endif %}
{# Badges #} {% if is_dataclass or is_abstract %} {% if is_dataclass %} dataclass {% endif %} {% if is_abstract %} abstract {% endif %} {% endif %}
{% if cls.description %}
{{ cls.description | markdownify | safe }}
{% endif %} {# Class attributes (from children with element_type='attribute' or 'property') #} {% if all_attrs %}

Attributes

{% for attr in all_attrs %} {# Attributes are DocElements with name, description, and metadata.annotation #} {% set attr_type = attr.metadata.annotation if attr.metadata else '' %} {% endfor %}
Name Type Description
{{ attr.name }} {{ attr_type }} {{ attr.description | markdownify | safe }}
{% endif %} {# Class methods - use unified members partial #} {% if cls_methods %}

Methods

{% set members = cls_methods %} {% set title = '' %} {% set member_type = 'method' %} {% set first_open = false %} {% include 'autodoc/partials/members.html' %}
{% endif %}
{% endmacro %}