diff options
Diffstat (limited to 'coverage/htmlfiles')
-rw-r--r-- | coverage/htmlfiles/coverage_html.js | 87 | ||||
-rw-r--r-- | coverage/htmlfiles/index.html | 170 | ||||
-rw-r--r-- | coverage/htmlfiles/pyfile.html | 119 | ||||
-rw-r--r-- | coverage/htmlfiles/style.css | 40 |
4 files changed, 260 insertions, 156 deletions
diff --git a/coverage/htmlfiles/coverage_html.js b/coverage/htmlfiles/coverage_html.js new file mode 100644 index 00000000..5219e36b --- /dev/null +++ b/coverage/htmlfiles/coverage_html.js @@ -0,0 +1,87 @@ +// Coverage.py HTML report browser code. + +// Loaded on index.html +function index_ready($) { + // Look for a cookie containing previous sort settings: + sort_list = []; + cookie_name = "COVERAGE_INDEX_SORT"; + + // This almost makes it worth installing the jQuery cookie plugin: + if (document.cookie.indexOf(cookie_name) > -1) { + cookies = document.cookie.split(";"); + for (var i=0; i < cookies.length; i++) { + parts = cookies[i].split("=") + + if ($.trim(parts[0]) == cookie_name && parts[1]) { + sort_list = eval("[[" + parts[1] + "]]"); + break; + } + } + } + + // Create a new widget which exists only to save and restore + // the sort order: + $.tablesorter.addWidget({ + id: "persistentSort", + + // Format is called by the widget before displaying: + format: function(table) { + if (table.config.sortList.length == 0 && sort_list.length > 0) { + // This table hasn't been sorted before - we'll use + // our stored settings: + $(table).trigger('sorton', [sort_list]); + } + else { + // This is not the first load - something has + // already defined sorting so we'll just update + // our stored value to match: + sort_list = table.config.sortList; + } + } + }); + + // Configure our tablesorter to handle the variable number of + // columns produced depending on report options: + var headers = {}; + var col_count = $("table.index > thead > tr > th").length; + + headers[0] = { sorter: 'text' }; + for (var i = 1; i < col_count-1; i++) { + headers[i] = { sorter: 'digit' }; + } + headers[col_count-1] = { sorter: 'percent' }; + + // Enable the table sorter: + $("table.index").tablesorter({ + widgets: ['persistentSort'], + headers: headers + }); + + // Watch for page unload events so we can save the final sort settings: + $(window).unload(function() { + document.cookie = cookie_name + "=" + sort_list.toString() + "; path=/" + }); +} + +// -- pyfile stuff -- + +function pyfile_ready($) { + // If we're directed to a particular line number, highlight the line. + var frag = location.hash; + if (frag.length > 2 && frag[1] == 'n') { + $(frag).addClass('highlight'); + } +} + +function toggle_lines(btn, cls) { + btn = $(btn); + var hide = "hide_"+cls; + if (btn.hasClass(hide)) { + $("#source ."+cls).removeClass(hide); + btn.removeClass(hide); + } + else { + $("#source ."+cls).addClass(hide); + btn.addClass(hide); + } +} diff --git a/coverage/htmlfiles/index.html b/coverage/htmlfiles/index.html index 5c562de2..c1ef8ad7 100644 --- a/coverage/htmlfiles/index.html +++ b/coverage/htmlfiles/index.html @@ -1,89 +1,81 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
-<html>
- <head>
- <meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
- <title>Coverage report</title>
- <link rel='stylesheet' href='style.css' type='text/css'>
- <script type='text/javascript' src='jquery-1.3.2.min.js'></script>
- <script type='text/javascript' src='jquery.tablesorter.min.js'></script>
- </head>
- <body>
-
- <div id='header'>
- <div class='content'>
- <h1>Coverage report:
- <span class='pc_cov'>{{totals.pc_covered|format_pct}}%</span>
- </h1>
- </div>
- </div>
-
- <div id='index'>
- <table class='index'>
- <thead>
- {# 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>
- {% if arcs %}
- <th>branches</th>
- <th>br exec</th>
- {% endif %}
- <th class='right'>coverage</th>
- </tr>
- </thead>
- <tbody>
- {% for file in files %}
- <tr class='file'>
- <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>
- {% if arcs %}
- <td>{{file.nums.n_branches}}</td>
- <td>{{file.nums.n_executed_branches}}</td>
- {% endif %}
- <td class='right'>{{file.nums.pc_covered|format_pct}}%</td>
- </tr>
- {% endfor %}
- </tbody>
- <tfoot>
- <tr class='total'>
- <td class='name left'>Total</td>
- <td>{{totals.n_statements}}</td>
- <td>{{totals.n_executed}}</td>
- <td>{{totals.n_excluded}}</td>
- {% if arcs %}
- <td>{{totals.n_branches}}</td>
- <td>{{totals.n_executed_branches}}</td>
- {% endif %}
- <td class='right'>{{totals.pc_covered|format_pct}}%</td>
- </tr>
- </tfoot>
- </table>
- </div>
-
- <div id='footer'>
- <div class='content'>
- <p>
- <a class='nav' href='{{__url__}}'>coverage.py v{{__version__}}</a>
- </p>
- </div>
- </div>
-
- <script type="text/javascript" charset="utf-8">
- jQuery(function() {
- jQuery("table.index").tablesorter({
- headers: {
- 0: { sorter:'text' },
- 1: { sorter:'digit' },
- 2: { sorter:'digit' },
- 3: { sorter:'digit' },
- 4: { sorter:'percent' },
- }
- });
- });
- </script>
- </body>
-</html>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> + <meta http-equiv='Content-Type' content='text/html; charset=utf-8'> + <title>Coverage report</title> + <link rel='stylesheet' href='style.css' type='text/css'> + <script type='text/javascript' src='jquery-1.3.2.min.js'></script> + <script type='text/javascript' src='jquery.tablesorter.min.js'></script> + <script type='text/javascript' src='coverage_html.js'></script> + <script type='text/javascript' charset='utf-8'> + jQuery(document).ready(index_ready); + </script> +</head> +<body id='indexfile'> + +<div id='header'> + <div class='content'> + <h1>Coverage report: + <span class='pc_cov'>{{totals.pc_covered|format_pct}}%</span> + </h1> + </div> +</div> + +<div id='index'> + <table class='index'> + <thead> + {# The title='' attr doesn't work in Safari. #} + <tr class='tablehead' title='Click to sort'> + <th class='name left headerSortDown'>Module</th> + <th>statements</th> + <th>missing</th> + <th>excluded</th> + {% if arcs %} + <th>branches</th> + <th>partial</th> + {% endif %} + <th class='right'>coverage</th> + </tr> + </thead> + {# HTML syntax requires thead, tfoot, tbody #} + <tfoot> + <tr class='total'> + <td class='name left'>Total</td> + <td>{{totals.n_statements}}</td> + <td>{{totals.n_missing}}</td> + <td>{{totals.n_excluded}}</td> + {% if arcs %} + <td>{{totals.n_branches}}</td> + <td>{{totals.n_missing_branches}}</td> + {% endif %} + <td class='right'>{{totals.pc_covered|format_pct}}%</td> + </tr> + </tfoot> + <tbody> + {% for file in files %} + <tr class='file'> + <td class='name left'><a href='{{file.html_filename}}'>{{file.cu.name}}</a></td> + <td>{{file.nums.n_statements}}</td> + <td>{{file.nums.n_missing}}</td> + <td>{{file.nums.n_excluded}}</td> + {% if arcs %} + <td>{{file.nums.n_branches}}</td> + <td>{{file.nums.n_missing_branches}}</td> + {% endif %} + <td class='right'>{{file.nums.pc_covered|format_pct}}%</td> + </tr> + {% endfor %} + </tbody> + </table> +</div> + +<div id='footer'> + <div class='content'> + <p> + <a class='nav' href='{{__url__}}'>coverage.py v{{__version__}}</a> + </p> + </div> +</div> + +</body> +</html> diff --git a/coverage/htmlfiles/pyfile.html b/coverage/htmlfiles/pyfile.html index ca65152d..035691c8 100644 --- a/coverage/htmlfiles/pyfile.html +++ b/coverage/htmlfiles/pyfile.html @@ -1,58 +1,61 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
-<html>
-<head>
-<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
-<title>Coverage for {{cu.name|escape}}</title>
-<link rel='stylesheet' href='style.css' type='text/css'>
-<script type='text/javascript' src='jquery-1.3.2.min.js'></script>
-<script type='text/javascript'>
-function toggle_lines(btn, cls) {
- var btn = $(btn);
- if (btn.hasClass("hide")) {
- $("#source ."+cls).removeClass("hide");
- btn.removeClass("hide");
- }
- else {
- $("#source ."+cls).addClass("hide");
- btn.addClass("hide");
- }
-}
-</script>
-</head>
-<body>
-<div id='header'>
- <div class='content'>
- <h1>Coverage for <b>{{cu.name|escape}}</b> :
- <span class='pc_cov'>{{nums.pc_covered|format_pct}}%</span>
- </h1>
- <h2 class='stats'>
- {{nums.n_statements}} statements
- <span class='{{c_run.strip}}' onclick='toggle_lines(this, "run")'>{{nums.n_executed}} run</span>
- <span class='{{c_exc.strip}}' onclick='toggle_lines(this, "exc")'>{{nums.n_excluded}} excluded</span>
- <span class='{{c_mis.strip}}' onclick='toggle_lines(this, "mis")'>{{nums.n_missing}} missing</span>
- {% if arcs %}
- <span class='{{c_par.strip}}' onclick='toggle_lines(this, "par")'>{{n_par}} partial</span>
- {% endif %}
- </h2>
- </div>
-</div>
-
-<div id='source'>
-<table cellspacing='0' cellpadding='0'>
-<tr>
-<td class='linenos' valign='top'>
- {% for line in lines %}
- <p class='{{line.class}}'>{{line.number}}</p>
- {% endfor %}
-</td>
-<td class='text' valign='top'>
- {% for line in lines %}
- <p class='{{line.class}}'>{% if line.annotate %}<span class='annotate'>{{line.annotate}}</span>{% endif %}{{line.html}}<span class='strut'> </span></p>
- {% endfor %}
-</td>
-</tr>
-</table>
-</div>
-
-</body>
-</html>
+<!doctype html PUBLIC "-//W3C//DTD html 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> + <meta http-equiv='Content-Type' content='text/html; charset=utf-8'> + {# IE8 rounds line-height incorrectly, and adding this emulateIE7 line makes it right! #} + {# http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/thread/7684445e-f080-4d8f-8529-132763348e21 #} + <meta http-equiv='X-UA-Compatible' content='IE=emulateIE7' /> + <title>Coverage for {{cu.name|escape}}: {{nums.pc_covered|format_pct}}%</title> + <link rel='stylesheet' href='style.css' type='text/css'> + <script type='text/javascript' src='jquery-1.3.2.min.js'></script> + <script type='text/javascript' src='coverage_html.js'></script> + <script type='text/javascript' charset='utf-8'> + jQuery(document).ready(pyfile_ready); + </script> +</head> +<body id='pyfile'> + +<div id='header'> + <div class='content'> + <h1>Coverage for <b>{{cu.name|escape}}</b> : + <span class='pc_cov'>{{nums.pc_covered|format_pct}}%</span> + </h1> + <h2 class='stats'> + {{nums.n_statements}} statements + <span class='{{c_run}}' onclick='toggle_lines(this, "run")'>{{nums.n_executed}} run</span> + <span class='{{c_mis}}' onclick='toggle_lines(this, "mis")'>{{nums.n_missing}} missing</span> + <span class='{{c_exc}}' onclick='toggle_lines(this, "exc")'>{{nums.n_excluded}} excluded</span> + {% if arcs %} + <span class='{{c_par}}' onclick='toggle_lines(this, "par")'>{{n_par}} partial</span> + {% endif %} + </h2> + </div> +</div> + +<div id='source'> + <table cellspacing='0' cellpadding='0'> + <tr> + <td class='linenos' valign='top'> + {% for line in lines %} + <p id='n{{line.number}}' class='{{line.class}}'><a href='#n{{line.number}}'>{{line.number}}</a></p> + {% endfor %} + </td> + <td class='text' valign='top'> + {% for line in lines %} + <p id='t{{line.number}}' class='{{line.class}}'>{% if line.annotate %}<span class='annotate' title='{{line.annotate_title}}'>{{line.annotate}}</span>{% endif %}{{line.html}}<span class='strut'> </span></p> + {% endfor %} + </td> + </tr> + </table> +</div> + +<div id='footer'> + <div class='content'> + <p> + <a class='nav' href='index.html'>« index</a> <a class='nav' href='{{__url__}}'>coverage.py v{{__version__}}</a> + </p> + </div> +</div> + +</body> +</html> diff --git a/coverage/htmlfiles/style.css b/coverage/htmlfiles/style.css index dd6c991a..9a06a2b4 100644 --- a/coverage/htmlfiles/style.css +++ b/coverage/htmlfiles/style.css @@ -20,7 +20,7 @@ body { html>body { font-size: 16px; - } + } /* Set base font size to 12/16 */ p { @@ -53,10 +53,14 @@ a.nav:hover { font-family: "courier new", monospace; } -#footer { +#indexfile #footer { margin: 1em 3em; } +#pyfile #footer { + margin: 1em 1em; + } + #footer .content { padding: 0; font-size: 85%; @@ -89,9 +93,14 @@ h2.stats { cursor: pointer; border-color: #999 #ccc #ccc #999; } -.stats span.hide { +.stats span.hide_run, .stats span.hide_exc, +.stats span.hide_mis, .stats span.hide_par, +.stats span.par.hide_run.hide_par { border-color: #ccc #999 #999 #ccc; } +.stats span.par.hide_run { + border-color: #999 #ccc #ccc #999; +} /* Source file styles */ .linenos p { @@ -100,9 +109,21 @@ h2.stats { padding: 0 .5em; color: #999999; font-family: verdana, sans-serif; - font-size: .625em; /* 10/16 */ + font-size: .625em; /* 10/16 */ line-height: 1.6em; /* 16/10 */ } +.linenos p.highlight { + background: #ffdd00; + } +.linenos p a { + text-decoration: none; + color: #999999; + } +.linenos p a:hover { + text-decoration: underline; + color: #999999; + } + td.text { width: 100%; } @@ -110,14 +131,14 @@ td.text { margin: 0; padding: 0 0 0 .5em; border-left: 2px solid #ffffff; - white-space: nowrap; + white-space: nowrap; } .text p.mis { background: #ffdddd; border-left: 2px solid #ff0000; } -.text p.run { +.text p.run, .text p.run.hide_par { background: #ddffdd; border-left: 2px solid #00ff00; } @@ -125,11 +146,12 @@ td.text { background: #eeeeee; border-left: 2px solid #808080; } -.text p.par { +.text p.par, .text p.par.hide_run { background: #ffffaa; border-left: 2px solid #eeee99; } -.text p.hide { +.text p.hide_run, .text p.hide_exc, .text p.hide_mis, .text p.hide_par, +.text p.hide_run.hide_par { background: inherit; } @@ -140,7 +162,7 @@ td.text { float: right; padding-right: .5em; } -.text p.hide span.annotate { +.text p.hide_par span.annotate { display: none; } |