From af7aa4c1308a47580bb1faa0198fee9d7c731de9 Mon Sep 17 00:00:00 2001 From: aycabta Date: Mon, 1 Jan 2018 12:29:15 +0900 Subject: [PATCH] Fix method name characters RDoc::Text#strip_stars removes unnecessary Document-method directive. But the regexp uses only [\w:.#=!?], so it fails with some operator methods. This commit adds other operator characters to the regexp. This closes #452. --- lib/rdoc/text.rb | 2 +- test/test_rdoc_text.rb | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/rdoc/text.rb b/lib/rdoc/text.rb index 7e714be0ad..def80d98a3 100644 --- a/lib/rdoc/text.rb +++ b/lib/rdoc/text.rb @@ -169,7 +169,7 @@ def strip_stars text encoding = text.encoding - text = text.gsub %r%Document-method:\s+[\w:.#=!?]+%, '' + text = text.gsub %r%Document-method:\s+[\w:.#=!?|^&<>~+-/*\%@`\[\]]+%, '' space = ' ' space = RDoc::Encoding.change_encoding space, encoding if encoding diff --git a/test/test_rdoc_text.rb b/test/test_rdoc_text.rb index 9f0e9480d3..8b137c701f 100644 --- a/test/test_rdoc_text.rb +++ b/test/test_rdoc_text.rb @@ -377,6 +377,32 @@ def test_strip_stars_document_method assert_equal expected, strip_stars(text) end + def test_strip_stars_document_method_special + text = <<-TEXT +/* + * Document-method: Zlib::GzipFile#mtime= + * Document-method: [] + * Document-method: ` + * Document-method: | + * Document-method: & + * Document-method: <=> + * Document-method: =~ + * Document-method: + + * Document-method: - + * Document-method: +@ + * + * A comment + */ + TEXT + + expected = <<-EXPECTED + + A comment + EXPECTED + + assert_equal expected, strip_stars(text) + end + def test_strip_stars_encoding text = <<-TEXT /*