{# -*- engine: jinja -*- #}
{% extends "base.html" %}

{% block summary %}
<div>
  <table class="legend">
    <tr>
      <th scope="row">Directory:</th>
      <td>{{info.get_directory()}}</td>
    </tr>
    <tr>
      <th scope="row">File:</th>
      <td>{{filename}}</td>
    </tr>
    <tr>
      <th scope="row">Date:</th>
      <td>{{info.date}}</td>
    </tr>
    {% if SHOW_DECISION and decisions.unchecked > 0 %}
    <tr>
      <th scrope="row">Warnings:</th>
      <td class="warning_text">{{decisions.unchecked}} unchecked decisions!</td>
    </tr>
    {% endif %}
  </table>
</div>
<div>
  <table class="coverage">
    <tr>
      <th></th>
      <th scope="col">Exec</th>
      <th scope="col">Total</th>
      <th scope="col">Coverage</th>
    </tr>
    <tr>
      <th scope="row">Lines:</th>
      <td>{{lines.exec}}</td>
      <td>{{lines.total}}</td>
      <td class="{{lines.class}}">{{lines.coverage}}%</td>
    </tr>
    <tr>
      <th scope="row">Functions:</th>
      <td>{{functions.exec}}</td>
      <td>{{functions.total}}</td>
      <td class="{{functions.class}}">{{functions.coverage}}%</td>
    </tr>
    <tr>
      <th scope="row">Branches:</th>
      <td>{{branches.exec}}</td>
      <td>{{branches.total}}</td>
      <td class="{{branches.class}}">{{branches.coverage}}%</td>
    </tr>
    {% if SHOW_DECISION %}
    <tr>
      <th scope="row">Decisions:</th>
      <td>{{decisions.exec}}</td>
      <td>{{decisions.total}}</td>
      <td class="{{decisions.class}}">{{decisions.coverage}}%</td>
    </tr>
    {% endif %}
  </table>
</div>
{% endblock %}

{% block navigation %}
{% if function_list %}
<details>
  <summary>List of functions</summary>
  <table class="listOfFunctions">
    <tr>
      <th>Function</th>
      <th>Line</th>
      <th>Call count</th>
    </tr>
{% for entry in function_list %}
    <tr>
      <td>
        <a href="#l{{ entry['line'] }}">{{ entry["name"] }}</a>
      </td>
      <td>
        <a href="#l{{ entry['line'] }}">{{ entry["line"] }}</a>
      </td>
      <td>
        <a href="#l{{ entry['line'] }}">
        {%- if entry["count"] == 0 %} not called
        {%- else %} called {{ entry["count"] }} time{% if entry["count"] > 1 %}s{% endif %}
        {%- endif -%}
        </a>
      </td>
    </tr>
{% endfor %}
  </table>
</details>
{% endif -%}
{% endblock %}

{% block content %}
<div class="file-source">
  <table>
    <tr>
      <th align="right">Line</th>
      <th align="right">Branch</th>
      {% if SHOW_DECISION %}
      <th align="right">Decision</th>
      {% endif %}
      <th align="right">Exec</th>
      <th align="left">Source</th>
    </tr>

    {% for row in source_lines %}

    <tr class="source-line">
      <td class="lineno"><a id="l{{row.lineno}}" href="#l{{row.lineno}}">{{row.lineno}}</a></td>
      <td class="linebranch">
        {% if row.linebranch %}
        <details class="linebranchDetails">
        <summary class="linebranchSummary">{{row.linebranch.taken}}/{{row.linebranch.total}}</summary>
        <div class="linebranchContents">
          {% for branch in row.linebranch.branches %}
          {% if branch.taken %}
          <div class="takenBranch">&check; Branch {{branch.name}} taken {{branch.count}} times.</div>
          {% else %}
          <div class="notTakenBranch">&cross; Branch {{branch.name}} not taken.</div>
          {% endif%}
          {% endfor %}
        </div>
        </details>
        {% endif %}
      </td>
      {% if SHOW_DECISION %}
      <td class="linedecision">
        {% if row.linedecision %}
        <details class="linedecisionDetails">
          <summary class="linedecisionSummary">{{row.linedecision.taken}}/{{row.linedecision.total}}</summary>
          <div class="linedecisionContents">
            {% for decision in row.linedecision.decisions %}
            {% if decision.uncheckable %}
            <div class="uncheckedDecision">? Decision couldn't be analyzed.</div>
            {% elif decision.taken %}
            <div class="takenDecision">&check; Decision '{{decision.name}}' taken {{decision.count}} times.</div>
            {% else %}
            <div class="notTakenDecision">&cross; Decision '{{decision.name}}' not taken.</div>
            {% endif %}
            {% endfor %}
          </div>
        </details>
        {% endif %}
      </td>
      {% endif %}
      <td class="linecount {{row.covclass}}">{% if ( row.covclass == 'uncoveredLine' ) %}&cross;{% elif ( row.covclass == 'excludedLine' ) %}&minus;{% else %}{{row.linecount}}{% endif %}</td>
      <td class="src {{row.covclass}}">{{row.source}}</td>
    </tr>
    {% endfor %}

  </table>
</div>
{% endblock %}
