{# Class Card Macro Renders a class as an information-rich collapsible card. Shows: icon, name, badges, method/attribute counts, description preview. Uses unified api-card classes from autodoc CSS modules. Args: cls: The class DocElement to render is_first: Whether this is the first item (to auto-open) #} {% macro class_card(cls, is_first=false) %} {# Compute preview info #} {% set is_dataclass = cls.metadata.is_dataclass | default(false) %} {% set is_abstract = cls.metadata.is_abstract | default(false) %} {% set methods = (cls.children or []) | selectattr('element_type', 'eq', 'method') | list %} {% set method_count = methods | length %} {% set attrs = cls.metadata.attributes or [] %} {% set attr_count = attrs | length %} {% set total_items = method_count + attr_count %} {% set first_sentence = ((cls.description or '') | truncate(100, True, '…')) %} {% set bases = cls.metadata.bases or [] %}
{# Status dot indicator #} {# Name + inline badges #}
{{ cls.name }} {# Count badge #} {{ total_items }} {# Toggle indicator #} {{ icon('caret-down', size=14) }}
{# Description preview on second line #} {% if first_sentence %} {{ first_sentence }} {% endif %}
{# Inline type badges - dataclass, abstract #}
{% if is_dataclass %}dataclass{% endif %} {% if is_abstract %}abstract{% endif %}
{# Full description (markdown rendered) #} {% if cls.description %}
{{ cls.description | markdownify | safe }}
{% endif %} {# Inheritance #} {% if bases %}
Inherits from {% for base in bases %} {{ base }}{% if not loop.last %}, {% endif %} {% endfor %}
{% endif %} {# Class Signature #} {% set element = cls %} {% include 'api-reference/partials/signature.html' %} {# Attributes #} {% set element = cls %} {% include 'api-reference/partials/attributes-table.html' %} {# Methods #} {% set element = cls %} {% include 'api-reference/partials/method-item.html' %}
{% endmacro %}