diff options
author | murphy <murphy@rubychan.de> | 2010-04-02 03:42:12 +0000 |
---|---|---|
committer | murphy <murphy@rubychan.de> | 2010-04-02 03:42:12 +0000 |
commit | 937daf4160cdd8cadf936f7ecb5f575c522e276a (patch) | |
tree | da15f97e0564f6dc46b40821934e3be2bb68c5f8 /lib/coderay/encoders | |
parent | 6d82ed6176a8c3e6a80a6fead652ad659a8892db (diff) | |
download | coderay-937daf4160cdd8cadf936f7ecb5f575c522e276a.tar.gz |
Python scanner highlights docstrings as comments (see #190).
Diffstat (limited to 'lib/coderay/encoders')
-rw-r--r-- | lib/coderay/encoders/comment_filter.rb | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/lib/coderay/encoders/comment_filter.rb b/lib/coderay/encoders/comment_filter.rb index 819c619..0a6a2e8 100644 --- a/lib/coderay/encoders/comment_filter.rb +++ b/lib/coderay/encoders/comment_filter.rb @@ -18,7 +18,7 @@ module Encoders register_for :comment_filter DEFAULT_OPTIONS = superclass::DEFAULT_OPTIONS.merge \ - :exclude => [:comment] + :exclude => [:comment, :docstring] end @@ -49,4 +49,32 @@ puts "Hello world!" RUBY_FILTERED end + def test_filtering_docstrings + tokens = CodeRay.scan <<-PYTHON, :python +''' +Assuming this is file mymodule.py then this string, being the +first statement in the file will become the mymodule modules +docstring when the file is imported +''' + +class Myclass(): + """The class's docstring""" + + def mymethod(self): + "The method's docstring" + +def myfunction(): + "The function's docstring" + PYTHON + assert_equal <<-PYTHON_FILTERED.chomp, tokens.comment_filter.text + +class Myclass(): + + def mymethod(self): + +def myfunction(): + +PYTHON_FILTERED + end + end
\ No newline at end of file |