summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.txt5
-rw-r--r--coverage/html.py19
-rw-r--r--coverage/htmlfiles/index.html19
-rw-r--r--coverage/htmlfiles/style.css59
4 files changed, 57 insertions, 45 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 63333d99..be3e7530 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -5,7 +5,10 @@ Change history for Coverage.py
Version 3.2b3
-------------
-- None yet.
+- The table of contents in the HTML report is now sortable. Thanks,
+ `Chris Adams`_.
+
+.. _Chris Adams: http://improbable.org/chris/
Version 3.2b2, 19 November 2009
diff --git a/coverage/html.py b/coverage/html.py
index 5e480011..3877c834 100644
--- a/coverage/html.py
+++ b/coverage/html.py
@@ -48,18 +48,13 @@ class HtmlReporter(Reporter):
self.index_file()
# Create the once-per-directory files.
- shutil.copyfile(
- data_filename("htmlfiles/style.css"),
- os.path.join(directory, "style.css")
- )
- shutil.copyfile(
- data_filename("htmlfiles/jquery-1.3.2.min.js"),
- os.path.join(directory, "jquery-1.3.2.min.js")
- )
- shutil.copyfile(
- data_filename("htmlfiles/jquery.tablesorter.min.js"),
- os.path.join(directory, "jquery.tablesorter.min.js")
- )
+ for static in [
+ "style.css", "jquery-1.3.2.min.js", "jquery.tablesorter.min.js"
+ ]:
+ shutil.copyfile(
+ data_filename("htmlfiles/" + static),
+ os.path.join(directory, static)
+ )
def html_file(self, cu, analysis):
"""Generate an HTML file for one source file."""
diff --git a/coverage/htmlfiles/index.html b/coverage/htmlfiles/index.html
index 162f862c..5c562de2 100644
--- a/coverage/htmlfiles/index.html
+++ b/coverage/htmlfiles/index.html
@@ -20,8 +20,9 @@
<div id='index'>
<table class='index'>
<thead>
- <tr class='tablehead'>
- <th class='name'>Module</th>
+ {# The title='' attr doesn't work in Safari. #}
+ <tr class='tablehead' title='Click to sort'>
+ <th class='name left'>Module</th>
<th>statements</th>
<th>run</th>
<th>excluded</th>
@@ -29,13 +30,13 @@
<th>branches</th>
<th>br exec</th>
{% endif %}
- <th>coverage</th>
+ <th class='right'>coverage</th>
</tr>
</thead>
<tbody>
{% for file in files %}
<tr class='file'>
- <td class='name'><a href='{{file.html_filename}}'>{{file.cu.name}}</a></td>
+ <td class='name left'><a href='{{file.html_filename}}'>{{file.cu.name}}</a></td>
<td>{{file.nums.n_statements}}</td>
<td>{{file.nums.n_executed}}</td>
<td>{{file.nums.n_excluded}}</td>
@@ -43,13 +44,13 @@
<td>{{file.nums.n_branches}}</td>
<td>{{file.nums.n_executed_branches}}</td>
{% endif %}
- <td>{{file.nums.pc_covered|format_pct}}%</td>
+ <td class='right'>{{file.nums.pc_covered|format_pct}}%</td>
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr class='total'>
- <td class='name'>Total</td>
+ <td class='name left'>Total</td>
<td>{{totals.n_statements}}</td>
<td>{{totals.n_executed}}</td>
<td>{{totals.n_excluded}}</td>
@@ -57,7 +58,7 @@
<td>{{totals.n_branches}}</td>
<td>{{totals.n_executed_branches}}</td>
{% endif %}
- <td>{{totals.pc_covered|format_pct}}%</td>
+ <td class='right'>{{totals.pc_covered|format_pct}}%</td>
</tr>
</tfoot>
</table>
@@ -75,11 +76,11 @@
jQuery(function() {
jQuery("table.index").tablesorter({
headers: {
- 0: { sorter:'test' },
+ 0: { sorter:'text' },
1: { sorter:'digit' },
2: { sorter:'digit' },
3: { sorter:'digit' },
- 4: { sorter:'digit' },
+ 4: { sorter:'percent' },
}
});
});
diff --git a/coverage/htmlfiles/style.css b/coverage/htmlfiles/style.css
index 65a27905..dd6c991a 100644
--- a/coverage/htmlfiles/style.css
+++ b/coverage/htmlfiles/style.css
@@ -2,14 +2,14 @@
/* Page-wide styles */
html, body, h1, h2, h3, p, td, th {
margin: 0;
- padding: 0;
- border: 0;
- outline: 0;
- font-weight: inherit;
- font-style: inherit;
- font-size: 100%;
- font-family: inherit;
- vertical-align: baseline;
+ padding: 0;
+ border: 0;
+ outline: 0;
+ font-weight: inherit;
+ font-style: inherit;
+ font-size: 100%;
+ font-family: inherit;
+ vertical-align: baseline;
}
/* Set baseline grid to 16 pt. */
@@ -134,16 +134,16 @@ td.text {
}
.text span.annotate {
- font-family: georgia;
- font-style: italic;
- color: #666;
- float: right;
- padding-right: .5em;
- }
+ font-family: georgia;
+ font-style: italic;
+ color: #666;
+ float: right;
+ padding-right: .5em;
+ }
.text p.hide span.annotate {
- display: none;
- }
-
+ display: none;
+ }
+
/* Syntax coloring */
.text .com {
color: green;
@@ -161,14 +161,28 @@ td.text {
/* index styles */
#index td, #index th {
text-align: right;
- width: 6em;
- padding: .25em 0;
+ width: 5em;
+ padding: .25em .5em;
border-bottom: 1px solid #eee;
}
#index th {
font-style: italic;
color: #333;
border-bottom: 1px solid #ccc;
+ cursor: pointer;
+ }
+#index th:hover {
+ background: #eee;
+ border-bottom: 1px solid #999;
+ }
+#index td.left, #index th.left {
+ padding-left: 0;
+ }
+#index td.right, #index th.right {
+ padding-right: 0;
+ }
+#index th.headerSortDown, #index th.headerSortUp {
+ border-bottom: 1px solid #000;
}
#index td.name, #index th.name {
text-align: left;
@@ -183,13 +197,12 @@ td.text {
color: #000;
}
#index tr.total {
- font-weight: bold;
}
#index tr.total td {
- padding: .25em 0;
+ font-weight: bold;
border-top: 1px solid #ccc;
border-bottom: none;
}
#index tr.file:hover {
- background: #eeeeee;
- }
+ background: #eeeeee;
+ }