Commit 6e308d10 authored by Robert Bradshaw's avatar Robert Bradshaw

minor annotation additions

parent 3716a375
# Note: Work in progress # Note: Work in progress
import os
import re import re
import time
from StringIO import StringIO from StringIO import StringIO
import Version
from Code import CCodeWriter from Code import CCodeWriter
# need one-characters subsitutions (for now) so offsets aren't off # need one-characters subsitutions (for now) so offsets aren't off
...@@ -112,12 +113,15 @@ function toggleDiv(id) { ...@@ -112,12 +113,15 @@ function toggleDiv(id) {
</head> </head>
""") """)
f.write('<body>\n') f.write('<body>\n')
f.write('<p>Generated by Cython %s on %s\n' % (Version.version, time.asctime()))
c_file = os.path.basename(filename)[:-3] + 'c'
f.write('<p>Raw output: <a href="%s">%s</a>\n' % (c_file, c_file))
k = 0 k = 0
py_c_api = re.compile('(Py[A-Z][a-z]+_[A-Z][a-z][A-Za-z_]+)') py_c_api = re.compile('(Py[A-Z][a-z]+_[A-Z][a-z][A-Za-z_]+)')
pyx_api = re.compile('(__Pyx[A-Za-z_]+)\(') pyx_api = re.compile('(__Pyx[A-Za-z_]+)\(')
py_marco_api = re.compile('(Py[A-Za-z]*_[A-Z][A-Z_]+)') py_marco_api = re.compile('(Py[A-Za-z]*_[A-Z][A-Z_]+)')
error_goto = re.compile(r'(if .*? \{__pyx_filename = .*goto __pyx_L\w+;\})') error_goto = re.compile(r'((; *if .*)? \{__pyx_filename = .*goto __pyx_L\w+;\})')
for line in lines: for line in lines:
...@@ -132,6 +136,8 @@ function toggleDiv(id) { ...@@ -132,6 +136,8 @@ function toggleDiv(id) {
code, macro_api_calls = py_marco_api.subn(r"<span class='py_macro_api'>\1</span>", code) code, macro_api_calls = py_marco_api.subn(r"<span class='py_macro_api'>\1</span>", code)
code, error_goto_calls = error_goto.subn(r"<span class='error_goto'>\1</span>", code) code, error_goto_calls = error_goto.subn(r"<span class='error_goto'>\1</span>", code)
code = code.replace("<span class='error_goto'>;", ";<span class='error_goto'>")
color = "FFFF%02x" % int(255/(1+(5*c_api_calls+2*pyx_api_calls+macro_api_calls)/10.0)) color = "FFFF%02x" % int(255/(1+(5*c_api_calls+2*pyx_api_calls+macro_api_calls)/10.0))
f.write("<pre class='line' style='background-color: #%s' onclick='toggleDiv(\"line%s\")'>" % (color, k)) f.write("<pre class='line' style='background-color: #%s' onclick='toggleDiv(\"line%s\")'>" % (color, k))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment