{{ log.debug("Rendering returns section") }}

{% import "language.html" as lang with context %}

{% if config.docstring_section_style == "table" %}
  {% block table_style scoped %}
  {% set name_column = section.value|selectattr("name")|any %}
  <p><strong>{{ section.title or lang.t("Returns:") }}</strong></p>
  <table>
    <thead>
      <tr>
        {% if name_column %}<th>{{ lang.t("Name") }}</th>{% endif %}
        <th>{{ lang.t("Type") }}</th>
        <th>{{ lang.t("Description") }}</th>
      </tr>
    </thead>
    <tbody>
      {% for returns in section.value %}
        <tr>
          {% if name_column %}<td>{% if returns.name %}<code>{{ returns.name }}</code>{% endif %}</td>{% endif %}
          <td>
            {% if returns.annotation %}
              {% with expression = returns.annotation %}
                <code>{% include "expression.html" with context %}</code>
              {% endwith %}
            {% endif %}
          </td>
          <td>
            <div class="doc-md-description">
              {{ returns.description|convert_markdown(heading_level, html_id) }}
            </div>
          </td>
        </tr>
      {% endfor %}
    </tbody>
  </table>
  {% endblock table_style %}
{% elif config.docstring_section_style == "list" %}
  {% block list_style scoped %}
  <p>{{ section.title or lang.t("Returns:") }}</p>
  <ul>
    {% for returns in section.value %}
      <li class="field-body">
        {% if returns.name %}<b><code>{{ returns.name }}</code></b>{% endif %}
        {% if returns.annotation %}
          {% with expression = returns.annotation %}
            {% if returns.name %} ({% endif %}
            <code>{% include "expression.html" with context %}</code>
            {% if returns.name %}){% endif %}
          {% endwith %}
        {% endif %}
        –
        <div class="doc-md-description">
          {{ returns.description|convert_markdown(heading_level, html_id) }}
      </div>
      </li>
    {% endfor %}
  </ul>
  {% endblock list_style %}
{% elif config.docstring_section_style == "spacy" %}
  {% block spacy_style scoped %}
  <p class="doc-section-head">{{ (section.title or lang.t("Returns:")) }}</p>
  <dl class="doc-field-list">
    {% for returns in section.value %}
      <dt class="doc-field-term">
        {% if returns.name %}
          <code>{{ returns.name }}</code>
        {% elif returns.annotation %}
          <span class="doc-returns-annotation">
            {% with expression = returns.annotation %}
              <code>{% include "expression.html" with context %}</code>
            {% endwith %}
          </span>
        {% endif %}
      </dt>
      <dd class="doc-field-def doc-returns-details">
        <div class="doc-md-description">
          {{ returns.description|convert_markdown(heading_level, html_id) }}
        </div>
        {% if returns.name and returns.annotation %}
          <p>
            <span class="doc-returns-annotation">
              <span class="doc-param-key">{{ lang.t("TYPE:") }}</span>
              {% with expression = returns.annotation %}
                <code>{% include "expression.html" with context %}</code>
              {% endwith %}
            </span>
          </p>
        {% endif %}
      </dd>
      {% endfor %}
  </dl>
  {% endblock spacy_style %}
{% endif %}
