{% macro base_type(base) -%}
  {% if base.type %}<span class="mkapi-item-type">{% if not base.type.html.startswith("(") -%}
  ({% endif %}{{ base.type.html|safe }}{% if not base.type.html.startswith("(") %}){% endif %}</span>{% endif %}
{%- endmacro %}

{%- macro object_type(object) -%}
  {% if object.type %}<span class="mkapi-item-type"> &#x2192; {{ object.type.html|safe }}</span>{% endif -%}
{%- endmacro -%}

{% macro object_prefix(object, url, upper) -%}
  {% if url %}<a href="{{ url }}">{% endif -%}
    {% if upper and object.kind in ['package', 'module'] %}{{ object.prefix|upper }}{% else %}{{ object.prefix }}{% endif %}
  {%- if url %}</a>{% endif %}.
{%- endmacro %}

{% macro object_name(object, url, upper) -%}
  {% if url and object.id != url[1:] %}<a href="{{ url }}">{% endif -%}
    {% if upper and object.kind in ['package', 'module'] %}{{ object.name|upper }}{% else %}{{ object.name }}{% endif %}
  {%- if url and object.id != url[1:] %}</a>{% endif %}
{%- endmacro %}

{% macro object_signature(signature, tag='span', in_code=False) -%}
{% set args = signature.arguments -%}
{% if args is iterable -%}
{% if in_code %}</code>{% endif %}<{{ tag }} class="mkapi-object-parenthesis">(</{{ tag }}>
{%- for arg in args -%}
<{{ tag }} class="mkapi-object-signature">{{ arg }}</{{ tag }}>{% if not loop.last %}, {% endif %}
{%- endfor -%}
<{{ tag }} class="mkapi-object-parenthesis">){% if not in_code %}</{{ tag }}>{% endif %}
{%- endif %}
{%- endmacro %}

{%- macro object_body(object, prefix_url, name_url, tag, upper, filters) -%}
  {% if object.prefix and '.' not in object.qualname and 'short' not in filters -%}
    <{{ tag }} class="mkapi-object-prefix">{{ object_prefix(object, prefix_url, upper) }}</{{ tag }}>
  {%- endif -%}
    <{{ tag }} class="mkapi-object-name">{{ object_name(object, name_url, upper) }}</{{ tag }}>{{ object_signature(object.signature, tag) }}{{ object_type(object) }}
{%- endmacro -%}
