Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/rdoc/code_object/class_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,12 @@ def merge(class_module)
document = document.merge other_document

@comment = RDoc::Comment.from_document(document)
@comment_location = document

@comment_location = if document.parts.first.is_a?(RDoc::Markup::Document)
document.parts.map { |doc| [doc, doc.file] }
else
[[document, document.file]]
end
end

cm = class_module
Expand Down
6 changes: 6 additions & 0 deletions test/rdoc/code_object/class_module_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -655,8 +655,10 @@ def test_merge
tl = @store.add_file 'one.rb'
p1 = tl.add_class RDoc::NormalClass, 'Parent'
c1 = p1.add_class RDoc::NormalClass, 'Klass'
c1.add_comment 'comment1', tl

c2 = RDoc::NormalClass.new 'Klass'
c2.add_comment 'comment2', tl

c2.merge c1

Expand All @@ -665,6 +667,10 @@ def test_merge

assert c1.current_section, 'original current_section'
assert c2.current_section, 'merged current_section'

comment, location = c2.comment_location.first
assert_kind_of RDoc::Markup::Document, comment
assert_equal tl.relative_name, location
end

def test_merge_attributes
Expand Down