Skip to content

Commit

Permalink
Fix method name characters
Browse files Browse the repository at this point in the history
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 ruby#452.
  • Loading branch information
aycabta committed Jan 4, 2018
1 parent 9405d86 commit af7aa4c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rdoc/text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions test/test_rdoc_text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
/*
Expand Down

0 comments on commit af7aa4c

Please sign in to comment.