From 937daf4160cdd8cadf936f7ecb5f575c522e276a Mon Sep 17 00:00:00 2001 From: murphy Date: Fri, 2 Apr 2010 03:42:12 +0000 Subject: Python scanner highlights docstrings as comments (see #190). --- lib/coderay/encoders/comment_filter.rb | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'lib/coderay/encoders') 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 -- cgit v1.2.1