{% macro info_bar(entity, incl_src, base_url, line_info) %}
  <div class="row" id="info-bar">
    <div class="col-lg-12">
      <div class="well well-sm">
        <ul class="list-inline" style="margin-bottom:0px;display:inline">
          {% if entity.meta['author'] %}
            <li id="meta-author"><i class="fa fa-pencil"></i> {{ entity.meta['author'] }}</li>
          {% endif %}
          {% if entity.meta['date'] %}
            <li id="meta-date"><i class="fa fa-calendar-o"></i> {{ entity.meta['date'] }}</li>
          {% endif %}
          {% if entity.meta['license'] %}
            <li id="meta-license"><i class="fa fa-legal"></i> {{ entity.meta['license'] }}</li>
          {% elif projectData['license'] %}
            <li id="meta-license"><i class="fa fa-legal"></i> {{ projectData['license'] }}</li>
          {% endif %}
          {% if entity.meta['since'] %}
            <li id="meta-since"><i class="fa fa-history"></i> Since: {{ entity.meta['since'] }}</li>
          {% endif %}
          {% if entity.meta['version'] %}
            <li id="meta-version"><i class="fa fa-barcode"></i> {{ entity.meta['version'] }}</li>
          {% endif %}
          {% if entity.meta['category'] %}
            <li id="meta-category"><i class="fa fa-folder-open"></i> {{ entity.meta['category'] }}</li>
          {% endif %}

          <li id="statements"><i class="fa fa-list-ol"></i>
            <a data-toggle="tooltip"
               data-placement="bottom" data-html="true"
               title="{{ line_info }}">{{ entity.meta['num_lines'] }} statements</a>
          </li>

          {% if incl_src %}
            <li id="source-file">
              <i class="fa fa-code"></i>
              <a href="{{ base_url }}/src/{{ entity.filename }}"> Source File</a>
            </li>
          {% endif %}
        </ul>
        <ol class="breadcrumb in-well text-right">
          {% if incl_src %}
            {% for item in entity.hierarchy %}
              <li>{{ item }}</li>
            {% endfor %}
          {% else %}
            {% for item in entity.hierarchy[1:] %}
              <li>{{ item }}</li>
            {% endfor %}
          {%endif%}
          <li class="active">{{ entity.name }}</li>
        </ol>
      </div>
    </div>
  </div>
  <script>
    $(function () {
    $('[data-toggle="tooltip"]').tooltip()
    })
  </script>
{% endmacro %}


{% macro panel_contents(name, collection, anchor, panelnum, collection_url=False) %}
  {% if collection %}
    <div class="panel panel-primary">
      <div class="panel-heading text-left">
        <h3 class="panel-title">
          <a data-toggle="collapse" href="#{{ anchor }}-{{ panelnum }}">{{ name }}</a>
        </h3>
      </div>
      <div id="{{ anchor }}-{{ panelnum }}" class="panel-collapse collapse">
        <div class="list-group">
          {% for item in collection %}
            {% set name = item.name if item.name else "<em>unnamed</em>" %}
            {% set anchor_url = collection_url + "#" + item.anchor if collection_url else item.get_url() %}
            <a class="list-group-item" href="{{ anchor_url }}">{{ name }}</a>
          {% endfor %}
        </div>
      </div>
    </div>
  {% endif %}
{% endmacro %}

{% macro content_list(self, panelnum=0) %}
  {# Create the expandable panels for all the possible contents #}
  <h3>Contents</h3>
  {{ panel_contents("Common Blocks", self.common, "common", panelnum, self.get_url()) }}
  {{ panel_contents("Variables", self.variables, "vars", panelnum, self.get_url()) }}
  {{ panel_contents("Enumerations", self.enums, "enums", panelnum, self.get_url()) }}
  {{ panel_contents("Constructor", [self.constructor] if self.constructor else [], "cons", panelnum, self.get_url()) }}
  {{ panel_contents("Programs", self.programs, "progs", panelnum) }}
  {{ panel_contents("Modules", self.modules, "mods", panelnum) }}
  {{ panel_contents("Submodules", self.submodules, "submods", panelnum) }}
  {{ panel_contents("Block Data Units", self.blockdata, "blocks", panelnum) }}
  {{ panel_contents("Interfaces", self.interfaces, "inters", panelnum, self.get_url()) }}
  {{ panel_contents("Abstract Interfaces", self.absinterfaces, "absints", panelnum, self.get_url()) }}
  {{ panel_contents("Derived Types", self.types, "types", panelnum, self.get_url()) }}
  {{ panel_contents("Functions", self.functions, "funcs", panelnum, self.get_url() if self.obj != "sourcefile" else False) }}
  {{ panel_contents("Subroutines", self.subroutines, "subs", panelnum, self.get_url() if self.obj != "sourcefile" else False) }}
  {{ panel_contents("Module Functions", self.modfunctions, "modfuncs", panelnum, self.get_url()) }}
  {{ panel_contents("Module Subroutines", self.modsubroutines, "modsubs", panelnum, self.get_url()) }}
  {{ panel_contents("Module Procedures", self.modprocedures, "modprocs", panelnum, self.get_url()) }}
  {{ panel_contents("Finalization Procedures", self.finalprocs, "fins", panelnum, self.get_url()) }}
  {{ panel_contents("Type-Bound Procedures", self.boundprocs, "boundprocs", panelnum, self.get_url()) }}
  {{ panel_contents("Module Procedures", self.modprocs, "modprocs", panelnum, self.get_url()) }}
  {% if self.src %}
    <div class="panel panel-primary">
      <div class="panel-heading text-left"><h3 class="panel-title">Source Code</h3></div>
      <div class="list-group">
        <a class="list-group-item" href="{{ self.get_url() }}#src">{{ self.name }}</a>
      </div>
    </div>
  {% endif %}

  {% if not (self.constructor or self.src or
       self.iterator(
         "absinterfaces",
         "args",
         "blockdata",
         "boundprocs",
         "common",
         "enums",
         "finalprocs",
         "functions",
         "interfaces",
         "modfunctions",
         "modsubroutines",
         "modprocedures",
         "modprocs",
         "modules",
         "programs",
         "submodules",
         "subroutines",
         "types",
         "variables",
       ) | list
    ) %}
    <em>None</em>
  {% endif %}
{% endmacro %}


{% macro sidebar(project,self) %}
  <div id="sidebar">
    {{ content_list(self) }}
  </div>
{% endmacro %}

{% macro add_comma(condition) %}
  {# Insert a literal comma if condition is true #}
  {%- if condition -%},{% endif %}
{% endmacro %}

{% macro deprecated(entity) %}
  {# Add 'Deprecated' warning #}
  {%- if entity.meta['deprecated'] -%}
    <span class="label label-danger depwarn">Deprecated</span>
  {%- endif -%}
{% endmacro %}

{% macro variable_list(variables, intent=False, permission=False, summary=False, id=True) %}
  <table class="table table-striped varlist">
    <thead>
      <tr>
        <th>Type</th>
        {% if permission %}<th>Visibility</th>{% endif %}
        {% if intent %}<th>Intent</th><th>Optional</th>{% endif %}
        <th>Attributes</th>
        <th></th>
        <th>Name</th>
        {% if not intent %}<th></th><th>Initial</th>{% endif %}
        <th></th>
    </thead>
    {% set colnum = 6 + permission|int + intent|int %}
    <tbody>
      {% for var in variables %}
        <tr>
          {% if var.obj == 'variable' %}
            <td>
              <span class="anchor" {% if id %}id="{{ var.anchor }}"{% endif %}></span>
              {{ var.full_type }}{{ add_comma((intent and var.intent) or var.optional or permission or var.parameter or var.attribs) }}
            </td>
            {% if intent -%}
              <td>
                {%- if var.intent -%}
                  intent({{ var.intent }}){{ add_comma(var.optional or permission or var.parameter or var.attribs) }}
                {%- endif -%}
              </td>
              <td>{%- if var.optional -%}optional{{ add_comma(permission or var.parameter or var.attribs) }}{%- endif -%}</td>
            {%- endif %}
            {% if permission %}
              <td>{{ var.permission }}{{ add_comma(var.parameter or var.attribs) }}</td>
            {% endif %}
            <td>
              {% if var.parameter %}parameter{{ add_comma(var.attribs) }} {% endif %}
              {{ var.attribs | join(", ") }}
            </td>
            <td>::</td>
            <td><strong>{{ var.name }}</strong>{{ var.dimension }}</td>
            {% if not intent %}
              {% if var.initial -%}
                <td>{% if var.points -%} =&gt; {% else %} = {%- endif %}</td>
                <td>{{ var.initial }}</td>
              {% else %}
                <td></td>
                <td></td>
              {% endif %}
            {% endif %}
            <td>
              {% if summary -%}
                {{ var.meta['summary'] }}
              {% else %}
                {{ var.doc }}
              {% endif %}
            </td>
          {% elif var.obj == 'proc' %}
            <td colspan="{{ colnum }}">
              <small>{{ proc_summary(var,title=True,small=True) }}</small>
            </td>
          {% endif %}
        </tr>
      {% endfor %}
    </tbody>
  </table>
{% endmacro %}

{%- macro header(size, small=False) -%}
  {%- if small -%}
    <h{{ size + 2 }}>
  {%- else -%}
    <h{{ size }}>
  {%- endif -%}
{% endmacro %}

{%- macro close_header(size, small=False) -%}
  {%- if small -%}
    </h{{ size + 2 }}>
  {%- else -%}
    </h{{ size }}>
  {%- endif -%}
{%- endmacro -%}

{%- macro docstring(entity, full_docstring=True) -%}
  {# Display either the full docstring or just the summary #}
  {%- if full_docstring or not entity.visible -%}
    {{ entity.doc }}
  {%- else -%}
    {{ entity.meta["summary"] }}
  {%- endif -%}
{%- endmacro -%}

{% macro proc_summary(proc, title=True, small=False, proto=False, full_docstring=False) %}
  {# Render the summary of a procedure, to be used in lists of procedures, for example #}
  {% if title %}
    {{ header(3, small) }}
    {{ proc_line(proc,proto=proto) }}
    {% if proto %}<small>Prototype</small>{% endif %}
    {{ close_header(3, small) }}
  {% endif %}
  {% if proc.parent and proc.visible %}
    {{ meta_list(proc.meta) }}
  {% endif %}
  {{ docstring(proc, full_docstring) }}

  {{ header(4, small) }}Arguments{{ close_header(4, small) }}
  {% if proc.args %}
    {{ variable_list(proc.args, intent=True, summary=proc.visible, id=False) }}
  {% else %}
    <em>None</em>
  {% endif %}
  {% if proc.retvar %}
    {{ header(4, small) }}
    Return Value
    <small>{{ proc.retvar.full_declaration }}</small>
    {{ close_header(4, small) }}
    {{ docstring(proc.retvar, full_docstring) }}
  {% endif %}
{% endmacro %}

{% macro binding_summary(proc,title=True,small=False,proto=False) %}
  {# Render the documentation for an individual binding of a type-bound procedure #}
  {% if title %}
    {{ header(3, small) }}
    {{ proc_line(proc, proto=proto) }}
    {%- if proto -%}
      <small>Prototype</small>
    {%- endif -%}
    {{ close_header(3, small) }}
  {% endif %}
  {% if proc.parent and proc.visible %}
    {{ meta_list(proc.meta) }}
  {% endif %}
  {{ proc.doc }}

  {{ header(4, small) }}Arguments{{ close_header(4, small) }}
  {% if proc.args|length %}
    {{ variable_list(proc.args, intent=True, summary=proc.visible, id=False) }}
  {% else %}
    <em>None</em>
  {% endif %}
  {% if proc.retvar %}
    {{ header(4, small) }}
    Return Value
    <small>{{ proc.retvar.full_declaration }}</small>
    {{ close_header(4, small) }}
    {{ proc.retvar.doc }}
  {% endif %}
{% endmacro %}

{% macro bound_info(tb) %}
  <div class="panel panel-default">
    <div class="panel-heading codesum"><span class="anchor" id="{{ tb.anchor }}"></span><h3>{% if tb.generic -%}generic,{% else %}procedure{% if tb.proto -%}({% if not tb.protomatch or tb.proto.visible -%}{{ tb.proto }}{% else %}{{ tb.proto.name }}{%- endif %}){%- endif %},{%- endif %} {{ tb.permission }}{% if tb.deferred -%}, deferred{%- endif %}{% if tb.attribs -%}, {% for attrib in tb.attribs -%}{{ attrib }}{% if not loop.last -%}, {% endif %}{%- endfor %}{%- endif %} :: <strong>{{ tb.name }}</strong> {% if tb.generic or (tb.name != tb.bindings[0].name and tb.name != tb.bindings[0]) %} => {% for bind in tb.bindings -%}{% if not bind.parent or bind.visible %}{{ bind }}{% else %}{{ bind.name }}{% endif %}{% if not loop.last -%}, {% endif %}{%- endfor %}{% endif %} {% if tb.binding|length == 1 %}<small>{{ tb.bindings[0].proctype }}</small>{% endif %}
        {{ deprecated(tb) }}
    </h3></div>
    {% if tb.doc or meta_list(tb.meta)|trim|length is more_than_one %}
      <div class="panel-body">
        {{ meta_list(tb.meta) }}
        {{ tb.doc }}
      </div>
    {% endif %}
    <ul class="list-group">
      {% for bind in tb.bindings %}
        <li class="list-group-item">
          {% if tb.deferred and tb.protomatch %}
            {% if tb.proto.obj == 'interface' %}
              {{ binding_summary(tb.proto.procedure,proto=True) }}
            {% elif tb.proto.obj == 'procedure' %}
              {{ binding_summary(tb.proto,proto=True) }}
            {% endif %}
          {% elif bind.obj == 'boundprocedure' %}
            {% if bind.deferred and bind.protomatch %}
              {% if bind.proto.obj == 'interface' %}
                {{ binding_summary(bind.proto.procedure,proto=True) }}
              {% elif bind.proto.obj == 'procedure' %}
                {{ binding_summary(bind.proto,proto=True) }}
              {% endif %}
            {% else %}
              {{ binding_summary(bind.bindings[0]) }}
            {% endif %}
          {% else %}
            {% if bind.obj == 'interface' %}
              <h3>interface {{ deprecated(bind) }}</h3>
              {% if bind.doc or (meta_list(bind.meta)|trim and not bind.visible) %}
                {% if not bind.visible %}
                  {{ meta_list(bind.meta) }}
                {% endif %}
                {{ bind.meta['summary'] }}
              {% endif %}
              {{ binding_summary(bind.procedure) }}
            {% else %}
              {{ binding_summary(bind) }}
            {% endif %}
          {% endif %}
        </li>
      {% endfor %}
    </ul>
  </div>
{% endmacro %}


{% macro interface(intr, full_docstring=True) %}
  <div class="panel panel-default">
    <div class="panel-heading codesum">
      <span class="anchor" id="{{ intr.anchor }}"></span>
      <h3>{% if intr.parobj == 'module' and intr.generic %}{{ intr.permission }}{% endif %}
        interface
        {%- if intr.generic %} {{ intr }} {% endif -%}
        {{ deprecated(intr) }}
      </h3>
    </div>
    {% if intr.doc or (meta_list(intr.meta)|trim and not intr.visible) %}
      <div class="panel-body">
        {% if not intr.visible %}
          {{ meta_list(intr.meta) }}
        {% endif %}
        {{ docstring(intr, full_docstring) }}
      </div>
    {% endif %}
    <ul class="list-group">
      {% if intr.generic %}
        {% for proc in intr.routines %}
          <li class="list-group-item">
            {{ proc_summary(proc, full_docstring=full_docstring) }}
          </li>
        {% endfor %}
        {% for proc in intr.modprocs %}
          <li class="list-group-item">
            {{ proc_summary(proc.procedure, full_docstring=full_docstring) }}
          </li>
        {% endfor %}
        {%- if intr.variables -%}
          <li class="list-group-item">
            <h3>Dummy Procedures and Procedure Pointers</h3>
            {{ variable_list(intr.variables, permission=False) }}
          </li>
        {%- endif -%}
      {% else %}
        <li class="list-group-item">
          {{ proc_summary(intr.procedure, full_docstring=full_docstring) }}
        </li>
      {% endif %}
    </ul>
  </div>
{% endmacro %}

{% macro absinterface(intr) %}
  <div class="panel panel-default">
    <div class="panel-heading codesum"><span class="anchor" id="{{ intr.anchor }}"></span><h3>abstract interface
        {{ deprecated(intr) }}
    </h3></div>
    {% if intr.doc or meta_list(intr.meta)|trim %}
      <div class="panel-body">
        {{ meta_list(intr.meta) }}
        {{ intr.meta['summary'] }}
      </div>
    {% endif %}
    <ul class="list-group">
      <li class="list-group-item">
        {{ proc_summary(intr.procedure) }}
      </li>
    </ul>
  </div>
{% endmacro %}

{% macro proc_line(proc, link=True, proto=False) %}
  {% if proc.mp %}module procedure {% if not proc.parent or (proc.visible and link) %}{{ proc }}{% else %}{{ proc.name }}{% endif %} <small>{% endif -%}
  {% if (proc.parobj == 'module' or (proc.parobj == 'interface' and proc.parent.parobj == 'module')) and not proto %}{{ proc.permission }} {% endif -%}
  {{ proc.attribs | join(" ") }} {{ proc.proctype |lower }}
  {%- if not proc.parent or (proc.visible and link and not proc.mp) %} {{ proc }}{% else %} {{ proc.name }}{% endif -%}
  ({{ proc.args | join(", ") }})
  {%- if proc.proctype|lower == 'function' and proc.name != proc.retvar.name %} result({{ proc.retvar.name }}){% endif -%}
  {% if proc.bindC %} bind({{ proc.bindC }}){% endif %}
  {% if proc.mp %}</small>{% endif %}
  {{ deprecated(proc) }}
  {% if proc.module and proc.module != True and proc.module.visible %}
    {% set label = "Implementation" if proc.parobj == 'interface' else "Interface" %}
    <a href='{{ proc.module.get_url() }}'><button type="button" class="btn btn-info depwarn">{{ label }} &rarr;</button></a>
  {% endif %}
{% endmacro %}


{% macro final(proc) %}
  <div class="panel panel-default">
    <div class="panel-heading codesum">
      <span class="anchor" id="{{ proc.anchor }}"></span>
      <h3>final :: <strong>{{ proc.name }}</strong> {{ deprecated(proc) }}</h3>
    </div>
    <div class="panel-body">
      {{ meta_list(proc.meta) }}
      {{ proc.doc }}
    </div>
    <ul class="list-group">
      <li class="list-group-item">
        {{ proc_summary(proc.procedure, title=True, full_docstring=True) }}
      </li>
    </ul>
  </div>
{% endmacro %}

{% macro display_permission(item) %}
  {% if item.parobj == "module" or (item.parobj == "interface" and item.parent.parobj == "module") %}
    {{ item.permission }}
  {% endif %}
{% endmacro %}

{% macro type_summary(dtype) %}
  <div class="panel panel-default">
    <div class="panel-heading codesum">
      <span class="anchor" id="{{ dtype.anchor }}"></span>
      <h3>
        type
        {%- if dtype.parobj == 'module' %}, {{ dtype.permission }}{% endif -%}
        {%- if dtype.sequence %}, sequence {% endif -%}
        {{ dtype.attribs | join(", ") }}
        {%- if dtype.extends %}, extends({{ dtype.extends }}){% endif -%}&nbsp;::&nbsp;
        {{ dtype }}
        {{ deprecated(dtype) }}
      </h3>
    </div>
    <div class="panel-body">
      {% if not dtype.visible %}
        {{ meta_list(dtype.meta) }}
      {% endif %}
      {{ dtype.meta['summary'] }}

      {% if dtype.variables %}
        <h4>Components</h4>
        {{ variable_list(dtype.variables, permission=True, summary=True) }}
      {% endif %}

      {% if dtype.constructor %}
        <h4>Constructor</h4>
        {% if dtype.constructor.obj == 'interface' %}
          {{ docstring(dtype.constructor, full_docstring=False) }}
        {% endif %}
        <table class="table table-striped varlist">
          <tbody>
            {% if dtype.constructor.obj == 'proc' %}
              <tr>
                <td>{{ proc_line(dtype.constructor) }}</td>
                <td>{{ docstring(dtype.constructor, full_docstring=False) }}</td>
              </tr>
            {% elif dtype.constructor.obj == 'interface' %}
              {% for proc in dtype.constructor.routines|list + dtype.constructor.modprocs|map(attribute="procedure")|list %}
                <tr>
                  <td>
                    {{ display_permission(proc) }}
                    {{ proc.attribs | join(", ") }}
                    {{ proc.proctype|lower }}
                    <strong>{{ proc }}</strong>
                    ({{ proc.args | join(", ") }})
                    {% if proc.bindC -%}, bind({{ proc.bindC }}){% endif %}
                  </td>
                  <td>{{ docstring(proc, full_docstring=False) }}</td>
                </tr>
              {% endfor %}
            {% endif %}
          </tbody>
        </table>
      {% endif %}

      {% if dtype.finalprocs %}
        <h4>Finalizations Procedures</h4>
        <table class="table table-striped varlist">
          <tbody>
            {% for fin in dtype.finalprocs %}
              <tr>
                <td>final :: <strong>{{ fin.name }}</strong></td>
                <td>{{ fin.meta['summary'] }}</td>
              </tr>
            {% endfor %}
          </tbody>
        </table>
      {% endif %}

      {% if dtype.boundprocs %}
        <h4>Type-Bound Procedures</h4>
        <table class="table table-striped varlist">
          <tbody>
            {% for tb in dtype.boundprocs %}
              <tr>
                <td>
                  {% if tb.generic -%}
                    generic,
                  {% else %}
                    procedure
                    {% if tb.proto -%}
                      ({% if not tb.protomatch -%}{{ tb.proto }}{% else %}{{ tb.proto.name }}{%- endif %})
                    {%- endif %}
                    ,
                  {%- endif %}
                  {{ tb.permission }}
                  {% if tb.attribs -%}, {{ tb.attribs|join(", ") }}{%- endif %}
                  :: <strong>{{ tb }}</strong>
                  {% if tb.generic or (tb.name != tb.bindings[0].name and tb.name != tb.bindings[0]) %} =>
                    {{ tb.bindings|join(", ") }}
                  {% endif %}
                  {% if tb.bindings|length == 1 %}<small>{{ tb.bindings[0].proctype }}</small>{% endif %}
                </td>
                <td>{{ tb.meta['summary'] }}</td>
              </tr>
              {% endfor %}
          </tbody>
        </table>
      {% endif %}
    </div>
  </div>
{% endmacro %}

{% macro common_block(com) %}
  <div class="panel panel-default">
    <div class="panel-heading codesum"><span class="anchor" id="{{ com.anchor }}"></span><h3>
        <a data-toggle="popover" data-html="true" tabindex="0"
           data-trigger="focus"
           data-content="<h4>Used Elsewhere:</h4>{% for item in com.other_uses %}{% if item != com %}<a href='{{ item.get_url() }}'>{% if item.parent.name -%}{{ item.parent.name }}{%- else -%}<em>unnamed</em>{%- endif %}</a> ({% if item.parobj == 'proc' -%}{{ item.parent.proctype|lower }}{%- else -%}{{ item.parobj }}{%- endif %})<br>{% endif %}{% endfor %}">common{% if com.name %} /{{ com.name }}/{% endif %}</a>
           {{ deprecated(com) }}
    </h3></div>
    <div class="panel-body">
      {% if meta_list(com.meta)|trim %}
        {{ meta_list(com.meta) }}
      {% endif %}
      {{ com.doc }}
      {% if com.variables %}
        {{ variable_list(com.variables) }}
      {% endif %}
    </div>
  </div>
{% endmacro %}


{% macro enum_entry(enum) %}
  <div class="panel panel-default">
    <div class="panel-heading codesum"><span class="anchor" id="{{ enum.anchor }}"></span><h3>enum, bind(c){{ deprecated(enum) }}</h3></div>
    <div class="panel-body">
      <h4>Enumerators</h4>
      <table class="table table-striped varlist">
        <tbody>
          {% for var in enum.variables %}
            <tr>
              <td>{{ var.vartype }}</td><td>::</td>
              <td><strong>{{ var.name }}</strong></td><td> = </td><td>{{ var.initial }}</td><td>{% if summary -%}{{ var.meta['summary'] }}{% else %}{{ var.doc }}{% endif %}</td>
            </tr>
          {% endfor %}
        </tbody>
      </table>
      {% if enum.doc or meta_list(enum.meta)|trim %}
        <h4>Description</h4>
        {{ meta_list(enum.meta) }}
        {{ enum.doc }}
      {% endif %}
    </div>
  </div>
{% endmacro %}

{% macro proc_entry(proc) %}
  <div class="panel panel-default">
    <div class="panel-heading codesum"><span class="anchor" id="{{ proc.anchor }}"></span><h3>{{ proc_line(proc) }}</h3></div>
    <div class="panel-body">
      {{ proc_summary(proc,False) }}
    </div>
  </div>
{% endmacro %}


{% macro use_list(obj) %}
  {% if obj.uses or obj.ancestry %}
    <div class="panel panel-default">
      <div class="panel-heading">
        <h3 class="panel-title">Uses</h3>
      </div>
      <ul class="list-group">
        {% if obj.uses %}
          <li class="list-group-item">
            <ul class="list-inline">
              {% for use in obj.uses %}
                <li>{{ use }}</li>
              {% endfor %}
            </ul>
          </li>
        {% endif %}
        {% if obj.ancestry %}
          <li class="list-group-item">
            <ul class="list-inline">
              <li><h5>Ancestors:</h5></li>
              {% for anc in obj.ancestry %}
                <li>{{ anc }}</li>
                {% if not loop.last -%}<li>:</li>{%- endif %}
                {% endfor %}
            </ul>
          </li>
        {% endif %}
        {% if obj.usesgraph %}
          <li class="list-group-item">
            {{ obj.usesgraph }}
          </li>
        {% endif %}
      </ul>
    </div>
  {% endif %}
{% endmacro %}


{% macro usedby_list(obj) %}
  {% if obj.usedbygraph or obj.descendants %}
    <div class="panel panel-default">
      <div class="panel-heading">
        <h3 class="panel-title">Used by</h3>
      </div>
      <ul class="list-group">
        {% if obj.descendants %}
          <li class="list-group-item">
            <ul class="list-inline">
              <li><h5>Descendants:</h5></li>
              {% for anc in obj.descendants %}
                <li>{{ anc }}</li>
              {% endfor %}
            </ul>
          </li>
        {% endif %}
        {% if obj.usedbygraph %}
          <li class="list-group-item">
            {{ obj.usedbygraph }}
          </li>
        {% endif %}
      </ul>
    </div>
  {% endif %}
{% endmacro %}


{% macro meta_list(meta) %}
  {% if meta['author'] or meta['date'] or meta['license'] or meta['version'] or meta['category'] %}
    <dl class="dl-horizontal">
      {% if meta['author'] %}
        <dt>Author</dt><dd>{{ meta['author'] }}</dd>
      {% endif %}
      {% if meta['date'] %}
        <dt>Date</dt><dd>{{ meta['date'] }}</dd>
      {% endif %}
      {% if meta['license'] %}
        <dt>License</dt><dd>{{ meta['license'] }}</dd>
      {% elif projectData['license'] %}
        <dt>License</dt><dd>{{ projectData['license'] }}</dd>
      {% endif %}
      {% if meta['since'] %}
        <dt>Since</dt><dd>{{ meta['since'] }}</dd>
      {% endif %}
      {% if meta['version'] %}
        <dt>Version</dt><dd>{{ meta['version'] }}</dd>
      {% endif %}
      {% if meta['category'] %}
        <dt>Category</dt><dd>{{ meta['category'] }}</dd>
      {% endif %}
    </dl>
  {% endif %}
{% endmacro %}
