In Files

  • rdoc/markup/to_table_of_contents.rb

Class/Module Index [+]



Extracts just the RDoc::Markup::Heading elements from a RDoc::Markup::Document to help build a table of contents



Omits headings with a level less than the given level.


Output accumulator

Public Class Methods

to_toc() click to toggle source

Singleton for table-of-contents generation

               # File rdoc/markup/to_table_of_contents.rb, line 12
def self.to_toc
  @to_toc ||= new

Public Instance Methods

accept_document(document) click to toggle source

Adds document to the output, using its heading cutoff if present

               # File rdoc/markup/to_table_of_contents.rb, line 35
def accept_document document
  @omit_headings_below = document.omit_headings_below

accept_heading(heading) click to toggle source

Adds heading to the table of contents

               # File rdoc/markup/to_table_of_contents.rb, line 44
def accept_heading heading
  @res << heading unless suppressed? heading
end_accepting() click to toggle source

Returns the table of contents

               # File rdoc/markup/to_table_of_contents.rb, line 51
def end_accepting
start_accepting() click to toggle source

Prepares the visitor for text generation

               # File rdoc/markup/to_table_of_contents.rb, line 58
def start_accepting
  @omit_headings_below = nil
  @res = []
suppressed?(heading) click to toggle source

Returns true if heading is below the display threshold

               # File rdoc/markup/to_table_of_contents.rb, line 66
def suppressed? heading
  return false unless @omit_headings_below

  heading.level > @omit_headings_below

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit