Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
62d77b27
Commit
62d77b27
authored
Apr 26, 2014
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplify HTML templating in annotated file writer
parent
02322340
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
17 deletions
+13
-17
Cython/Compiler/Annotate.py
Cython/Compiler/Annotate.py
+13
-17
No files found.
Cython/Compiler/Annotate.py
View file @
62d77b27
...
...
@@ -101,13 +101,12 @@ body { font-family: courier; font-size: 12; }
out_buffer
.
write
(
self
.
_save_annotation
(
lines
,
code_source_file
,
c_file
))
def
_save_annotation_header
(
self
,
c_file
):
outlist
=
[]
outlist
.
append
(
u'<!DOCTYPE html>
\
n
'
)
outlist
.
append
(
u'<!-- Generated by Cython %s -->
\
n
'
%
Version
.
watermark
)
outlist
.
append
(
u'<html>
\
n
'
)
outlist
.
append
(
u"""
outlist
=
[
u'''
<!DOCTYPE html>
<!-- Generated by Cython {watermark} -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
{css}
</style>
...
...
@@ -115,33 +114,30 @@ body { font-family: courier; font-size: 12; }
{js}
</script>
</head>
"""
.
format
(
css
=
self
.
_css
(),
js
=
self
.
_js
))
outlist
.
append
(
u'<body>
\
n
'
)
outlist
.
append
(
u'<p>Generated by Cython %s</p>
\
n
'
%
Version
.
watermark
)
if
c_file
:
<body>
<p>Generated by Cython {watermark}</p>
\
n
'''
.
format
(
css
=
self
.
_css
(),
js
=
self
.
_js
,
watermark
=
Version
.
watermark
)]
if
c_file
:
outlist
.
append
(
u'<p>Raw output: <a href="%s">%s</a></p>
\
n
'
%
(
c_file
,
c_file
))
return
outlist
def
_save_annotation_footer
(
self
):
return
(
u'</body></html>
\
n
'
,)
def
_save_annotation
(
self
,
lines
,
code_source_file
,
c_file
=
None
):
def
_save_annotation
(
self
,
lines
,
code_source_file
,
c_file
=
None
):
"""
lines : original cython source code split by lines
code_source_file : generated c code keyed by line number in original file
target filename : name of the file in which to store the generated html
c_file : filename in which the c_code has been written
"""
outlist
=
[]
outlist
.
extend
(
self
.
_save_annotation_header
(
c_file
))
outlist
.
extend
(
self
.
_save_annotation_body
(
lines
,
code_source_file
,
c_file
=
None
))
outlist
.
extend
(
self
.
_save_annotation_body
(
lines
,
code_source_file
,
c_file
=
None
))
outlist
.
extend
(
self
.
_save_annotation_footer
())
return
''
.
join
(
outlist
)
def
_save_annotation_body
(
self
,
lines
,
code_source_file
,
c_file
=
None
):
def
_save_annotation_body
(
self
,
lines
,
code_source_file
,
c_file
=
None
):
outlist
=
[]
pos_comment_marker
=
u'/*
\
N{HORIZONTAL ELLIPSIS}
*/
\
n
'
zero_calls
=
dict
((
name
,
0
)
for
name
in
...
...
@@ -172,7 +168,7 @@ body { font-family: courier; font-size: 12; }
score
=
(
5
*
calls
[
'py_c_api'
]
+
2
*
calls
[
'pyx_c_api'
]
+
calls
[
'py_macro_api'
]
+
calls
[
'pyx_macro_api'
])
outlist
.
append
(
u"<pre class='cython line score-%s' onclick='toggleDiv(this)'>"
%
(
score
)
)
outlist
.
append
(
u"<pre class='cython line score-%s' onclick='toggleDiv(this)'>"
%
score
)
outlist
.
append
(
u" %d: "
%
k
)
outlist
.
append
(
line
.
rstrip
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment