{# Function Card Macro Renders a function as an information-rich collapsible card. Shows: icon, name, param count, return type, description preview. Uses unified api-card classes from autodoc CSS modules. #} {% macro function_card(func) %} {# Use normalized param_count and return_type filters #} {% set func_param_count = func | param_count %} {% set func_return_type = func | return_type %} {% set is_async = func.metadata.is_async | default(false) %} {% set first_sentence = ((func.description or '') | truncate(100, True, '…')) %}
{# Status dot indicator (green for functions) #} {# Name + count + return type #}
{{ func.name }} {# Parameter count badge #} {{ func_param_count }} {# Return type with arrow #} {{ func_return_type | truncate(25, True, '…') }} {# Toggle indicator #} {{ icon('caret-down', size=14) }}
{# Description preview on second line #} {% if first_sentence %} {{ first_sentence }} {% endif %}
{# Async badge if applicable #} {% if is_async %}
async
{% endif %}
{# Full signature #} {% set element = func %} {% include 'api-reference/partials/signature.html' %} {# Full description (markdown rendered) #} {% if func.description %}
{{ func.description | markdownify | safe }}
{% endif %} {# Parameters, Returns, Raises #} {% set element = func %} {% include 'api-reference/partials/parameters-table.html' %} {% set element = func %} {% include 'api-reference/partials/returns-section.html' %} {% set element = func %} {% include 'api-reference/partials/raises-list.html' %} {# Examples #} {% if func.metadata.examples %}

Examples

{% for example in func.metadata.examples %}
Python
{{ example }}
{% endfor %}
{% endif %}
{% endmacro %}