class RDoc::Markup::ToTableOfContents
Extracts just the RDoc::Markup::Heading elements from a RDoc::Markup::Document
to help build a table of contents
Attributes
Omits headings with a level less than the given level.
Output accumulator
Public Class Methods
Source
# File lib/rdoc/markup/to_table_of_contents.rb, line 13 def self.to_toc @to_toc ||= new end
Singleton for table-of-contents generation
Public Instance Methods
Source
# File lib/rdoc/markup/to_table_of_contents.rb, line 36 def accept_document document @omit_headings_below = document.omit_headings_below super end
Adds document
to the output, using its heading cutoff if present
Calls superclass method
RDoc::Markup::Formatter#accept_document
Source
# File lib/rdoc/markup/to_table_of_contents.rb, line 45 def accept_heading heading @res << heading unless suppressed? heading end
Adds heading
to the table of contents
Source
# File lib/rdoc/markup/to_table_of_contents.rb, line 52 def end_accepting @res end
Returns the table of contents
Source
# File lib/rdoc/markup/to_table_of_contents.rb, line 59 def start_accepting @omit_headings_below = nil @res = [] end
Prepares the visitor for text generation
Source
# File lib/rdoc/markup/to_table_of_contents.rb, line 67 def suppressed? heading return false unless @omit_headings_below heading.level > @omit_headings_below end
Returns true if heading
is below the display threshold