diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-06-16 04:59:24 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-06-16 04:59:24 +0000 |
commit | b7528b5edb1f9148ea00ebb6151720e5943b3f0b (patch) | |
tree | 4caf55c53adb188170240f54b924892fbc5f9814 /lib/rdoc/markup/document.rb | |
parent | 97ac172d58d695305c39d555155318edb99f1ea7 (diff) | |
download | ruby-b7528b5edb1f9148ea00ebb6151720e5943b3f0b.tar.gz |
* lib/rdoc.rb: Import RDoc 3.7 release candidate
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32115 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/markup/document.rb')
-rw-r--r-- | lib/rdoc/markup/document.rb | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/lib/rdoc/markup/document.rb b/lib/rdoc/markup/document.rb index 688e8e822e..b4e070285e 100644 --- a/lib/rdoc/markup/document.rb +++ b/lib/rdoc/markup/document.rb @@ -4,6 +4,12 @@ class RDoc::Markup::Document ## + # The file this document was created from. See also + # RDoc::ClassModule#add_comment + + attr_accessor :file + + ## # The parts of the Document attr_reader :parts @@ -14,6 +20,8 @@ class RDoc::Markup::Document def initialize *parts @parts = [] @parts.push(*parts) + + @file = nil end ## @@ -36,7 +44,9 @@ class RDoc::Markup::Document end def == other # :nodoc: - self.class == other.class and @parts == other.parts + self.class == other.class and + @file == other.file and + @parts == other.parts end ## @@ -59,8 +69,30 @@ class RDoc::Markup::Document @parts.empty? end + ## + # When this is a collection of documents (#file is not set and this document + # contains only other documents as its direct children) #merge replaces + # documents in this class with documents from +other+ when the file matches + # and adds documents from +other+ when the files do not. + # + # The information in +other+ is preferred over the receiver + + def merge other + other.parts.each do |other_part| + self.parts.delete_if do |self_part| + self_part.file and self_part.file == other_part.file + end + + self.parts << other_part + end + + self + end + def pretty_print q # :nodoc: - q.group 2, '[doc: ', ']' do + start = @file ? "[doc (#{@file}): " : '[doc: ' + + q.group 2, start, ']' do q.seplist @parts do |part| q.pp part end |