diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-27 04:28:14 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-27 04:28:14 +0000 |
commit | 1c279a7d2753949c725754e1302f791b76358114 (patch) | |
tree | 36aa3bdde250e564445eba5f2e25fcb96bcb6cef /lib/rdoc/markup/document.rb | |
parent | c72f0daa877808e4fa5018b3191ca09d4b97c03d (diff) | |
download | ruby-1c279a7d2753949c725754e1302f791b76358114.tar.gz |
* lib/rdoc*: Updated to RDoc 4.0 (pre-release)
* bin/rdoc: ditto
* test/rdoc: ditto
* NEWS: Updated with RDoc 4.0 information
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37889 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/markup/document.rb')
-rw-r--r-- | lib/rdoc/markup/document.rb | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/lib/rdoc/markup/document.rb b/lib/rdoc/markup/document.rb index 7077f357d3..198cef9ed9 100644 --- a/lib/rdoc/markup/document.rb +++ b/lib/rdoc/markup/document.rb @@ -3,11 +3,13 @@ class RDoc::Markup::Document + include Enumerable + ## # The file this document was created from. See also # RDoc::ClassModule#add_comment - attr_accessor :file + attr_reader :file ## # The parts of the Document @@ -19,7 +21,7 @@ class RDoc::Markup::Document def initialize *parts @parts = [] - @parts.push(*parts) + @parts.concat parts @file = nil end @@ -31,7 +33,7 @@ class RDoc::Markup::Document case part when RDoc::Markup::Document then unless part.empty? then - parts.push(*part.parts) + parts.concat part.parts parts << RDoc::Markup::BlankLine.new end when String then @@ -68,6 +70,20 @@ class RDoc::Markup::Document end ## + # Concatenates the given +parts+ onto the document + + def concat parts + self.parts.concat parts + end + + ## + # Enumerator for the parts of this document + + def each &block + @parts.each(&block) + end + + ## # Does this document have no parts? def empty? @@ -75,6 +91,18 @@ class RDoc::Markup::Document end ## + # The file this Document was created from. + + def file= location + @file = case location + when RDoc::TopLevel then + location.absolute_name + else + location + end + 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 @@ -120,7 +148,16 @@ class RDoc::Markup::Document # Appends +parts+ to the document def push *parts - self.parts.push(*parts) + self.parts.concat parts + end + + ## + # Returns an Array of headings in the document. + # + # Require 'rdoc/markup/formatter' before calling this method. + + def table_of_contents + accept RDoc::Markup::ToTableOfContents.to_toc end end |