Skip to content

closes #9: create v2 html by default #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ compiler:
script: make
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq gcc-4.6-plugin-dev python-six python-pygments graphviz
- sudo apt-get install -qq gcc-4.6-plugin-dev python-six python-pygments graphviz python-lxml
Empty file added libcpychecker/html/__init__.py
Empty file.
22 changes: 12 additions & 10 deletions libcpychecker/html/make_html.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python
"""Make our data into HTML!"""
from __future__ import print_function

# Copyright 2012 Buck Golemon <[email protected]>
#
Expand All @@ -17,7 +18,7 @@
# along with this program. If not, see
# <http://www.gnu.org/licenses/>.

import capi
from . import capi

from lxml.html import (
tostring, fragment_fromstring as parse, builder as E
Expand All @@ -29,24 +30,23 @@

from copy import deepcopy
from itertools import islice
from json import load

class HtmlPage(object):
"""Represent one html page."""
def __init__(self, codefile, jsonfile):
def __init__(self, codefile, data):
self.codefile = codefile
self.data = load(jsonfile)
self.data = data

def __str__(self):
html = tostring(self.__html__())
return '<!DOCTYPE html>\n' + html

def __html__(self):
return E.HTML( self.head(), self.body() )
return E.HTML(self.head(), self.body())

def head(self):
"""The HEAD of the html document"""
head = E.HEAD(
head = E.HEAD(
E.META({
'http-equiv': 'Content-Type',
'content': 'text/html; charset=utf-8'
Expand Down Expand Up @@ -86,7 +86,7 @@ def code(self):
open('pygments_c.css', 'w').write(formatter.get_style_defs())

# Use pygments to convert it all to HTML:
code = parse(highlight(self.raw_code(), CLexer(), formatter))
code = parse(highlight(self.raw_code(), CLexer(), formatter))

# linkify the python C-API functions
for name in code.xpath('//span[@class="n"]'):
Expand Down Expand Up @@ -210,7 +210,7 @@ def states(self):
)
break
else:
annotations.insert(0,
annotations.insert(0,
E.LI({'data-line': str(line)}, note)
)

Expand Down Expand Up @@ -271,9 +271,11 @@ def main(argv):
"""our entry point"""
if len(argv) < 3:
return "Please provide code and json filenames."

from json import load
codefile = open(argv[1])
jsonfile = open(argv[2])
print(HtmlPage(codefile, jsonfile))
data = load(open(argv[2]))
print(HtmlPage(codefile, data))

if __name__ == '__main__':
from sys import argv as ARGV
Expand Down
12 changes: 12 additions & 0 deletions libcpychecker/refcounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4383,6 +4383,18 @@ def check_refcounts(fun, dump_traces=False, show_traces=False,
('graphical error report for function %r written out to %r'
% (fun.decl.name, filename)))

filename_v2 = ('%s.%s-refcount-errors.v2.html'
% (gcc.get_dump_base_name(), fun.decl.name))

from libcpychecker.html.make_html import HtmlPage
data = rep.to_json(fun)
srcfile = open(fun.start.file)
htmlfile = open(filename_v2, 'w')
htmlfile.write(str(HtmlPage(srcfile, data)))
htmlfile.close()
srcfile.close()


if show_timings:
end_cpusecs = time.clock()
gcc.inform(fun.start, 'Finished analyzing reference-counting within %s' % fun.decl.name)
Expand Down