diff --git a/libcpychecker_html/extlib/prefixfree-1.0.4.min.js b/libcpychecker_html/extlib/prefixfree-1.0.4.min.js deleted file mode 100644 index b1db0326..00000000 --- a/libcpychecker_html/extlib/prefixfree-1.0.4.min.js +++ /dev/null @@ -1,11 +0,0 @@ -// StyleFix 1.0.2 & PrefixFree 1.0.4 / by Lea Verou / MIT license -(function(){function h(a,b){return[].slice.call((b||document).querySelectorAll(a))}if(window.addEventListener){var b=window.StyleFix={link:function(a){try{if("stylesheet"!==a.rel||a.hasAttribute("data-noprefix"))return}catch(c){return}var d=a.href||a.getAttribute("data-href"),f=d.replace(/[^\/]+$/,""),g=a.parentNode,e=new XMLHttpRequest;e.open("GET",d);e.onreadystatechange=function(){if(4===e.readyState){var c=e.responseText;if(c&&a.parentNode){c=b.fix(c,!0,a);f&&(c=c.replace(/url\(((?:"|')?)(.+?)\1\)/gi, -function(a,c,b){return!/^([a-z]{3,10}:|\/|#)/i.test(b)?'url("'+f+b+'")':a}),c=c.replace(RegExp("\\b(behavior:\\s*?url\\('?\"?)"+f,"gi"),"$1"));var d=document.createElement("style");d.textContent=c;d.media=a.media;d.disabled=a.disabled;d.setAttribute("data-href",a.getAttribute("href"));g.insertBefore(d,a);g.removeChild(a)}}};e.send(null);a.setAttribute("data-inprogress","")},styleElement:function(a){var c=a.disabled;a.textContent=b.fix(a.textContent,!0,a);a.disabled=c},styleAttribute:function(a){var c= -a.getAttribute("style"),c=b.fix(c,!1,a);a.setAttribute("style",c)},process:function(){h('link[rel="stylesheet"]:not([data-inprogress])').forEach(StyleFix.link);h("style").forEach(StyleFix.styleElement);h("[style]").forEach(StyleFix.styleAttribute)},register:function(a,c){(b.fixers=b.fixers||[]).splice(void 0===c?b.fixers.length:c,0,a)},fix:function(a,c){for(var d=0;d + # open('pygments_c.css', 'w').write(formatter.get_style_defs()) # Use pygments to convert it all to HTML: @@ -127,7 +113,6 @@ def code(self): return code - def header(self): """Make the header bar of the webpage""" @@ -136,40 +121,35 @@ def header(self): E.DIV( E.ATTR(id='title'), E.H1( - 'GCC Python Plugin', + E.A( + 'GCC Python Plugin', + href='http://gcc-python-plugin.readthedocs.org/', + ), ), E.DIV( - E.ATTR(id='filename'), + E.ATTR(id='info'), E.SPAN( E.CLASS('label'), 'Filename: ', ), self.data['filename'], - ), - ), - E.E.nav( - E.ATTR(id='nav'), - E.DIV( - E.ATTR(id='function'), - E.H3('Function'), + E.SPAN( + E.CLASS('label'), + 'Function: ', + ), self.data['function']['name'], ), E.DIV( E.ATTR(id='report-pagination'), - E.H3('Report'), + E.SPAN( + E.CLASS('label'), + 'Report: ', + ), *( E.A(str(i + 1), href="#state{0}".format(i + 1)) for i in range(len(self.data['reports'])) ) ), - E.DIV( - E.ATTR(id='bug-toggle'), - E.IMG( - src=data_uri('image/png', 'images/bug.png'), - ), - E.H3('Bug'), - ' [count]', - ), E.DIV( E.ATTR(id='prev'), E.IMG( @@ -183,7 +163,26 @@ def header(self): ), ), ), - ) + ) + + @staticmethod + def footer(): + """put non-essential javascript in the footer""" + return E.E.footer( + # zepto is the one resource we don't embed. + # It's (relatively) big, and non-essential. + E.SCRIPT( + src=( + 'http://cdnjs.cloudflare.com' + '/ajax/libs/zepto/1.1.3/zepto.js' + ), + type='text/javascript', + ), + E.SCRIPT( + file_contents('script.js'), + type='text/javascript', + ), + ) def states(self): """Return an ordered-list of states, for each report.""" @@ -213,7 +212,7 @@ def states(self): for note in report['notes']: line = note['location'][0]['line'] - note = E.P({'class':'note'}, note['message']) + note = E.P({'class': 'note'}, note['message']) # Put this note on the last matching state, if possible for ann in reversed(tuple(annotations)): @@ -223,13 +222,11 @@ def states(self): break elif line > annline: ann.addnext( - E.LI({'data-line': str(line)}, note) + E.LI({'data-line': str(line)}, note) ) break else: - annotations.insert(0, - E.LI({'data-line': str(line)}, note) - ) + annotations.insert(0, E.LI({'data-line': str(line)}, note)) yield annotations, report['message'] @@ -240,38 +237,44 @@ def body(self): for i, (state_html, state_problem) in enumerate(self.states(), 1): reports.append( - E.LI( - E.ATTR(id="state{0}".format(i)), + E.LI( + E.ATTR(id="state{0}".format(i)), + E.E.header( + E.DIV( + E.CLASS('error'), + state_problem, + ), + E.DIV( + E.CLASS('report-count'), + E.H3('Report'), + str(i), + ), + ), + E.DIV( + E.CLASS('body'), E.DIV( E.CLASS('source'), - E.E.header( - E.DIV( - E.CLASS('error'), - state_problem, - ), - E.DIV( - E.CLASS('report-count'), - E.H3('Report'), - str(i), - ), - ), deepcopy(code), ), state_html, ), + ), ) return E.BODY( self.header(), reports, + self.footer(), ) + def data_uri(mimetype, filename): """represent a file as a data uri""" data = open(join(HERE, filename), 'rb').read() data = data.encode('base64').replace('\n', '') return 'data:%s;base64,%s' % (mimetype, data) + def file_contents(filename): """Add a leading newline to make the first line show up in the right spot. """ @@ -283,7 +286,7 @@ class CodeHtmlFormatter(HtmlFormatter): def wrap(self, source, outfile): yield 0, '' % ( - self.linenostart, + self.linenostart, ) for i, line in source: if i == 1: @@ -295,6 +298,7 @@ def wrap(self, source, outfile): yield i, line yield 0, '
' + def main(argv): """our entry point""" if len(argv) < 3: diff --git a/libcpychecker_html/script.js b/libcpychecker_html/script.js index 88129d0a..517f9e7d 100644 --- a/libcpychecker_html/script.js +++ b/libcpychecker_html/script.js @@ -79,8 +79,8 @@ $(function() { $.each(source_flow, function(idx, flow) { // Lines mentioned in the flow get dots... if (flow.length && flow[0].lineno == lineno) { - var $new_cell = $('', { "class": "flow-line" }).html('​'); - $new_cell.append($('', { "class": "flow-dot" })); + var $new_cell = $('', { "class": "flow-line" }); + $new_cell.append($('', { "class": "flow-dot" }).html('​')); $paths = $paths.add($new_cell); $selectables = $selectables.add($new_cell).add(flow[0].$state); started[idx] = true; diff --git a/libcpychecker_html/style-noprefix.css b/libcpychecker_html/style-noprefix.css new file mode 100644 index 00000000..19b568b1 --- /dev/null +++ b/libcpychecker_html/style-noprefix.css @@ -0,0 +1,390 @@ +/* Copyright 2012 Buck Golemon + * with help from http://jsfiddle.net/simevidas/udyTs/show/light/ + + This is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see + . +*/ +html, body { + width: 100%; + background: black; +} +html { + height: 100%; +} +body { + font: 12px "DejaVu Sans", "Bitstream Vera Sans", "Ubuntu Sans", Helvetica, Arial, sans-serif; + color: black; + background: #EBEBEB; + height: 100%; + + display: flex; + flex-direction: column; +} +h1, h2 { + font-weight: bolder; +} +h1 a { + text-decoration: none; + color: inherit; +} +h3 { + display: inline-block; + font-weight: bold; + margin-right: 0.33em; +} +h3:after { + content: ':'; +} +hr { + border-bottom: 1px solid #CCC; width: 640px; +} +img { + vertical-align: middle; +} + + +/* Main page layout */ +#header { + background-color: #0099ff; +} +#reports { + flex: 1; + overflow-y: auto; + overflow-x: hidden; +} + + +/* Header */ +#title { + display:flex; + flex-direction: row; + align-items: center; + padding: 0.5em 1em; + box-sizing: border-box; + color: white; + border-bottom: 1px solid #7A7A7A; + box-shadow: 0px 0px 2px #000; +} +#title h1 { + font-size: 1.2em; + text-shadow: 0 1px 1px black; +} +#title #info { + flex: 1; + align-items: flex-end; + text-shadow: 0 1px 0 black; +} + +/* Navigation */ +#nav { + display: flex; + flex-direction: row; + align-items: center; + padding: 0.5em 1em; + box-sizing: border-box; + background-color: #E4E4E4; + border-bottom: 1px solid #7A7A7A; + box-shadow: 0px 0px 2px #000; +} +#report-pagination a { + padding: 4px; +} +#prev, +#next { + padding: 0.25em 1em; + background-color: white; + border: 1px solid #ccc; + margin-left: 1em; +} + + +#header-container { + border-bottom:1px solid #7A7A7A; +} + +#header ul { + margin: 0; + padding: 0; + list-style: none; + position: absolute; + top: 35px; + right: 0; +} + +#header ul li { + float: left; + margin-right: 5px; +} + +#header ul li a{ + color: #90b874; + font-weight: bold; + font-size: 1.4em; + margin-right: 5px; + text-decoration: none; +} + +#header ul li a:hover { + color: #beffbf; +} + + + + + +#reports > li { + display: flex; + flex-direction: column; + width: 100%; +} +#reports > li + li { + border-top: 1px dashed hsl(0, 0%, 70%); +} +#reports > li header { + display: flex; + flex-direction: row; + padding: .5em; + background: white; +} +#reports > li header .error { + flex: 1; + color: darkred; + font-weight: bold; + text-align: center; +} +#reports > li .body { + display: flex; + flex-direction: row; +} + + + +.label { + font-size: 12px; + font-weight:bolder; + margin-left: 2em; +} + +#main { + background: red; + display: flex; +} + + +.source { + height: 100%; + font-size: 12px; + padding: 1em; + background: white; + line-height: 1.33; + overflow-x: auto; + border-right: 1px solid hsl(0, 0%, 70%); + flex: 1 0 40em; +} +.source table { + width: 100%; + margin-top: 1em; + font-family: monospace; +} + +#code { + background: blue; + min-width: 300px; + flex: 2; +} +.source tr:nth-child(2n) { + background: hsl(0, 0%, 93%); +} + +#container { + width: 1000px; + margin: 0 auto; + font-size:12px; + overflow: auto; + padding: 70px 0 0px; + background-color:#f8f8f8; +} + +#content { + float: left; + width: 660px; + padding-top:20px; + padding-left:20px; + padding-right:10px; +} + + +#content table.source { + clear: left; + margin: 2em 0; +} + +#content .source td { + font-family: monospace; + white-space: pre; + min-height: 1em; + line-height: 20px; +} + + +.fnc-report { + font-size:12px; +} + +#error-box { + font-size:12px; + font-color:000; + float:left; +} + +#report-count{ + font-size:12px; + float:right; +} + +/* Left column: source code */ +.source tr:hover { + background: hsl(210, 30%, 87%); +} +.source .lineno { + padding-right: 0.5em; + text-align: right; + user-select: none; + color: hsl(0, 0%, 60%); + vertical-align: middle; +} +.source .code { + white-space: pre; +} + + +/* Right column: list of states */ +.states { + font-size: 12px; + top: 0.5em; + height: 100%; + min-width: 25em; + border-left: 1px solid hsl(0, 0%, 70%); + border-top: 2px solid #B2B2B2 +} +.states li { + position: relative; + padding: 0.5em; + margin: 1em; + background: white; + border: 1px solid hsl(0, 0%, 80%); +} +.states li.new-subflow { + border-top-width: 4px; +} +.states h2 { + float: right; + padding: 0.33em 0.5em; + margin: -0.5em -0.5em 0.5em 0.5em; + background: hsl(0, 0%, 80%); + color: hsl(0, 0%, 30%); + border-radius: 0 0 0 0.5em; +} +.states p { + line-height: 1.5; +} +.states p + p { + margin-top: 0.5em; +} + +var { + color: navy; +} +var.leak { + color: darkred; + font-weight: bold; + background: hsl(0, 100%, 90%); +} + +.flow-line { + background: hsl(210, 80%, 60%); + background-clip: content-box; +} +.flow-empty, .flow-line { + padding: 0 5px; + text-align: center; +} +.flow-dot { + display: inline-block; + background: hsl(210, 80%, 60%); + outline: 1px solid rgba(100%, 100%, 100%, 0.5); + height: 6px; + width: 6px; + margin: -2px; + border-radius: 100px; + outline-radius: 100px; + vertical-align: middle; +} + +/* Selection overrides */ +.states li { + left: 0; + transition-property: left, background-color, border-color; +} +.source tr +.states li h2 { + transition-property: background-color; +} +td .flow-dot, +.states li, +.states li h2 { + transition-duration: 0.25s; + transition-timing-function: ease-out; +} + +td:hover .flow-dot, +td.selected .flow-dot { + height: 10px; + width: 10px; + background: hsl(30, 80%, 60%); + margin: -5px; +} + +.source tr:hover, +.source tr.selected { + background-color: #ffe181; +} +.states li:hover, +.states li.selected { + left: -2em; + background-color: #fef8cb; + border-color: #ffe181; +} +.states li:hover h2, +.states li.selected h2 { + background-color: #ffe181; +} + +#notes { + background: yellow; + min-width: 200px; +} + +.note { + font-weight: bolder; +} +.note:first-of-type::before { + /* content: url('images/exclamation.png'); + * to regenerate: + * from libcpychecker_html.make_html import data_uri + * data_uri('image/png', 'images/exclamation.png') + */ + content: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAjBJREFUeNqkk0trE1EUx8/cO49OfGTSRNJMYsA0aVonoYh13YW71uJCKFQhKqibfgFLwYULsR/AhY+VG1d+C124kJiFIGipmoIZNUXtZDKTycz1njGpaRNU8MJv7txzzv/c5xEYY/A/TRQEAW5c5KwM+aKcR73/a5zvg84HT371wv07Apwuj0x+PZW/vArA4NO7x/f4+OGoIHLKAAiC/fBdHadSbCGZPTeTzC7OUElbQNvBOISMMnIqeqFSYs57mTkfZD1/qYS2f0rAZ5pVDmXnY/FSbn3jM6xvfAEtfjKnRDLz6BtK4PPPADi+ms6vGK71lti2DUintUVSJ84b6OvF7GlI4PNMPVgAZ49oxpyqRnXf+wGWZYX4ngWRiKYfPpqfw5hBjej7eweqCkSo6JOLhmd/hI7vQLVaBdM0YXt1FgK2CeJ40fCbmxUWsGc8vh3egtcFQPhyLsQnzpQJcbVmuw5mawtqtRo0Gg3wJQeY7ALIrqZEM2WM7esIPkROAgR5OZEpTTV3X4IXNEGiLnw1b4fItBNCBQuiqeQUA7qMGtSSLt8C38aVRLo47QVvVJFYoFAnJJG8FdIfI6rSVWMTx6ZRg1rS7UKeSspSMj2Wk+AbjPGZ+vTboA1JZbQcEcUl1Iq2zdZyxURBpruUMTzR38Vl79wM+9bO0/3vlwLVs+OF16/MNdFug/vi+Xadm+vDL/3uHyuR16Er4E3gKvEaOTLa/1LBuEQPF8hxfgowAINnMqTBUH7hAAAAAElFTkSuQmCC'); + padding: 5px; +} diff --git a/libcpychecker_html/style.css b/libcpychecker_html/style.css index 689a8612..8939fe0b 100755 --- a/libcpychecker_html/style.css +++ b/libcpychecker_html/style.css @@ -1,4 +1,5 @@ /* Copyright 2012 Buck Golemon + * with help from http://jsfiddle.net/simevidas/udyTs/show/light/ This is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -27,12 +28,23 @@ body { background: #EBEBEB; height: 100%; - display: box; - box-orient: vertical; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-box-orient: vertical; + -webkit-box-direction: normal; + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; } h1, h2 { font-weight: bolder; } +h1 a { + text-decoration: none; + color: inherit; +} h3 { display: inline-block; font-weight: bold; @@ -54,7 +66,10 @@ img { background-color: #0099ff; } #reports { - box-flex: 1; + -webkit-box-flex: 1; + -webkit-flex: 1; + -ms-flex: 1; + flex: 1; overflow-y: auto; overflow-x: hidden; } @@ -62,52 +77,73 @@ img { /* Header */ #title { - display: box; - box-orient: horizontal; - width: 100%; - padding: 0.5em; + display:-webkit-box; + display:-webkit-flex; + display:-ms-flexbox; + display:flex; + -webkit-box-orient: horizontal; + -webkit-box-direction: normal; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; + -webkit-box-align: center; + -webkit-align-items: center; + -ms-flex-align: center; + align-items: center; + padding: 0.5em 1em; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; box-sizing: border-box; color: white; -} -#title h1, -#title #filename { - box-flex: 1; - vertical-align: middle; + border-bottom: 1px solid #7A7A7A; + -webkit-box-shadow: 0px 0px 2px #000; + box-shadow: 0px 0px 2px #000; } #title h1 { font-size: 1.2em; text-shadow: 0 1px 1px black; } -#title #filename { - box-flex: 1; - text-align: right; +#title #info { + -webkit-box-flex: 1; + -webkit-flex: 1; + -ms-flex: 1; + flex: 1; + -webkit-box-align: end; + -webkit-align-items: flex-end; + -ms-flex-align: end; + align-items: flex-end; text-shadow: 0 1px 0 black; } /* Navigation */ #nav { - display: box; - box-orient: horizontal; - box-align: center; - width: 100%; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-box-orient: horizontal; + -webkit-box-direction: normal; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; + -webkit-box-align: center; + -webkit-align-items: center; + -ms-flex-align: center; + align-items: center; padding: 0.5em 1em; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; box-sizing: border-box; background-color: #E4E4E4; border-bottom: 1px solid #7A7A7A; + -webkit-box-shadow: 0px 0px 2px #000; box-shadow: 0px 0px 2px #000; } -#nav #function { - margin-right: 2em; -} -#nav #report-pagination a { +#report-pagination a { padding: 4px; } -#nav #bug-toggle { - box-flex: 1; - text-align: right; -} -#nav #prev, -#nav #next { +#prev, +#next { padding: 0.25em 1em; background-color: white; border: 1px solid #ccc; @@ -115,7 +151,6 @@ img { } - #header-container { border-bottom:1px solid #7A7A7A; } @@ -151,52 +186,83 @@ img { #reports > li { - display: box; - box-orient: horizontal; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-box-orient: vertical; + -webkit-box-direction: normal; + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; width: 100%; } #reports > li + li { border-top: 1px dashed hsl(0, 0%, 70%); } - - - +#reports > li header { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-box-orient: horizontal; + -webkit-box-direction: normal; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; + padding: .5em; + background: white; +} +#reports > li header .error { + -webkit-box-flex: 1; + -webkit-flex: 1; + -ms-flex: 1; + flex: 1; + color: darkred; + font-weight: bold; + text-align: center; +} +#reports > li .body { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-box-orient: horizontal; + -webkit-box-direction: normal; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; +} .label { - font-color:000; font-size: 12px; font-weight:bolder; + margin-left: 2em; } #main { background: red; - display: box; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; } + .source { height: 100%; font-size: 12px; padding: 1em; background: white; line-height: 1.33; - min-width: 40em; - box-flex: 3; overflow-x: auto; border-right: 1px solid hsl(0, 0%, 70%); -} -.source > header { - display: box; - box-orient: horizontal; - width: 100%; -} -.source > header .error { - box-flex: 1; - color: darkred; - font-weight: bold; -} -.source > header .report-count { + -webkit-box-flex: 1; + -webkit-flex: 1 0 40em; + -ms-flex: 1 0 40em; + flex: 1 0 40em; } .source table { width: 100%; @@ -204,27 +270,18 @@ img { font-family: monospace; } -#bug-toggle { - color:#000; - font-size:12px; - float:right; - vertical-align:middle; -} - #code { background: blue; min-width: 300px; - box-flex: 2; + -webkit-box-flex: 2; + -webkit-flex: 2; + -ms-flex: 2; + flex: 2; } .source tr:nth-child(2n) { background: hsl(0, 0%, 93%); } -#bug-toggle img{ - padding-right:5px; - vertical-align:middle; -} - #container { width: 1000px; margin: 0 auto; @@ -278,6 +335,9 @@ img { .source .lineno { padding-right: 0.5em; text-align: right; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; user-select: none; color: hsl(0, 0%, 60%); vertical-align: middle; @@ -294,7 +354,7 @@ img { height: 100%; min-width: 25em; border-left: 1px solid hsl(0, 0%, 70%); - box-flex: 1; + border-top: 2px solid #B2B2B2 } .states li { position: relative; @@ -332,12 +392,12 @@ var.leak { .flow-line { background: hsl(210, 80%, 60%); + -webkit-background-clip: content-box; background-clip: content-box; } .flow-empty, .flow-line { - width: 2px; padding: 0 5px; - vertical-align: middle; + text-align: center; } .flow-dot { display: inline-block; @@ -345,42 +405,51 @@ var.leak { outline: 1px solid rgba(100%, 100%, 100%, 0.5); height: 6px; width: 6px; - margin: 0 -2px; + margin: -2px; border-radius: 100px; outline-radius: 100px; + vertical-align: middle; } /* Selection overrides */ .states li { left: 0; + -webkit-transition-property: left, background-color, border-color; transition-property: left, background-color, border-color; } .source tr .states li h2 { + -webkit-transition-property: background-color; transition-property: background-color; } td .flow-dot, .states li, .states li h2 { + -webkit-transition-duration: 0.25s; transition-duration: 0.25s; + -webkit-transition-timing-function: ease-out; transition-timing-function: ease-out; } +td:hover .flow-dot, td.selected .flow-dot { height: 10px; width: 10px; - margin: 0 -4px; background: hsl(30, 80%, 60%); + margin: -5px; } +.source tr:hover, .source tr.selected { background-color: #ffe181; } +.states li:hover, .states li.selected { left: -2em; background-color: #fef8cb; border-color: #ffe181; } +.states li:hover h2, .states li.selected h2 { background-color: #ffe181; }