{#
  SPDX-License-Identifier: Apache-2.0
  SPDX-FileCopyrightText: 2020 The Gleam contributors
#}
{% extends "documentation_layout.html" %}

{% block sidebar_content %}
{% if !types.is_empty() %}
<h2>Types</h2>
<ul>
  {% for typ in types %}
  <li><a href="#{{ typ.name }}">{{ typ.name }}</a></li>
  {% endfor %}
</ul>
{% endif %}

{% if !values.is_empty() %}
<h2>Values</h2>
<ul>
  {% for value in values %}
  <li><a href="#{{ value.name }}">{{ value.name }}</a></li>
  {% endfor %}
</ul>
{% endif %}
{% endblock %}

{% block content %}
<h1 id="module-name" class="module-name">
  <a href="#module-name">{{ module_name }}</a>
  <svg class="icon icon-gleam-chasse"><use xlink:href="#icon-gleam-chasse"></use></svg>
</h1>
{{ documentation|safe }}

{% if !types.is_empty() %}
<section class="module-members">
  <h1 id="module-types" class="module-member-kind">
    <a href="#module-types">Types</a>
    <svg class="icon icon-gleam-chasse-2"><use xlink:href="#icon-gleam-chasse-2"></use></svg>
  </h1>

  {% for typ in types %}
  <div class="member">
    <div class="member-name">
      <h2 id="{{ typ.name }}">
        <a href="#{{ typ.name }}">
          {{ typ.name }}
        </a>
      </h2>{% if typ.opaque %} <span class="visibility-tag">opaque</span> {% endif %}
      {% if !typ.source_url.is_empty() %}
      <a class="member-source" alt="View Source" title="View Source" href="{{ typ.source_url|safe }}">
        &lt;/&gt;
      </a>
      {% endif %}
    </div>
    {% if !typ.deprecation_message.is_empty() %}
    <p>
      <b>Deprecated:</b> {{ typ.deprecation_message }}
    </p>
    {% endif %}
    <div class="custom-type-constructors">
      <div class="rendered-markdown">{{ typ.documentation|safe }}</div>
      <pre><code class="hljs hljs-ignore">{{ typ.definition|safe }}</code></pre>
      {% if !typ.constructors.is_empty() %}
      <h3>
        Constructors
      </h3>
      <ul class="constructor-list">
        {% for constructor in typ.constructors %}
        <li class="constructor-item">
          <div class="constructor-row">
            <svg class="icon icon-star"><use xlink:href="#icon-star"></use></svg>
            <pre class="constructor-name"><code class="hljs hljs-ignore">{{ constructor.definition|safe }}</code></pre>
          </div>

          <div class="constructor-item-docs">
            {{ constructor.documentation|safe }}

            {% if !constructor.arguments.is_empty() %}
            <h4>
              Arguments
            </h4>

            <dl class="constructor-argument-list">
            {% for argument in constructor.arguments %}
              <dt class="constructor-argument-label">
                {{ argument.name }}
              </dt>
              <dd class="constructor-argument-doc">
                {{ argument.doc|safe }}
              </dd>
            {% endfor %}
            </dl>
            {% endif %}
          </div>
        </li>
        {% endfor %}
      </ul>
      {% endif %}
    </div>
  </div>
  {% endfor %}
</section>
{% endif %}

{% if !values.is_empty() %}
<section class="module-members">
  <h1 id="module-values" class="module-member-kind">
    <a href="#module-values">Values</a>
    <svg class="icon icon-gleam-chasse"><use xlink:href="#icon-gleam-chasse"></use></svg>
  </h1>
  {% for value in values %}
  <div class="member">
    <div class="member-name">
      <h2 id="{{ value.name }}">
        <a href="#{{ value.name }}">
          {{ value.name }}
        </a>
      </h2>
      {% if !value.source_url.is_empty() %}
      <a class="member-source" alt="View Source" title="View Source" href="{{ value.source_url|safe }}">
        &lt;/&gt;
      </a>
      {% endif %}
    </div>

    <pre><code class="hljs hljs-ignore">{{ value.definition|safe }}</code></pre>
    {% if !value.deprecation_message.is_empty() %}
    <p>
      <b>Deprecated:</b> {{ value.deprecation_message }}
    </p>
    {% endif %}
    <div class="rendered-markdown">{{ value.documentation|safe }}</div>
  </div>
  {% endfor %}
</section>
{% endif %}
{% endblock %}
