<html>
  {% include "head.dtl" %}
  <body>
    {{ sidenav|safe }}
    <div id="main" class="nav">
      <span id="show-nav-button" class="nav" onclick="openNav()">&#9776;</span>
      <div id="content">
        <section id="top">
          <h1>{{ module.name }}</h1>
          {% if module.description != "none" %}
          <p>{{ module.description|safe }}</p>
          {% endif %}
        </section>
        {% if module.functions|length > 0 or module.types|length > 0 %}
        <!------- Summary ------->
        <section id="summary">
          <h1>Summary</h1>

          {% if module.types|length > 0 %}
          <!------- Types summary ------->
          <h2>Types</h2>
          <ul>
            {% for type in module.types %}
            <li>
              <a href="#{{ type.name }}/{{ type.arity }}">
                <span class="signature">{{ type.name }}()</span>
              </a>
            </li>
            {% endfor %}
          </ul>
          {% endif %}

          {% if module.functions|length > 0 %}
          <!------- Functions summary ------->
          <h2>Functions</h2>
          <ul>
            {% for function in module.functions %}
            <li>
              <a href="#{{ function.name }}/{{ function.arity }}">
                <span class="signature">
                  {{ function.name }}({% for arg in function.args %}{{ arg.name }}{% if not forloop.last %}, {% endif %}{% endfor %})
                </span>
              </a>
              {% if function.synopsis != "none" %}
              <div class="synopsis">{{ function.synopsis|safe }}</div>
              {% endif %}
            </li>
            {% endfor %}
          </ul>
          {% endif %}
        </section>
        {% endif %}

        {% if module.types|length > 0 %}
        <!------- Types details ------->
        <section id="types">
          <h1>Types</h1>
          {% for type in module.types %}
          <a id="{{ type.name }}/{{ type.arity }}" href="#{{ type.name }}/{{ type.arity }}">
            <h2 class="type">
              <span class="signature"> {{ type.name }}()</span>
              {% if type.description != "none" %}
              <pre class="definition">{{ type.description|safe }}</pre>
              {% endif %}
            </h2>
          </a>
          {% endfor %}
        </section>
        {% endif %}

        {% if module.functions|length > 0 %}
        <!------- Functions details ------->
        <section id="functions">
          <h1>Functions</h1>
          {% for function in module.functions %}
          <a id="{{ function.name }}/{{ function.arity }}" href="#{{ function.name }}/{{ function.arity }}">
            <h2 class="function">
              <span class="signature">
                {{ function.name }}({% for arg in function.args %}{{ arg.name }}{% if not forloop.last %}, {% endif %}{% endfor %})
              </span>
              {% if function.spec != "none" %}
              <pre class="definition">{{ function.spec }}</pre>
              {% endif %}
            </h2>
          </a>
          {% if function.description != "none" %}
          <p>{{ function.description|safe }}</p>
          {% endif %}
          {% endfor %}
        </section>
        {% endif %}
      </div>
    </div>
  </body>
</html>
