[py-svn] r37602 - in py/trunk/py/apigen/source: . testing
guido at codespeak.net
guido at codespeak.net
Tue Jan 30 15:46:59 CET 2007
Author: guido
Date: Tue Jan 30 15:46:57 2007
New Revision: 37602
Modified:
py/trunk/py/apigen/source/color.py
py/trunk/py/apigen/source/html.py
py/trunk/py/apigen/source/testing/test_color.py
Log:
Fixed support for files ending on a comment rather than a newline, fixed some
unicode() call so it's not done on objects that are already unicode.
Modified: py/trunk/py/apigen/source/color.py
==============================================================================
--- py/trunk/py/apigen/source/color.py (original)
+++ py/trunk/py/apigen/source/color.py Tue Jan 30 15:46:57 2007
@@ -4,7 +4,7 @@
class PythonSchema(object):
""" contains information for syntax coloring """
- comment = [('#', '\n')]
+ comment = [('#', '\n'), ('#', '$')]
multiline_string = ['"""', "'''"]
string = ['"""', "'''", '"', "'"]
# XXX not complete
@@ -125,7 +125,6 @@
break
return data, token
-
def _check_comments(self, data):
# fortunately we don't have to deal with multi-line comments
token = None
Modified: py/trunk/py/apigen/source/html.py
==============================================================================
--- py/trunk/py/apigen/source/html.py (original)
+++ py/trunk/py/apigen/source/html.py Tue Jan 30 15:46:57 2007
@@ -46,7 +46,10 @@
if type(item) in [str, unicode]:
tokens = tokenizer.tokenize(item)
for t in tokens:
- data = unicode(t.data, encoding)
+ if not isinstance(t.data, unicode):
+ data = unicode(t.data, encoding)
+ else:
+ data = t.data
if t.type in ['keyword', 'alt_keyword', 'number',
'string', 'comment']:
ret.append(html.span(data, class_=t.type))
Modified: py/trunk/py/apigen/source/testing/test_color.py
==============================================================================
--- py/trunk/py/apigen/source/testing/test_color.py (original)
+++ py/trunk/py/apigen/source/testing/test_color.py Tue Jan 30 15:46:57 2007
@@ -45,8 +45,12 @@
assert self.tokens('foo # bar\n') == [Token('foo', type='word'),
Token(' ', type='whitespace'),
Token('# bar\n', type='comment')]
+ assert self.tokens("# foo 'bar\n") == [Token("# foo 'bar\n",
+ type='comment')]
+ assert self.tokens('# foo') == [Token('# foo', type='comment')]
def test_string_simple(self):
+ assert self.tokens('""') == [Token('""', type='string')]
assert self.tokens('"foo"') == [Token('"foo"', type='string')]
assert self.tokens('"foo"\'bar\'') == [Token('"foo"', type='string'),
Token("'bar'", type='string')]
More information about the pytest-commit
mailing list