{% macro info_bar(name,meta,base_url,hierarchy) %}
<div class="row">
<div class="col-lg-12">
<div class="well well-sm">
  <ul class="list-inline" style="margin-bottom:0px;display:inline">
     {% if meta['author'] %}
    <li><i class="fa fa-pencil"></i> {{ meta['author'] }}</li>
     {% endif %}
     {% if meta['date'] %}
    <li><i class="fa fa-calendar-o"></i> {{ meta['date'] }}</li>
     {% endif %}
     {% if meta['license'] %}
    <li><i class="fa fa-legal"></i> {{ meta['license'] }}</li>
     {% endif %}
     {% if meta['version'] %}
    <li><i class="fa fa-barcode"></i> {{ meta['version'] }}</li>
    {% endif %}
    {% if meta['category'] %}
    <li><i class="fa fa-folder-open"></i> {{ meta['category'] }}</li>
    {% endif %}
    {% if hierarchy[0] %}
    <li><i class="fa fa-code"></i><a href="{{ base_url }}/src/{{ hierarchy[0].name }}"> Source File</a></li>
     {% else %}
    <li><i class="fa fa-code"></i><a href="{{ base_url }}/src/{{ name }}"> Source File</a></li>
     {% endif %}
  </ul>
  <ol class="breadcrumb in-well text-right">
  {% for item in hierarchy %}
     <li>{{ item }}</li>
  {% endfor %}
     <li class="active">{{ name }}</li>
  </ol>
</div>
</div>
</div>
{% endmacro %}


{% macro sidebar(project,self) %}
<div id="sidebar">
  {% set count = 0 %}
  {% if self.variables %}
  {% set count = count + 1 %}
  <div class="panel panel-primary">
    <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#vars">Variables</a></h3></div>
    <div id="vars" class="panel-collapse collapse">
      <div class="list-group">
        {% for var in self.variables %}
        <a class="list-group-item" href="{{ self.get_url() }}#{{ var.anchor }}">{{ var.name }}</a>
        {% endfor %}
      </div>
    </div>
  </div>
  {% endif %}
  {% if self.enums %}
  {% set count = count + 1 %}
  <div class="panel panel-primary">
    <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#enums">Enumerations</a></h3></div>
    <div id="enums" class="panel-collapse collapse">
      <div class="list-group">
        {% for enum in self.enums %}
        <a class="list-group-item" href="{{ self.get_url() }}#{{ enum.anchor }}">{{ enum.name }}</a>
        {% endfor %}
      </div>
    </div>
  </div>
  {% endif %}
  {% if self.constructor %}
  {% set count = count + 1 %}
  <div class="panel panel-primary">
    <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#cons">Constructor</a></h3></div>
    <div id="cons" class="panel-collapse collapse">
        <div class="list-group">
          <a class="list-group-item" href="{{ self.get_url() }}#{{ self.constructor.anchor }}">{{ self.constructor.name }}</a>
        </div>
    </div>
  </div>
  {% endif %}
  {% if self.programs %}
  {% set count = count + 1 %}
  <div class="panel panel-primary">
    <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#progs">Programs</a></h3></div>
    <div id="progs" class="panel-collapse collapse">
        <div class="list-group">
          {% for prog in self.programs %}
          <a class="list-group-item" href="{{ prog.get_url() }}">{{ prog.name }}</a>
          {% endfor %}
        </div>
    </div>
  </div>
  {% endif %}
  {% if self.modules %}
  {% set count = count + 1 %}
  <div class="panel panel-primary">
    <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#mods">Modules</a></h3></div>
    <div id="mods" class="panel-collapse collapse">
        <div class="list-group">
          {% for mod in self.modules %}
          <a class="list-group-item" href="{{ mod.get_url() }}">{{ mod.name }}</a>
          {% endfor %}
        </div>
    </div>
  </div>
  {% endif %}
  {% if self.submodules %}
  {% set count = count + 1 %}
  <div class="panel panel-primary">
    <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#submods">Submodules</a></h3></div>
    <div id="submods" class="panel-collapse collapse">
        <div class="list-group">
          {% for mod in self.submodules %}
          <a class="list-group-item" href="{{ mod.get_url() }}">{{ mod.name }}</a>
          {% endfor %}
        </div>
    </div>
  </div>
  {% endif %}
  {% if self.interfaces %}
  {% set count = count + 1 %}
  <div class="panel panel-primary">
    <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#inters">Interfaces</a></h3></div>
    <div id="inters" class="panel-collapse collapse">
        <div class="list-group">
          {% for intr in self.interfaces %}
          <a class="list-group-item" href="{{ self.get_url() }}#{{ intr.anchor }}">{{ intr.name }}</a>
          {% endfor %}
        </div>
    </div>
  </div>
  {% endif %}
  {% if self.absinterfaces %}
  {% set count = count + 1 %}
  <div class="panel panel-primary">
    <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#absints">Abstract Interfaces</a></h3></div>
    <div id="absints" class="panel-collapse collapse">
        <div class="list-group">
          {% for intr in self.absinterfaces %}
          <a class="list-group-item" href="{{ self.get_url() }}#{{ intr.anchor }}">{{ intr.name }}</a>
          {% endfor %}
        </div>
    </div>
  </div>
  {% endif %}
  {% if self.types %}
  {% set count = count + 1 %}
  <div class="panel panel-primary">
    <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#types">Derived Types</a></h3></div>
    <div id="types" class="panel-collapse collapse">
      <div class="list-group">
        {% for type in self.types %}
        <a class="list-group-item" href="{{ self.get_url() }}#{{ type.anchor }}">{{ type.name }}</a>
        {% endfor %}
      </div>
    </div>
  </div>
  {% endif %}
  {% if self.functions %}
  {% set count = count + 1 %}
  <div class="panel panel-primary">
    <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#funcs">Functions</a></h3></div>
    <div id="funcs" class="panel-collapse collapse">
        <div class="list-group">
          {% for proc in self.functions %}
          <a class="list-group-item" href="{% if self.obj == 'sourcefile' %}{{ proc.get_url() }}{% else %}{{ self.get_url() }}#{{ proc.anchor }}{% endif %}">{{ proc.name }}</a>
          {% endfor %}
        </div>
    </div>
  </div>
  {% endif %}
  {% if self.subroutines %}
  {% set count = count + 1 %}
  <div class="panel panel-primary">
    <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#subs">Subroutines</a></h3></div>
    <div class="list-group">
        <div id="subs" class="panel-collapse collapse">
          {% for proc in self.subroutines %}
          <a class="list-group-item" href="{% if self.obj == 'sourcefile' %}{{ proc.get_url() }}{% else %}{{ self.get_url() }}#{{ proc.anchor }}{% endif %}">{{ proc.name }}</a>
          {% endfor %}
        </div>
    </div>
  </div>
  {% endif %}
  {% if self.modfunctions %}
  {% set count = count + 1 %}
  <div class="panel panel-primary">
    <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#modfuncs">Module Functions</a></h3></div>
    <div id="modfuncs" class="panel-collapse collapse">
        <div class="list-group">
          {% for proc in self.modfunctions %}
          <a class="list-group-item" href="{{ self.get_url() }}#{{ proc.anchor }}">{{ proc.name }}</a>
          {% endfor %}
        </div>
    </div>
  </div>
  {% endif %}
  {% if self.modsubroutines %}
  {% set count = count + 1 %}
  <div class="panel panel-primary">
    <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#modsubs">Module Subroutines</a></h3></div>
    <div id="modsubs" class="panel-collapse collapse">
        <div class="list-group">
          {% for proc in self.modsubroutines %}
          <a class="list-group-item" href="{{ self.get_url() }}#{{ proc.anchor }}">{{ proc.name }}</a>
          {% endfor %}
        </div>
    </div>
  </div>
  {% endif %}
  {% if self.modprocedures %}
  {% set count = count + 1 %}
  <div class="panel panel-primary">
    <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#modprocs">Module Procedures</a></h3></div>
    <div id="modprocs" class="panel-collapse collapse">
        <div class="list-group">
          {% for proc in self.modprocedures %}
          <a class="list-group-item" href="{{ self.get_url() }}#{{ proc.anchor }}">{{ proc.name }}</a>
          {% endfor %}
        </div>
    </div>
  </div>
  {% endif %}
  {% if self.finalprocs %}
  {% set count = count + 1 %}
  <div class="panel panel-primary">
    <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#fins">Finalization Procedures</a></h3></div>
    <div id="fins" class="panel-collapse collapse">
        <div class="list-group">
          {% for fp in self.finalprocs %}
          <a class="list-group-item" href="{{ self.get_url() }}#{{ fp.anchor }}">{{ fp.name }}</a>
          {% endfor %}
        </div>
    </div>
  </div>
  {% endif %}
  {% if self.boundprocs %}
  {% set count = count + 1 %}
  <div class="panel panel-primary">
    <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#boundprocs">Type-Bound Procedures</a></h3></div>
    <div id="boundprocs" class="panel-collapse collapse">
        <div class="list-group">
          {% for bp in self.boundprocs %}
          <a class="list-group-item" href="{{ self.get_url() }}#{{ bp.anchor }}">{{ bp.name }}</a>
          {% endfor %}
        </div>
    </div>
  </div>
  {% endif %}
  {% if self.modprocs %}
  {% set count = count + 1 %}
  <div class="panel panel-primary">
    <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#modprocs">Module Procedures</a></h3></div>
    <div id="modprocs" class="panel-collapse collapse">
        <div class="list-group">
          {% for mod in self.modprocs %}
          <a class="list-group-item" href="{{ self.get_url() }}#{{ mod.anchor }}">{{ mod.name }}</a>
          {% endfor %}
        </div>
    </div>
  </div>
  {% endif %}
  {% if self.src %}
  {% set count = count + 1 %}
  <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 count > 0 %}<hr>{% endif %}
  {% if self.obj == 'program' %}
  <div class="panel panel-default">
    <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#allprogs">All Programs</a></h3></div>
    <div id="allprogs" class="panel-collapse collapse">
        <div class="list-group">
          {% for prog in project.programs|sort(attribute='name') %}
          <a class="list-group-item" href="{{ prog.get_url() }}">{{ prog.name }}</a>
          {% endfor %}
        </div>
    </div>
  </div>
  {% elif self.obj == 'module' or self.obj == 'submodule' %}
  <div class="panel panel-default">
    <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#allmods">All Modules</a></h3></div>
    <div id="allmods" class="panel-collapse collapse">
        <div class="list-group">
          {% for mod in project.modules|sort(attribute='name') %}
          <a class="list-group-item" href="{{ mod.get_url() }}">{{ mod.name }}</a>
          {% endfor %}
        </div>
    </div>
  </div>
  {% elif self.obj == 'proc' or (self.obj == 'interface' and (not self.abstract)) %}
  <div class="panel panel-default">
    <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#allprocs">All Procedures</a></h3></div>
    <div id="allprocs" class="panel-collapse collapse">
        <div class="list-group">
          {% for proc in project.procedures|sort(attribute='name') %}
          <a class="list-group-item" href="{{ proc.get_url() }}">{{ proc.name }}</a>
          {% endfor %}
        </div>
    </div>
  </div>
  {% elif self.obj == 'interface' %}
  <div class="panel panel-default">
    <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#allabsints">All Abstract Interfaces</a></h3></div>
    <div id="allabsints" class="panel-collapse collapse">
        <div class="list-group">
          {% for absint in project.absinterfaces|sort(attribute='name') %}
          <a class="list-group-item" href="{{ absint.get_url() }}">{{ absint.name }}</a>
          {% endfor %}
        </div>
    </div>
  </div> 
  {% elif self.obj == 'type' %}
  <div class="panel panel-default">
    <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#alltypes">All Derived Types</a></h3></div>
    <div id="alltypes" class="panel-collapse collapse">
        <div class="list-group">
          {% for dtype in project.types|sort(attribute='name') %}
          <a class="list-group-item" href="{{ dtype.get_url() }}">{{ dtype.name }}</a>
          {% endfor %}
        </div>
    </div>
  </div>
  {% elif self.obj == 'sourcefile' %}
  <div class="panel panel-default">
    <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#allfiles">All Source Files</a></h3></div>
    <div id="allfiles" class="panel-collapse collapse">
        <div class="list-group">
          {% for src in project.allfiles|sort(attribute='name') %}
          <a class="list-group-item" href="{{ src.get_url() }}">{{ src.name }}</a>
          {% endfor %}
        </div>
    </div>
  </div>
  {% endif %}
</div>
{% endmacro %}


{% macro var_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 = 5 %}
{% if permission %}{% set colnum = colnum + 1%}{% endif %}
{% if intent %}{% set colnum = colnum + 2%}{% else %}{% set colnum = colnum + 1 %}{% endif %}
<tbody>
{% for var in variables %}
  {% set args = 0 %}
  {% if var.kind %}{% set args = args + 1 %}{% endif %}
  {% if var.strlen %}{% set args = args + 1 %}{% endif %}
  {% if var.proto %}{% set args = args + 1 %}{% endif %}
<tr>
  {% if var.obj == 'variable' %}
  <td><span class="anchor" {% if id %}id="{{ var.anchor }}"{% endif %}></span>{{ var.vartype }}{% if args > 0 -%}({% if var.kind -%}kind={{ var.kind }}{%- endif %}{% if args > 1 -%},{%- endif %}{% if var.strlen -%}len={{ var.strlen }}{%- endif %}{% if var.proto -%}{% if not var.proto[0].permission or var.proto[0].visible -%}{{ var.proto[0] }}{% else %}{{ var.proto[0].name }}{%- endif %}{{ var.proto[1] }}{%- endif %}){%- endif %}{% if (intent and var.intent) or permission or var.parameter or var.attribs|length > 0 -%},{%- endif %}</td>
  {% if intent -%}<td>{% if var.intent -%}intent({{ var.intent }}){%- endif%}{% if var.optional or permission or var.parameter or var.attribs|length > 0 -%},{% endif %}</td>
  <td>{% if var.optional -%}optional{% if permission or var.parameter or var.attributes|length > 0 -%},{%- endif %}{%- endif %}</td>{%- endif %}
  {% if permission %}<td>{{ var.permission }}{% if var.parameter or var.attribs|length > 0 -%},{%- endif %}</td>{% endif %}
  <td>{% if var.parameter %}parameter{% if var.attribs|length > 0 %}, {% endif %}{% endif %}{% for attrib in var.attribs -%}{{ attrib }}{% if not loop.last -%}, {% endif %}{%- endfor %}</td><td>::</td>
  <td><strong>{{ var.name }}</strong>{{ var.dimension }}</td>{% if not intent %}<td>{% if var.initial -%}{% if var.points -%} => {% else %} = {%- endif %}{% endif %}</td><td>{% if var.initial %}{{ var.initial }}{%- endif %}</td>{% 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 proc_summary(proc,title=True,small=False,proto=False) %}
    {% if title %}
    {% if small %}<h5>{% else %}<h3>{% endif %}{{ proc_line(proc,proto=proto) }}{% if proto %}<small>Prototype</small>{% endif %}{% if small %}</h5>{% else %}</h3>{% endif %}
    {% endif %}
    {% if small %}<h6>{% else %}<h4>{% endif %}Arguments{% if small %}</h6>{% else %}</h4>{% endif %}
    {% if proc.args|length > 0 %}
      {% if proc.visible %}
      {{ var_list(proc.args,intent=True,summary=True,id=False) }}
      {% else %}
      {{ var_list(proc.args,intent=True,id=False) }}
      {% endif %}
    {% else %}
      <em>None</em>
    {% endif %}
    {% if proc.retvar %}
{% set var = proc.retvar %}
  {% set args = 0 %}
  {% if var.kind %}{% set args = args + 1 %}{% endif %}
  {% if var.strlen %}{% set args = args + 1 %}{% endif %}
  {% if var.proto %}{% set args = args + 1 %}{% endif %}
     {% if small %}<h6>{% else %}<h4>{% endif %}Return Value <small>{{ var.vartype }}{% if args > 0 -%}({% if var.kind -%}kind={{ var.kind }}{%- endif %}{% if args > 1 -%},{%- endif %}{% if var.strlen -%}len={{ var.strlen }}{%- endif %}{% if var.proto -%}{% if not var.proto[0].permission or var.proto[0].visible -%}{{ var.proto[0] }}{% else %}{{ var.proto[0].name }}{%- endif %}{{ var.proto[1] }}{%- endif %}){%- endif %}{% if var.attribs|length > 0 -%},{%- endif %}
  {% for attrib in var.attribs -%}{{ attrib }}{% if not loop.last or var.dimension -%}, {%- endif %}{%- endfor %}{{ var.dimension }}</small>{% if small %}</h6>{% else %}</h4>{% endif %}
  {{ var.meta['summary'] }}
    {% endif %}
    {% if proc.doc or (meta_list(proc.meta)|trim|length > 0 and proc.visible) %}
    {% if small %}<h6>{% else %}<h4>{% endif %}Description{% if small %}</h6>{% else %}</h4>{% endif %}
       {% if proc.parent and proc.visible %}
       {{ meta_list(proc.meta) }}
       {% endif %}
       {{ proc.meta['summary'] }}
    {% 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.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 %}
    {% if tb.meta['deprecated'] and tb.meta['deprecated'].lower() == 'true' %}
	 <span class="label label-danger depwarn">Deprecated</span>
    {% endif %}
  </h3></div>
  {% if tb.doc or meta_list(tb.meta)|trim|length > 1 %}
  <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' %}
            {{ proc_summary(tb.proto.procedure,proto=True) }}
         {% elif tb.proto.obj == 'procedure' %}
            {{ proc_summary(tb.proto,proto=True) }}
         {% endif %}
      {% elif bind.obj == 'boundprocedure' %}
         {% if bind.deferred and bind.protomatch %}
            {% if bind.proto.obj == 'interface' %}
                {{ proc_summary(bind.proto.procedure,proto=True) }}
            {% elif bind.proto.obj == 'procedure' %}
                {{ proc_summary(bind.proto,proto=True) }}
            {% endif %}
         {% else %}
            {{ proc_summary(bind.bindings[0]) }}
         {% endif %}
      {% else %}
         {{ proc_summary(bind) }}
      {% endif %}
      </li>
    {% endfor %}
  </ul>
</div>
{% endmacro %}


{% macro interface(intr) %}
<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 %}{% if intr.visible %}{{ intr }}{% else %}{{ intr.name }}{% endif %}{% endif %}
    {% if intr.meta['deprecated'] and intr.meta['deprecated'].lower() == 'true' %}
	 <span class="label label-danger depwarn">Deprecated</span>
    {% endif %}
  </h3></div>
  {% if intr.doc or (meta_list(intr.meta)|trim|length > 0 and not intr.visible) %}
  <div class="panel-body">
    {% if not intr.visible %}
    {{ meta_list(intr.meta) }}
    {% endif %}
    {{ intr.meta['summary'] }}
  </div>
  {% endif %}
  <ul class="list-group">
  {% if intr.generic %}
  {% for proc in intr.functions + intr.subroutines %}
    <li class="list-group-item">
    {{ proc_summary(proc) }}
    </li>
  {% endfor %}
  {% for proc in intr.modprocs %}
    <li class="list-group-item">
    {{ proc_summary(proc.procedure) }}
    </li>
  {% endfor %}
  {% else %}
    <li class="list-group-item">
    {{ proc_summary(intr.procedure) }}
    </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
    {% if intr.meta['deprecated'] and intr.meta['deprecated'].lower() == 'true' %}
	 <span class="label label-danger depwarn">Deprecated</span>
    {% endif %}
  </h3></div>
  {% if intr.doc or meta_list(intr.meta)|trim|length > 0 %}
  <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 %}{% for attrib in proc.attribs -%}{{ attrib }}{#{% if not loop.last or proc.module %}#} {#{% endif %}#}{%- endfor %}{% if proc.module and proc.module != True and (proc.parobj == 'interface' or proc.parobj == 'submodule') %}module {% endif %}{{ proc.proctype|lower }} {% if not proc.parent or (proc.visible and link and not proc.mp) %}{{ proc }}{% else %}{{ proc.name }}{% endif %}({% for arg in proc.args -%}{{ arg.name }}{% if not loop.last -%}, {% endif %}{%- endfor %}){% 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 %}
    {% if proc.meta['deprecated'] and proc.meta['deprecated'].lower() == 'true' %}
	 <span class="label label-danger depwarn">Deprecated</span>
    {% endif %}
    {% if proc.module and proc.module != True and proc.parobj == 'submodule' and proc.module.visible %}
	 <a href='{{ proc.module.get_url() }}'><button type="button" class="btn btn-info depwarn">Interface &rarr;</button></a>
    {% endif %}
    {% if proc.module and proc.module != True and proc.parobj == 'interface' and proc.module.visible %}
	 <a href='{{ proc.module.get_url() }}'><button type="button" class="btn btn-info depwarn">Implementation &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> 
    {% if proc.meta['deprecated'] and proc.meta['deprecated'].lower() == 'true' %}
	 <span class="label label-danger depwarn">Deprecated</span>
    {% endif %}</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) }}
     </li>
  </ul>
</div>
{% 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 %}{% for attrib in dtype.attributes -%}, {{ attrib }}{%- endfor %}{% if dtype.extends %}, extends({{ dtype.extends }}){% endif %} :: {% if dtype.visible %}{{ dtype }}{% else %}{{ dtype.name }}{% endif %}
    {% if dtype.meta['deprecated'] and dtype.meta['deprecated'].lower() == 'true' %}
	 <span class="label label-danger depwarn">Deprecated</span>
    {% endif %}
  </h3></div>
  <div class="panel-body">
     {% if dtype.variables|length > 0 %}
     <h4>Components</h4>
    {{ var_list(dtype.variables,permission=True,summary=True) }}
     {% endif %}
     {% if dtype.constructor %}
     <h4>Constructor</h4>
       {% if dtype.constructor.obj == 'interface' %}
         {{ dtype.constructor.meta['summary'] }}
       {% endif %}
       <table class="table table-striped varlist">
      <tbody>
        {% if dtype.constructor.obj == 'proc' %}
        <tr><td>{{ proc_line(dtype.constructor) }}</td><td>{{ dtype.constructor.meta['summary'] }}</td></tr>
        {% elif dtype.constructor.obj == 'interface' %}
             {% for proc in dtype.constructor.functions + dtype.constructor.subroutines %}
             <tr><td>{% if proc.parobj == 'module' or (proc.parobj == 'interface' and proc.parent.parobj == 'module') %}{{ proc.permission }} {% endif %}{% for attrib in proc.attribs -%}{{ attrib }}{% if not loop.last -%}, {%- endif %}{%- endfor %} {{ proc.proctype|lower }} <strong>{% if proc.visible %}{{ proc }}{% else %}{{ proc.name }}{% endif %}</strong>({% for arg in proc.args -%}{{ arg }}{% if not loop.last -%}, {% endif %}{%- endfor %}){% if proc.bindC -%}, bind({{ proc.bindC }}){% endif %}</td><td>{{ proc.meta['summary'] }}</td></tr>
             {% endfor %}
             {% for mproc in dtype.constructor.modprocs %}
             {% set proc = mproc.procedure %}
             <tr><td>{% if proc.parobj == 'module' or (proc.parobj == 'interface' and proc.parent.parobj == 'module') %}{{ proc.permission }} {% endif %}{% for attrib in proc.attribs -%}{{ attrib }}{% if not loop.last -%}, {%- endif %}{%- endfor %} {{ proc.proctype|lower }} <strong>{% if proc.visible %}{{ proc }}{% else %}{{ proc.name }}{% endif %}</strong>({% for arg in proc.args -%}{{ arg }}{% if not loop.last -%}, {% endif %}{%- endfor %}){% if proc.bindC -%}, bind({{ proc.bindC }}){% endif %}</td><td>{{ proc.meta['summary'] }}</td></tr>
             {% endfor %}
        {% endif %}
       </tbody>
       </table>
     {% endif %}
     {% if dtype.finalprocs|length > 0 %}
     <h4>Finalizations Procedures</h4>
      <table class="table table-striped varlist">
      <tbody>
      {% for fin in dtype.finalprocs %}
       <tr><td>final :: <strong>{{ fin.name }}</strong></h3></td><td>{{ fin.meta['summary'] }}</td></tr>
      {% endfor %}
       </tbody>
       </table>  
     {% endif %}     
     {% if dtype.boundprocs|length > 0 %}
     <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 -%}, {% 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 -%}{{ bind.name }}{% if not loop.last -%}, {% endif %}{%- endfor %}{% endif %} {% if tb.binding|length == 1 %}<small>{{ tb.bindings[0].proctype }}</small>{% endif %}</td>
       <td>{{ tb.meta['summary'] }}</td></tr>
      {% endfor %}
       </tbody>
       </table>
     {% endif %}
     {% if dtype.doc or (meta_list(dtype.meta)|trim|length > 0 and not dtype.visible) %}
     <h4>Description</h4>
       {% if not dtype.visible %}
       {{ meta_list(dtype.meta) }}
       {% endif %}
       {{ dtype.meta['summary'] }}
     {% 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){% if enum.meta['deprecated'] and enum.meta['deprecated'].lower() == 'true' %}<span class="label label-danger depwarn">Deprecated</span>{% endif %}</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|length > 0 %}
     <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 ancestry(obj) %}
  {% if obj.ancestry|length > 0 %}
    <ul class="list-inline">
      <li><h4>Ancestors:</h4></li>
      {% for anc in obj.ancestry %}
      <li>{{ anc }}</li>
      {% if not loop.last -%}<li>:</li>{%- endif %}
      {% endfor %}
    </ul>
  {% endif %}
{% endmacro %}


{% macro descendants(obj) %}
  {% if obj.descendants|length > 0 %}
    <ul class="list-inline">
      <li><h4>Descendants:</h4></li>
      {% for anc in obj.descendants %}
      <li>{{ anc }}</li>
      {% endfor %}
    </ul>
  {% endif %}
{% endmacro %}


{% macro use_list(obj) %}
  {% if obj.uses|length > 0 %}
    <ul class="list-inline">
      <li><h4>Uses:</h4></li>
      {% for use in obj.uses %}
      <li>{{ use }}</li>
      {% endfor %}
    </ul>
  {% 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>
    {% 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 %}
