diff options
author | aycabta <[email protected]> | 2019-01-20 13:18:22 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2019-07-26 17:20:27 +0800 |
commit | f7cbbc707413f7e1c71ac1839b0c8834550451e6 (patch) | |
tree | 65d32de07b000d57070fc717486c196c36c4367b | |
parent | 95aa60f6cde1ab7bc5cfe33c95c4fd2d2154cd52 (diff) |
[ruby/rdoc] ClassModule#add_comment should receive RDoc::Comment
https://github.com/ruby/rdoc/commit/3fb03bf399
-rw-r--r-- | lib/rdoc/class_module.rb | 2 | ||||
-rw-r--r-- | lib/rdoc/comment.rb | 5 | ||||
-rw-r--r-- | test/rdoc/test_rdoc_class_module.rb | 21 |
3 files changed, 18 insertions, 10 deletions
diff --git a/lib/rdoc/class_module.rb b/lib/rdoc/class_module.rb index fdd56e236b..7609080fbf 100644 --- a/lib/rdoc/class_module.rb +++ b/lib/rdoc/class_module.rb @@ -210,7 +210,7 @@ class RDoc::ClassModule < RDoc::Context normalize_comment comment end - comment = "#{@comment}\n---\n#{comment}" unless @comment.empty? + comment = "#{@comment.to_s}\n---\n#{comment.to_s}" unless @comment.empty? super comment end diff --git a/lib/rdoc/comment.rb b/lib/rdoc/comment.rb index 134f6440a0..0f643c45b9 100644 --- a/lib/rdoc/comment.rb +++ b/lib/rdoc/comment.rb @@ -34,6 +34,11 @@ class RDoc::Comment attr_reader :text ## + # Alias for text + + alias to_s text + + ## # Overrides the content returned by #parse. Use when there is no #text # source for this comment diff --git a/test/rdoc/test_rdoc_class_module.rb b/test/rdoc/test_rdoc_class_module.rb index cc53a13528..138ede58b6 100644 --- a/test/rdoc/test_rdoc_class_module.rb +++ b/test/rdoc/test_rdoc_class_module.rb @@ -9,21 +9,24 @@ class TestRDocClassModule < XrefTestCase tl3 = @store.add_file 'three.rb' cm = RDoc::ClassModule.new 'Klass' - cm.add_comment '# comment 1', tl1 + comment_tl1 = RDoc::Comment.new('# comment 1') + cm.add_comment comment_tl1, tl1 - assert_equal [['comment 1', tl1]], cm.comment_location - assert_equal 'comment 1', cm.comment + assert_equal [[comment_tl1, tl1]], cm.comment_location + assert_equal 'comment 1', cm.comment.text - cm.add_comment '# comment 2', tl2 + comment_tl2 = RDoc::Comment.new('# comment 2') + cm.add_comment comment_tl2, tl2 - assert_equal [['comment 1', tl1], ['comment 2', tl2]], cm.comment_location + assert_equal [[comment_tl1, tl1], [comment_tl2, tl2]], cm.comment_location assert_equal "comment 1\n---\ncomment 2", cm.comment - cm.add_comment "# * comment 3", tl3 + comment_tl3 = RDoc::Comment.new('# * comment 3') + cm.add_comment comment_tl3, tl3 - assert_equal [['comment 1', tl1], - ['comment 2', tl2], - ['* comment 3', tl3]], cm.comment_location + assert_equal [[comment_tl1, tl1], + [comment_tl2, tl2], + [comment_tl3, tl3]], cm.comment_location assert_equal "comment 1\n---\ncomment 2\n---\n* comment 3", cm.comment end |