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
Kirill Smelkov
cython
Commits
b48ad915
Commit
b48ad915
authored
Feb 15, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add intro text and title to annotated HTML code file to make it more user friendly
parent
1f24710e
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 @
b48ad915
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
from
__future__
import
absolute_import
from
__future__
import
absolute_import
import
os
import
os
import
os.path
import
re
import
re
import
codecs
import
codecs
import
textwrap
import
textwrap
...
@@ -99,9 +100,9 @@ class AnnotationCCodeWriter(CCodeWriter):
...
@@ -99,9 +100,9 @@ class AnnotationCCodeWriter(CCodeWriter):
c_file
=
Utils
.
decode_filename
(
os
.
path
.
basename
(
target_filename
))
c_file
=
Utils
.
decode_filename
(
os
.
path
.
basename
(
target_filename
))
html_filename
=
os
.
path
.
splitext
(
target_filename
)[
0
]
+
".html"
html_filename
=
os
.
path
.
splitext
(
target_filename
)[
0
]
+
".html"
with
codecs
.
open
(
html_filename
,
"w"
,
encoding
=
"UTF-8"
)
as
out_buffer
:
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
=
[
outlist
=
[
textwrap
.
dedent
(
u'''
\
textwrap
.
dedent
(
u'''
\
<!DOCTYPE html>
<!DOCTYPE html>
...
@@ -109,6 +110,7 @@ class AnnotationCCodeWriter(CCodeWriter):
...
@@ -109,6 +110,7 @@ class AnnotationCCodeWriter(CCodeWriter):
<html>
<html>
<head>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Cython: {filename}</title>
<style type="text/css">
<style type="text/css">
{css}
{css}
</style>
</style>
...
@@ -117,8 +119,13 @@ class AnnotationCCodeWriter(CCodeWriter):
...
@@ -117,8 +119,13 @@ class AnnotationCCodeWriter(CCodeWriter):
</script>
</script>
</head>
</head>
<body class="cython">
<body class="cython">
<p>Generated by Cython {watermark}</p>
<p><span style="border-bottom: solid 1px grey;">Generated by Cython {watermark}</span></p>
'''
).
format
(
css
=
self
.
_css
(),
js
=
self
.
_js
,
watermark
=
Version
.
watermark
)
<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
:
if
c_file
:
outlist
.
append
(
u'<p>Raw output: <a href="%s">%s</a></p>
\
n
'
%
(
c_file
,
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):
...
@@ -127,7 +134,7 @@ class AnnotationCCodeWriter(CCodeWriter):
def
_save_annotation_footer
(
self
):
def
_save_annotation_footer
(
self
):
return
(
u'</body></html>
\
n
'
,)
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
lines : original cython source code split by lines
generated_code : generated c code keyed by line number in original file
generated_code : generated c code keyed by line number in original file
...
@@ -135,7 +142,7 @@ class AnnotationCCodeWriter(CCodeWriter):
...
@@ -135,7 +142,7 @@ class AnnotationCCodeWriter(CCodeWriter):
c_file : filename in which the c_code has been written
c_file : filename in which the c_code has been written
"""
"""
outlist
=
[]
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_body
(
code
,
generated_code
))
outlist
.
extend
(
self
.
_save_annotation_footer
())
outlist
.
extend
(
self
.
_save_annotation_footer
())
return
''
.
join
(
outlist
)
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