Skip to content

Commit af7aa4c

Browse files
committed
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.
1 parent 9405d86 commit af7aa4c

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

lib/rdoc/text.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def strip_stars text
169169

170170
encoding = text.encoding
171171

172-
text = text.gsub %r%Document-method:\s+[\w:.#=!?]+%, ''
172+
text = text.gsub %r%Document-method:\s+[\w:.#=!?|^&<>~+-/*\%@`\[\]]+%, ''
173173

174174
space = ' '
175175
space = RDoc::Encoding.change_encoding space, encoding if encoding

test/test_rdoc_text.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,32 @@ def test_strip_stars_document_method
377377
assert_equal expected, strip_stars(text)
378378
end
379379

380+
def test_strip_stars_document_method_special
381+
text = <<-TEXT
382+
/*
383+
* Document-method: Zlib::GzipFile#mtime=
384+
* Document-method: []
385+
* Document-method: `
386+
* Document-method: |
387+
* Document-method: &
388+
* Document-method: <=>
389+
* Document-method: =~
390+
* Document-method: +
391+
* Document-method: -
392+
* Document-method: +@
393+
*
394+
* A comment
395+
*/
396+
TEXT
397+
398+
expected = <<-EXPECTED
399+
400+
A comment
401+
EXPECTED
402+
403+
assert_equal expected, strip_stars(text)
404+
end
405+
380406
def test_strip_stars_encoding
381407
text = <<-TEXT
382408
/*

0 commit comments

Comments
 (0)