mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/rdoc] Normalization of comment should check language
RDoc::Text#normalize_comment that is included RDoc::Comment always
remove Ruby style comment indicator "#" and C style comment indicator
"/**/", but should check language and remove only the language's comment
indicator.
ca68ba1e73
This commit is contained in:
parent
f7cbbc7074
commit
a86d4eef4b
11 changed files with 73 additions and 53 deletions
|
@ -9,19 +9,19 @@ class TestRDocClassModule < XrefTestCase
|
|||
tl3 = @store.add_file 'three.rb'
|
||||
|
||||
cm = RDoc::ClassModule.new 'Klass'
|
||||
comment_tl1 = RDoc::Comment.new('# comment 1')
|
||||
comment_tl1 = RDoc::Comment.new('# comment 1', @top_level, :ruby)
|
||||
cm.add_comment comment_tl1, tl1
|
||||
|
||||
assert_equal [[comment_tl1, tl1]], cm.comment_location
|
||||
assert_equal 'comment 1', cm.comment.text
|
||||
|
||||
comment_tl2 = RDoc::Comment.new('# comment 2')
|
||||
comment_tl2 = RDoc::Comment.new('# comment 2', @top_level, :ruby)
|
||||
cm.add_comment comment_tl2, tl2
|
||||
|
||||
assert_equal [[comment_tl1, tl1], [comment_tl2, tl2]], cm.comment_location
|
||||
assert_equal "comment 1\n---\ncomment 2", cm.comment
|
||||
|
||||
comment_tl3 = RDoc::Comment.new('# * comment 3')
|
||||
comment_tl3 = RDoc::Comment.new('# * comment 3', @top_level, :ruby)
|
||||
cm.add_comment comment_tl3, tl3
|
||||
|
||||
assert_equal [[comment_tl1, tl1],
|
||||
|
@ -42,11 +42,13 @@ class TestRDocClassModule < XrefTestCase
|
|||
tl1 = @store.add_file 'one.rb'
|
||||
|
||||
cm = RDoc::ClassModule.new 'Klass'
|
||||
cm.add_comment '# comment 1', tl1
|
||||
cm.add_comment '# comment 2', tl1
|
||||
comment1 = RDoc::Comment.new('# comment 1', @top_level, :ruby)
|
||||
comment2 = RDoc::Comment.new('# comment 2', @top_level, :ruby)
|
||||
cm.add_comment comment1, tl1
|
||||
cm.add_comment comment2, tl1
|
||||
|
||||
assert_equal [['comment 1', tl1],
|
||||
['comment 2', tl1]], cm.comment_location
|
||||
assert_equal [[comment1, tl1],
|
||||
[comment2, tl1]], cm.comment_location
|
||||
end
|
||||
|
||||
def test_add_comment_stopdoc
|
||||
|
@ -66,17 +68,17 @@ class TestRDocClassModule < XrefTestCase
|
|||
|
||||
def test_comment_equals
|
||||
cm = RDoc::ClassModule.new 'Klass'
|
||||
cm.comment = '# comment 1'
|
||||
cm.comment = RDoc::Comment.new('# comment 1', @top_level, :ruby)
|
||||
|
||||
assert_equal 'comment 1', cm.comment
|
||||
assert_equal 'comment 1', cm.comment.to_s
|
||||
|
||||
cm.comment = '# comment 2'
|
||||
cm.comment = RDoc::Comment.new('# comment 2', @top_level, :ruby)
|
||||
|
||||
assert_equal "comment 1\n---\ncomment 2", cm.comment
|
||||
assert_equal "comment 1\n---\ncomment 2", cm.comment.to_s
|
||||
|
||||
cm.comment = "# * comment 3"
|
||||
cm.comment = RDoc::Comment.new('# * comment 3', @top_level, :ruby)
|
||||
|
||||
assert_equal "comment 1\n---\ncomment 2\n---\n* comment 3", cm.comment
|
||||
assert_equal "comment 1\n---\ncomment 2\n---\n* comment 3", cm.comment.to_s
|
||||
end
|
||||
|
||||
def test_comment_equals_comment
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue