<!--
SPDX-FileCopyrightText: 2021 GNOME Foundation

SPDX-License-Identifier: Apache-2.0 OR GPL-3.0-or-later
-->

{% extends "base.html" %}

{% block title %}{{ namespace.name }} &ndash; {{ namespace.version }}{% endblock %}

{% block meta_other %}
  <meta property="og:title" content="{{ namespace.name }}-{{ namespace.version }}"/>
  <meta property="og:description" content="Reference for {{ namespace.name }}-{{ namespace.version }}"/>
  <meta name="twitter:title" content="{{ namespace.name }}-{{ namespace.version }}"/>
  <meta name="twitter:description" content="Reference for {{ namespace.name }}-{{ namespace.version }}"/>
{% endblock %}

{% block sidebar %}
<div class="section">
  <h5>Sections</h5>
  <div class="links">
  {% macro section_link(elements, section_id, section_title) -%}
  {% if elements|length > 0 %}
    <a href="#{{ section_id }}">{{ section_title }}</a>
  {% endif %}
  {%- endmacro %}

  {{ section_link(symbols.classes, "classes", "Classes") }}
  {{ section_link(symbols.interfaces, "interfaces", "Interfaces") }}
  {{ section_link(symbols.structs, "structs", "Structs") }}
  {{ section_link(symbols.unions, "unions", "Unions") }}
  {{ section_link(symbols.aliases, "aliases", "Aliases") }}
  {{ section_link(symbols.enums, "enums", "Enumerations") }}
  {{ section_link(symbols.bitfields, "bitfields", "Bitfields") }}
  {{ section_link(symbols.domains, "domains", "Error Domains") }}
  {{ section_link(symbols.callbacks, "callbacks", "Callbacks") }}
  {{ section_link(symbols.functions, "functions", "Functions") }}
  {{ section_link(symbols.function_macros, "function_macros", "Function Macros") }}
  {{ section_link(symbols.constants, "constants", "Constants") }}
  </div>
</div>
{% if CONFIG.dependencies|length > 0 %}
<div class="section">
  <h5>Dependencies</h5>
  <div class="links">
  {% for gir_name, dep in CONFIG.dependencies.items() %}
    <a href="{{ dep.docs_url }}" class="external">{{ dep.name }}</a>
  {% endfor %}
  </div>
</div>
{% endif %}
{% endblock %}

{% block content %}
<section id="main" class="content">
  <header>
    <h3>Namespace</h3>
    <h1>{{ namespace.name }} &ndash; {{ namespace.version }}</h1>

    <div class="description">
      <p>{{ CONFIG.description|escape }}</p>
    </div>

    <div class="meta info">
      <table>
        <tr><td><em>Version</em></td><td>{{ CONFIG.version }}</td></tr>
        <tr><td><em>Authors</em></td><td>{{ CONFIG.authors }}</td></tr>
        <tr><td><em>License</em></td><td>{{ CONFIG.license }}</td></tr>
        <tr><td><em>Website</em></td><td><a href="{{ CONFIG.website_url }}" class="external">{{ CONFIG.website_url }}</a></td></tr>
        <tr><td><em>Source</em></td><td><a href="{{ CONFIG.browse_url }}" class="external">{{ CONFIG.browse_url }}</a></td></tr>
      </table>
    </div>

    <div class="meta build toggle-wrapper">
      <h4>Build</h4>

      <div class="docblock">
      <table>
        <tr><td>C headers</td><td><code>{{ repository.c_includes|join(', ') }}</code></td></tr>
        <tr><td>pkg-config files</td><td><code>{{ repository.packages|join(', ') }}</code></td></tr>
      </table>
      </div>
    </div>
  </header>

  {% if CONFIG.dependencies|length > 0 %}
  <section>
    <div class="toggle-wrapper">
      <h4 id="dependencies" style="display:flex;">
        Dependencies
        <a href="#dependencies" class="anchor"></a>
      </h4>

      <div class="docblock">
        <table>
        {% for gir_name, dep in CONFIG.dependencies.items() %}
          <tr>
            <td><strong>{{ dep.name }}</strong></td>
            <td>{{ dep.description }}</td>
          </tr>
          <tr>
            <td></td>
            <td><a href="{{ dep.docs_url }}" class="external">Browse documentation</a></td>
          </tr>
        {% endfor %}
        </table>
      </div>
    </div>
  </section>
  {% endif %}

  {% if content_files|length > 0 %}
  <section>
    <div class="toggle-wrapper">
      <h4 id="extra" style="display:flex;">
        Additional documentation
        <a href="#extra" class="anchor"></a>
      </h4>

      <div class="docblock">
        <ul>
        {% for file in content_files %}
          <li><a href="{{ file.href }}">{{ file.title }}</a></li>
        {% endfor %}
        </ul>
      </div>
    </div>
  </section>
  {% endif %}

  {% macro section_block(elements, section_id, section_title, section_fragment) -%}
  {% if elements|length > 0 %}
  <section>
    <div class="toggle-wrapper default-hide">
      <h4 id="{{ section_id }}" class="section-header" style="display:flex;">
        {{ section_title }}
        <a href="#{{ section_id }}" class="anchor"></a>
      </h4>

      <div class="docblock">
        <table style="display:block;">
          <tbody>
          {% for element in elements %}
          <tr class="section-item">
            <td><a title="{{ element.name }}" class="symbol" href="{{ section_fragment }}.{{ element.name }}.html">{{ element.name }}</a></td>
            {% if CONFIG.show_index_summary %}
            <td class="docblock-summary">{{ element.summary }}</td>
            {% endif %}
          </tr>
          {% endfor %}
          </tbody>
        </table>
      </div>
    </div>
  </section>
  {% endif %}
  {%- endmacro %}

  {{ section_block(symbols.classes, "classes", "Classes", "class") }}
  {{ section_block(symbols.interfaces, "interfaces", "Interfaces", "iface") }}
  {{ section_block(symbols.structs, "structs", "Structs", "struct") }}
  {{ section_block(symbols.unions, "unions", "Unions", "union") }}
  {{ section_block(symbols.aliases, "aliases", "Aliases", "alias") }}
  {{ section_block(symbols.enums, "enums", "Enumerations", "enum") }}
  {{ section_block(symbols.bitfields, "bitfields", "Bitfields", "flags") }}
  {{ section_block(symbols.domains, "domains", "Error Domains", "error") }}
  {{ section_block(symbols.callbacks, "callbacks", "Callbacks", "callback") }}
  {{ section_block(symbols.functions, "functions", "Functions", "func") }}
  {{ section_block(symbols.function_macros, "function_macros", "Function Macros", "func") }}
  {{ section_block(symbols.constants, "constants", "Constants", "const") }}
</section>
{% endblock %}
