Skip to content

Commit

Permalink
Change function list to table and update docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Spacetown committed Dec 29, 2021
1 parent 5163530 commit b99da91
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 14 deletions.
Binary file modified doc/images/screenshot-html-details.example.cpp.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 28 additions & 9 deletions gcovr/templates/source_page.html
Expand Up @@ -49,16 +49,35 @@
{% endblock %}

{% block content %}
{% if function_names %}
<details class="listOfFunctions">
{% if function_list %}
<details>
<summary>List of functions</summary>
<ul>
{% for function_name in function_names %}
<li><a href="#l{{ function_name.1 }}">{{ function_name.0 }}, line {{ function_name.1 }}</a></li>
{% endfor %}
</ul>
</details>
<br/>
<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>
<hr/>
{% endif -%}
<div class="file-source">
<table>
Expand Down
21 changes: 20 additions & 1 deletion gcovr/templates/style.details.css
Expand Up @@ -82,7 +82,26 @@ pre
margin-bottom: 0;
}

.listOfFunctions > ul > li > a
.listOfFunctions td, .listOfFunctions th {
padding: 0 10px;
}
.listOfFunctions th
{
text-align: center;
color: white;
background-color: SteelBlue;
}
.listOfFunctions tr > td {
background: aliceblue;
}
.listOfFunctions tr:nth-child(even) > td {
background: LightSteelBlue
}
.listOfFunctions tr:hover > td
{
background-color: #ddd;
}
.listOfFunctions tr > td > a
{
text-decoration: none;
color: inherit;
Expand Down
17 changes: 13 additions & 4 deletions gcovr/writer/html.py
Expand Up @@ -404,10 +404,19 @@ def print_html_report(covdata, output_file, options):
data['filename'] = cdata_fname[f]

# Only use demangled names (containing a brace)
data['function_names'] = [
(f, cdata.functions[f].lineno) for f in sorted(cdata.functions.keys())
]

data['function_list'] = []
for name in sorted(cdata.functions.keys()):
fcdata = cdata.functions[name]
fdata = dict()
fdata["name"] = name
fdata["line"] = fcdata.lineno
fdata["count"] = fcdata.count
fdata["class"] = coverage_to_class(
0 if fcdata.count >= 0 else high_threshold,
medium_threshold,
high_threshold
)
data['function_list'].append(fdata)
functions = dict()
data['functions'] = functions

Expand Down

0 comments on commit b99da91

Please sign in to comment.