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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
386da290
Commit
386da290
authored
Feb 15, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Plain Diff
merge 0.22.x branch into master
parents
1c1fd444
b48ad915
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
6 deletions
+13
-6
Cython/Compiler/Annotate.py
Cython/Compiler/Annotate.py
+13
-6
No files found.
Cython/Compiler/Annotate.py
View file @
386da290
...
...
@@ -3,6 +3,7 @@
from
__future__
import
absolute_import
import
os
import
os.path
import
re
import
codecs
import
textwrap
...
...
@@ -99,9 +100,9 @@ class AnnotationCCodeWriter(CCodeWriter):
c_file
=
Utils
.
decode_filename
(
os
.
path
.
basename
(
target_filename
))
html_filename
=
os
.
path
.
splitext
(
target_filename
)[
0
]
+
".html"
with
codecs
.
open
(
html_filename
,
"w"
,
encoding
=
"UTF-8"
)
as
out_buffer
:
out_buffer
.
write
(
self
.
_save_annotation
(
code
,
generated_code
,
c_file
))
out_buffer
.
write
(
self
.
_save_annotation
(
code
,
generated_code
,
c_file
,
source_filename
))
def
_save_annotation_header
(
self
,
c_file
):
def
_save_annotation_header
(
self
,
c_file
,
source_filename
):
outlist
=
[
textwrap
.
dedent
(
u'''
\
<!DOCTYPE html>
...
...
@@ -109,6 +110,7 @@ class AnnotationCCodeWriter(CCodeWriter):
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Cython: {filename}</title>
<style type="text/css">
{css}
</style>
...
...
@@ -117,8 +119,13 @@ class AnnotationCCodeWriter(CCodeWriter):
</script>
</head>
<body class="cython">
<p>Generated by Cython {watermark}</p>
'''
).
format
(
css
=
self
.
_css
(),
js
=
self
.
_js
,
watermark
=
Version
.
watermark
)
<p><span style="border-bottom: solid 1px grey;">Generated by Cython {watermark}</span></p>
<p>
<span style="background-color: #FFFF00">Yellow lines</span> hint at Python interaction.<br />
Click on a line that starts with a "<code>+</code>" to see the C code that Cython generated for it.
</p>
'''
).
format
(
css
=
self
.
_css
(),
js
=
self
.
_js
,
watermark
=
Version
.
watermark
,
filename
=
os
.
path
.
basename
(
source_filename
)
if
source_filename
else
''
)
]
if
c_file
:
outlist
.
append
(
u'<p>Raw output: <a href="%s">%s</a></p>
\
n
'
%
(
c_file
,
c_file
))
...
...
@@ -127,7 +134,7 @@ class AnnotationCCodeWriter(CCodeWriter):
def
_save_annotation_footer
(
self
):
return
(
u'</body></html>
\
n
'
,)
def
_save_annotation
(
self
,
code
,
generated_code
,
c_file
=
None
):
def
_save_annotation
(
self
,
code
,
generated_code
,
c_file
=
None
,
source_filename
=
None
):
"""
lines : original cython source code split by lines
generated_code : generated c code keyed by line number in original file
...
...
@@ -135,7 +142,7 @@ class AnnotationCCodeWriter(CCodeWriter):
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_header
(
c_file
,
source_filename
))
outlist
.
extend
(
self
.
_save_annotation_body
(
code
,
generated_code
))
outlist
.
extend
(
self
.
_save_annotation_footer
())
return
''
.
join
(
outlist
)
...
...
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