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
ec89eb9e
Commit
ec89eb9e
authored
Mar 06, 2018
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce code overhead of inlined "onclick" JS code in annotated HTML file.
Closes #2124.
parent
7cec55ab
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
Cython/Compiler/Annotate.py
Cython/Compiler/Annotate.py
+9
-6
No files found.
Cython/Compiler/Annotate.py
View file @
ec89eb9e
...
...
@@ -106,6 +106,14 @@ class AnnotationCCodeWriter(CCodeWriter):
.cython.code .c_call { color: #0000FF; }
"""
)
# on-click toggle function to show/hide C source code
_onclick_attr
=
' onclick="{}"'
.
format
((
"(function(s){"
" s.display = s.display === 'block' ? 'none' : 'block'"
"})(this.nextElementSibling.style)"
).
replace
(
' '
,
''
)
# poor dev's JS minification
)
def
save_annotation
(
self
,
source_filename
,
target_filename
,
coverage_xml
=
None
):
with
Utils
.
open_source_file
(
source_filename
)
as
f
:
code
=
f
.
read
()
...
...
@@ -242,12 +250,7 @@ class AnnotationCCodeWriter(CCodeWriter):
calls
[
'py_macro_api'
]
+
calls
[
'pyx_macro_api'
])
if
c_code
:
onclick
=
textwrap
.
dedent
(
'''
onclick="
this.nextElementSibling.style.display != 'block' ?
this.nextElementSibling.style.display = 'block' :
this.nextElementSibling.style.display = 'none'
"'''
).
replace
(
'
\
n
'
,
''
)
onclick
=
self
.
_onclick_attr
expandsymbol
=
'+'
else
:
onclick
=
''
...
...
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