Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Show all reports, not just the first.

  • Loading branch information...
commit 9807823ddfd647e598786b88f37e4f17bfd0023c 1 parent 0023ea0
@eevee authored
Showing with 101 additions and 77 deletions.
  1. +69 −56 libcpychecker/html/make_html.py
  2. +32 −21 libcpychecker/html/style.css
View
125 libcpychecker/html/make_html.py
@@ -11,6 +11,7 @@
from pygments.lexers.compiled import CLexer
from pygments.formatters.html import HtmlFormatter
+import copy
import itertools
from json import load
@@ -55,7 +56,7 @@ def code(self):
"""generate the contents of the #code section"""
# Get ready to use Pygments:
formatter = CodeHtmlFormatter(
- style='default',
+ style='default',
cssclass='source',
linenostart=self.data['function']['lines'][0],
)
@@ -79,6 +80,10 @@ def code(self):
def header(self):
"""Make the header bar of the webpage"""
+ def report_links():
+ for i in range(len(self.data['reports'])):
+ yield E.A(str(i + 1), href="#state{0}".format(i + 1))
+
return E.E.header(
E.ATTR(id='header'),
E.DIV(
@@ -105,7 +110,7 @@ def header(self):
E.DIV(
E.ATTR(id='report-pagination'),
E.H3('Report'),
- '[Report Pagination]',
+ *report_links()
),
E.DIV(
E.ATTR(id='bug-toggle'),
@@ -118,13 +123,13 @@ def header(self):
E.DIV(
E.ATTR(id='prev'),
E.IMG(
- src='images/arrow.png',
+ src='images/arrow-180.png',
),
),
E.DIV(
E.ATTR(id='next'),
E.IMG(
- src='images/arrow-180.png',
+ src='images/arrow.png',
),
),
),
@@ -143,71 +148,79 @@ def footer():
)
def states(self):
- report = self.data['reports'][0]
-
- lis = []
- last_line = None
- for state in report['states']:
- if not state['location'] or not state['message']:
- continue
-
- line = state['location'][0]['line']
- p = E.P(state['message'])
- p.append(
- E.IMG(
- src='images/bug--arrow.png', align='center',
- ),
- )
+ for report in self.data['reports']:
+ lis = []
+ last_line = None
+ for state in report['states']:
+ if not state['location'] or not state['message']:
+ continue
- if lis and line == last_line:
- # Merge adjacent messages for the same line together
- lis[-1].append(p)
- else:
- lis.append(E.LI(
- {'data-line': str(line)},
- p,
- ))
+ line = state['location'][0]['line']
+ p = E.P(state['message'])
+ p.append(
+ E.IMG(
+ src='images/bug--arrow.png', align='center',
+ ),
+ )
- last_line = line
+ if lis and line == last_line:
+ # Merge adjacent messages for the same line together
+ lis[-1].append(p)
+ else:
+ lis.append(E.LI(
+ {'data-line': str(line)},
+ p,
+ ))
- return E.OL(
- {'class': 'states'},
- *lis
- )
+ last_line = line
+
+ final_li = E.LI({'data-line': str(self.data['function']['lines'][-1] - 1)})
+ for note in report['notes']:
+ final_li.append(
+ E.P(note['message']),
+ )
+ lis.append(final_li)
+
+ html = E.OL(
+ {'class': 'states'},
+ *lis
+ )
+
+ yield html, report['message']
def body(self):
"""The BODY of the html document"""
- return E.BODY(
- self.header(),
- E.OL(
- E.ATTR(id='reports'),
+ reports = []
+ code = self.code()
+
+ for i, (state_html, state_problem) in enumerate(self.states(), 1):
+ reports.append(
E.LI(
+ E.ATTR(id="state{0}".format(i)),
E.DIV(
E.CLASS('source'),
- E.DIV(
- E.ATTR(id='error-box'),
- E.SPAN(
- E.CLASS('label'),
- 'Error: ',
+ E.E.header(
+ E.DIV(
+ E.CLASS('error'),
+ state_problem,
),
- ' [error type]',
- ),
- E.DIV(
- E.ATTR(id='report-count'),
- E.SPAN(
- E.CLASS('label'),
- 'Report: ',
+ E.DIV(
+ E.CLASS('report-count'),
+ E.H3('Report'),
+ str(i),
),
- ' [count]',
- ),
- self.code(),
- E.DIV(
- E.CLASS('hr'),
- E.HR(),
),
+ copy.deepcopy(code),
),
- self.states(),
+ state_html,
),
+ )
+
+ return E.BODY(
+ self.header(),
+ E.OL(
+ E.ATTR(id='reports'),
+ *reports
),
self.footer(),
)
@@ -228,7 +241,7 @@ def wrap(self, source, outfile):
else:
yield i, line
yield 0, '</table>'
-
+
def wrap2(self, source, outfile):
"""not used"""
return super(CodeHtmlFormatter, self).wrap(source, outfile)
View
53 libcpychecker/html/style.css
@@ -17,6 +17,14 @@ body {
h1, h2 {
font-weight: bolder;
}
+h3 {
+ display: inline-block;
+ font-weight: bold;
+ margin-right: 0.33em;
+}
+h3:after {
+ content: ':';
+}
hr {
border-bottom: 1px solid #CCC; width: 640px;
}
@@ -29,11 +37,6 @@ img {
#header {
background-color: #0099ff;
}
-#nav {
- padding: 1em;
- background: hsl(0, 0%, 83%);
- color: black;
-}
#reports {
box-flex: 1;
overflow-y: auto;
@@ -54,12 +57,13 @@ img {
display: box;
box-orient: horizontal;
width: 100%;
+ padding: 1em;
+ box-sizing: border-box;
color: white;
}
#title h1,
#title #filename {
box-flex: 1;
- padding: 1em;
vertical-align: middle;
}
#title h1 {
@@ -78,19 +82,12 @@ img {
box-orient: horizontal;
box-align: center;
width: 100%;
+ padding: 0.5em 1em;
box-sizing: border-box;
background-color: #E4E4E4;
border-bottom: 1px solid #7A7A7A;
box-shadow: 0px 0px 2px #000;
}
-#nav h3 {
- display: inline-block;
- font-weight: bold;
- margin-right: 0.33em;
-}
-#nav h3:after {
- content: ':';
-}
#nav #function {
margin-right: 2em;
}
@@ -102,12 +99,10 @@ img {
}
#nav #prev,
#nav #next {
- width: 2em;
- height: 18px;
- text-align: center;
- background-color:#fff;
- border: 1px solid #CCCCCC;
- margin: 0 1em;
+ padding: 0.25em 1em;
+ background-color: white;
+ border: 1px solid #ccc;
+ margin-left: 1em;
}
@@ -151,6 +146,9 @@ img {
box-orient: horizontal;
width: 100%;
}
+#reports > li + li {
+ border-top: 1px dashed hsl(0, 0%, 70%);
+}
@@ -170,15 +168,28 @@ img {
.source {
height: 100%;
- font-family: monospace;
font-size: 12px;
padding: 1em;
background: white;
box-flex: 1;
line-height: 1.33;
}
+.source > header {
+ display: box;
+ box-orient: horizontal;
+ width: 100%;
+}
+.source > header .error {
+ box-flex: 1;
+ color: darkred;
+ font-weight: bold;
+}
+.source > header .report-count {
+}
.source table {
width: 100%;
+ margin-top: 1em;
+ font-family: monospace;
}
#bug-toggle {
Please sign in to comment.
Something went wrong with that request. Please try again.