diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2015-02-15 12:28:29 +0100 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2015-02-15 12:28:29 +0100 |
commit | b48ad91509291176e40542e575ab69debf479225 (patch) | |
tree | dcc62ccdb62bd1fadadf835302f621ae247b79ce | |
parent | 1f24710e8e3a9127964d84d74d24e80150a306b4 (diff) | |
download | cython-b48ad91509291176e40542e575ab69debf479225.tar.gz |
add intro text and title to annotated HTML code file to make it more user friendly
-rw-r--r-- | Cython/Compiler/Annotate.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/Cython/Compiler/Annotate.py b/Cython/Compiler/Annotate.py index 9ea9ce0d7..7a330195c 100644 --- a/Cython/Compiler/Annotate.py +++ b/Cython/Compiler/Annotate.py @@ -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) |