minor annotation additions
authorRobert Bradshaw <robertwb@math.washington.edu>
Wed, 16 Jan 2008 06:54:00 +0000 (22:54 -0800)
committerRobert Bradshaw <robertwb@math.washington.edu>
Wed, 16 Jan 2008 06:54:00 +0000 (22:54 -0800)
Cython/Compiler/Annotate.py

index e1f05e491a82f0da082f482a1b438276d4d72829..c377d04d217e87b286fd254f75e253a34de1af03 100644 (file)
@@ -1,10 +1,11 @@
 # Note: Work in progress
 
-
+import os
 import re
+import time
 from StringIO import StringIO
 
-
+import Version
 from Code import CCodeWriter
 
 # need one-characters subsitutions (for now) so offsets aren't off
@@ -112,12 +113,15 @@ function toggleDiv(id) {
 </head>
         """)
         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
         
         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_]+)\(')
         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:
 
@@ -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, 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))
             f.write("<pre class='line' style='background-color: #%s' onclick='toggleDiv(\"line%s\")'>" % (color, k))