class RDoc::Markup::ToTableOfContents - rdoc-4.1.2 Documentation

# class RDoc::Markup::ToTableOfContents

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

### Attributes

omit_headings_below[RW]

Omits headings with a level less than the given level.

res[R]

Output accumulator

### Public Class Methods

### Public Instance Methods

accept_document(document) click to toggle source

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

Calls superclass method RDoc::Markup::Formatter#accept_document

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

      super
    end

accept_heading(heading) click to toggle source

Adds `heading` to the table of contents

    # File lib/rdoc/markup/to_table_of_contents.rb, line 44
    def accept_heading heading
      @res << heading unless suppressed? heading
    end

end_accepting() click to toggle source

Returns the table of contents

    # File lib/rdoc/markup/to_table_of_contents.rb, line 51
    def end_accepting
      @res
    end

start_accepting() click to toggle source

Prepares the visitor for text generation

    # File lib/rdoc/markup/to_table_of_contents.rb, line 58
    def start_accepting
      @omit_headings_below = nil
      @res = []
    end

suppressed?(heading) click to toggle source

Returns true if `heading` is below the display threshold

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

      heading.level > @omit_headings_below
    end