Class: RDoc::Markup::ToTableOfContents (Ruby 2.7.3)
Description: Class : RDoc::Markup::ToTableOfContents - Ruby 2.7.3

### Home Classes Methods

### In Files

- rdoc/markup/to_table_of_contents.rb

### Parent

RDoc::Markup::Formatter

### Methods

- ::to_toc
- #accept_document
- #accept_heading
- #end_accepting
- #start_accepting
- #suppressed?

### Class/Module Index

Quicksearch

- RDoc
- RDoc::Alias
- RDoc::AnonClass
- RDoc::AnyMethod
- RDoc::Attr
- RDoc::ClassModule
- RDoc::CodeObject
- RDoc::Comment
- RDoc::Constant
- RDoc::Context
- RDoc::Context::Section
- RDoc::CrossReference
- RDoc::ERBIO
- RDoc::ERBPartial
- RDoc::Encoding
- RDoc::Error
- RDoc::Extend
- RDoc::Generator
- RDoc::Generator::Darkfish
- RDoc::Generator::JsonIndex
- RDoc::Generator::Markup
- RDoc::Generator::POT
- RDoc::Generator::POT::MessageExtractor
- RDoc::Generator::POT::PO
- RDoc::Generator::POT::POEntry
- RDoc::Generator::RI
- RDoc::GhostMethod
- RDoc::I18n
- RDoc::I18n::Locale
- RDoc::I18n::Text
- RDoc::Include
- RDoc::Markdown
- RDoc::Markdown::Literals
- RDoc::Markup
- RDoc::Markup::AttrChanger
- RDoc::Markup::AttrSpan
- RDoc::Markup::AttributeManager
- RDoc::Markup::Attributes
- RDoc::Markup::BlankLine
- RDoc::Markup::BlockQuote
- RDoc::Markup::Document
- RDoc::Markup::Formatter
- RDoc::Markup::HardBreak
- RDoc::Markup::Include
- RDoc::Markup::IndentedParagraph
- RDoc::Markup::List
- RDoc::Markup::ListItem
- RDoc::Markup::Paragraph
- RDoc::Markup::Parser
- RDoc::Markup::Parser::Error
- RDoc::Markup::Parser::MyStringScanner
- RDoc::Markup::Parser::ParseError
- RDoc::Markup::PreProcess
- RDoc::Markup::Raw
- RDoc::Markup::RegexpHandling
- RDoc::Markup::Rule
- RDoc::Markup::ToAnsi
- RDoc::Markup::ToBs
- RDoc::Markup::ToHtml
- RDoc::Markup::ToHtmlCrossref
- RDoc::Markup::ToHtmlSnippet
- RDoc::Markup::ToJoinedParagraph
- RDoc::Markup::ToLabel
- RDoc::Markup::ToMarkdown
- RDoc::Markup::ToRdoc
- RDoc::Markup::ToTableOfContents
- RDoc::Markup::ToTest
- RDoc::Markup::ToTtOnly
- RDoc::Markup::Verbatim
- RDoc::MetaMethod
- RDoc::MethodAttr
- RDoc::Mixin
- RDoc::NormalClass
- RDoc::NormalModule
- RDoc::Options
- RDoc::Parser
- RDoc::Parser::C
- RDoc::Parser::ChangeLog
- RDoc::Parser::Markdown
- RDoc::Parser::RD
- RDoc::Parser::RipperStateLex
- RDoc::Parser::RipperStateLex::InnerStateLex
- RDoc::Parser::Ruby
- RDoc::Parser::RubyTools
- RDoc::Parser::Simple
- RDoc::Parser::Text
- RDoc::RD
- RDoc::RD::BlockParser
- RDoc::RD::Inline
- RDoc::RD::InlineParser
- RDoc::RDoc
- RDoc::RI
- RDoc::RI::Driver
- RDoc::RI::Driver::Error
- RDoc::RI::Driver::NotFoundError
- RDoc::RI::Error
- RDoc::RI::Paths
- RDoc::RI::Task
- RDoc::Require
- RDoc::RubygemsHook
- RDoc::Servlet
- RDoc::SingleClass
- RDoc::Stats
- RDoc::Stats::Normal
- RDoc::Stats::Quiet
- RDoc::Stats::Verbose
- RDoc::Store
- RDoc::Store::Error
- RDoc::Store::MissingFileError
- RDoc::Task
- RDoc::Text
- RDoc::TokenStream
- RDoc::TomDoc
- RDoc::TopLevel
- RDocTask

No matching classes.

# 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

                   # File rdoc/markup/to_table_of_contents.rb, line 36
    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 rdoc/markup/to_table_of_contents.rb, line 45
    def accept_heading heading
      @res << heading unless suppressed? heading
    end

end_accepting() click to toggle source

Returns the table of contents

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

start_accepting() click to toggle source

Prepares the visitor for text generation

                   # File rdoc/markup/to_table_of_contents.rb, line 59
    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 rdoc/markup/to_table_of_contents.rb, line 67
    def suppressed? heading
      return false unless @omit_headings_below

      heading.level > @omit_headings_below
    end