summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2010-03-14 09:29:54 -0400
committerNed Batchelder <ned@nedbatchelder.com>2010-03-14 09:29:54 -0400
commit29cd74524abf7568452da7e59903759c267635ed (patch)
tree654d8a4bf1f8f2d7a99ac08d4f0290bd84f3b67c
parent9f6fa1c7806e7802572b28e8ecbd57a9afe5ec21 (diff)
downloadpython-coveragepy-29cd74524abf7568452da7e59903759c267635ed.tar.gz
HTML line numbers are clickable, and highlight the line on arrival. Also, noticed that IE8 didn't line up the line number properly, so added an unfortunate meta tag to make it right. Closes issue #55.
-rw-r--r--CHANGES.txt3
-rw-r--r--coverage/htmlfiles/coverage_html.js8
-rw-r--r--coverage/htmlfiles/pyfile.html10
-rw-r--r--coverage/htmlfiles/style.css16
4 files changed, 33 insertions, 4 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 098740f..8e63d85 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -11,6 +11,9 @@ Next version
rather than increasing the executed lines to varying targets. Once
suggested, this seemed blindingly obvious.
+- Line numbers in HTML source pages are clickable, linking directly to that
+ line, which is highlighted on arrival.
+
- Source files with DOS line endings are now properly tokenized for syntax
coloring on non-DOS machines. Fixes `issue 53`_.
diff --git a/coverage/htmlfiles/coverage_html.js b/coverage/htmlfiles/coverage_html.js
index 2acba5c..b6bde6c 100644
--- a/coverage/htmlfiles/coverage_html.js
+++ b/coverage/htmlfiles/coverage_html.js
@@ -65,6 +65,14 @@ function index_page_ready($) {
// -- 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;
diff --git a/coverage/htmlfiles/pyfile.html b/coverage/htmlfiles/pyfile.html
index 209887b..4aa4309 100644
--- a/coverage/htmlfiles/pyfile.html
+++ b/coverage/htmlfiles/pyfile.html
@@ -1,11 +1,17 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<!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>
@@ -31,7 +37,7 @@
<tr>
<td class='linenos' valign='top'>
{% for line in lines %}
- <p id='n{{line.number}}' class='{{line.class}}'>{{line.number}}</p>
+ <p id='n{{line.number}}' class='{{line.class}}'><a href='#n{{line.number}}'>{{line.number}}</a></p>
{% endfor %}
</td>
<td class='text' valign='top'>
diff --git a/coverage/htmlfiles/style.css b/coverage/htmlfiles/style.css
index 25e7d11..a9ab535 100644
--- a/coverage/htmlfiles/style.css
+++ b/coverage/htmlfiles/style.css
@@ -5,8 +5,8 @@ html, body, h1, h2, h3, p, td, th {
padding: 0;
border: 0;
outline: 0;
- font-weight: inherit;
- font-style: inherit;
+ font-weight: normal;
+ font-style: normal;
font-size: 100%;
font-family: inherit;
vertical-align: baseline;
@@ -108,6 +108,18 @@ h2.stats {
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%;
}