Merge pull request #330 from matthiaskrgr/htmlreport_2
Htmlreport: minor cleanup, write index of errors (with links) under "Defect list" in menu for each page
This commit is contained in:
commit
da73627059
|
@ -48,9 +48,9 @@ body {
|
|||
-webkit-box-sizing: content-box;
|
||||
-moz-box-sizing: content-box;
|
||||
box-sizing: content-box;
|
||||
margin: 30px;
|
||||
margin: 10px;
|
||||
overflow: auto;
|
||||
padding: 5px 20px;
|
||||
padding: 5px 10px;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
|
@ -62,24 +62,38 @@ body {
|
|||
float: left;
|
||||
margin-top: 5px;
|
||||
text-align: left;
|
||||
width: 100px;
|
||||
height: auto;
|
||||
width: 150px;
|
||||
height: 75%;
|
||||
position: fixed;
|
||||
overflow: auto;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
#menu > a {
|
||||
display: block;
|
||||
margin-left: 10px;
|
||||
font: 12px;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.highlighttable {
|
||||
background-color:white;
|
||||
z-index: 10;
|
||||
position: relative;
|
||||
margin: -10 px;
|
||||
}
|
||||
|
||||
#content {
|
||||
background-color: white;
|
||||
-webkit-box-sizing: content-box;
|
||||
-moz-box-sizing: content-box;
|
||||
box-sizing: content-box;
|
||||
border-left: thin solid #aaa;
|
||||
float: left;
|
||||
margin: 5px;
|
||||
margin-left: 10px;
|
||||
padding: 0 10px 10px 10px;
|
||||
width: 80%;
|
||||
padding-left: 150px;
|
||||
}
|
||||
|
||||
.linenos {
|
||||
|
@ -108,17 +122,18 @@ HTML_HEAD = """
|
|||
<meta charset="utf-8">
|
||||
<title>Cppcheck - HTML report - %s</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<style>
|
||||
%s
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="page">
|
||||
<div id="header">
|
||||
<h1>Cppcheck report - %s</h1>
|
||||
</div>
|
||||
<div id="menu">
|
||||
<a href="index.html">Defect list</a>
|
||||
<div id="menu" dir="rtl">
|
||||
<a href="index.html">Defect list</a>
|
||||
<br>
|
||||
"""
|
||||
|
||||
HTML_HEAD_END = """
|
||||
</div>
|
||||
<div id="content">
|
||||
"""
|
||||
|
@ -303,9 +318,12 @@ if __name__ == '__main__':
|
|||
'w') as output_file:
|
||||
output_file.write(HTML_HEAD %
|
||||
(options.title,
|
||||
htmlFormatter.get_style_defs('.highlight'),
|
||||
#htmlFormatter.get_style_defs('.highlight'),
|
||||
options.title))
|
||||
for error in errors:
|
||||
output_file.write("<a href='%s#line-%d'> %s %s</a>" % (data['htmlfile'], error['line'], error['id'], error['line']))
|
||||
|
||||
output_file.write(HTML_HEAD_END)
|
||||
lexer = guess_lexer_for_filename(source_filename, '')
|
||||
if options.source_encoding:
|
||||
lexer.encoding = options.source_encoding
|
||||
|
@ -323,13 +341,14 @@ if __name__ == '__main__':
|
|||
print('Creating index.html')
|
||||
with io.open(os.path.join(options.report_dir, 'index.html'),
|
||||
'w') as output_file:
|
||||
output_file.write(HTML_HEAD % (options.title, '', options.title))
|
||||
output_file.write('<table>')
|
||||
output_file.write(HTML_HEAD % (options.title, options.title))
|
||||
output_file.write(HTML_HEAD_END)
|
||||
output_file.write(' <table>\n')
|
||||
output_file.write(
|
||||
'<tr><th>Line</th><th>Id</th><th>Severity</th><th>Message</th></tr>')
|
||||
' <tr><th>Line</th><th>Id</th><th>Severity</th><th>Message</th></tr>')
|
||||
for filename, data in sorted(files.items()):
|
||||
output_file.write(
|
||||
"<tr><td colspan='4'><a href='%s'>%s</a></td></tr>" %
|
||||
"\n <tr><td colspan='4'><a href='%s'>%s</a></td></tr>" %
|
||||
(data['htmlfile'], filename))
|
||||
for error in data['errors']:
|
||||
if error['severity'] == 'error':
|
||||
|
@ -339,15 +358,15 @@ if __name__ == '__main__':
|
|||
|
||||
if error['id'] == 'missingInclude':
|
||||
output_file.write(
|
||||
'<tr><td></td><td>%s</td><td>%s</td><td>%s</td></tr>' %
|
||||
'\n <tr><td></td><td>%s</td><td>%s</td><td>%s</td></tr>' %
|
||||
(error['id'], error['severity'], error['msg']))
|
||||
else:
|
||||
output_file.write(
|
||||
"<tr><td><a href='%s#line-%d'>%d</a></td><td>%s</td><td>%s</td><td %s>%s</td></tr>" %
|
||||
"\n <tr><td><a href='%s#line-%d'>%d</a></td><td>%s</td><td>%s</td><td %s>%s</td></tr>" %
|
||||
(data['htmlfile'], error['line'], error['line'],
|
||||
error['id'], error['severity'], error_class,
|
||||
error['msg']))
|
||||
output_file.write('</table>')
|
||||
output_file.write('\n </table>')
|
||||
output_file.write(HTML_FOOTER % contentHandler.versionCppcheck)
|
||||
|
||||
print('Creating style.css file')
|
||||
|
|
Loading…
Reference in New Issue