123456789_123456789_123456789_123456789_123456789_

Class: RDoc::Markup::ToTableOfContents

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Formatter
Instance Chain:
self, Formatter
Inherits: RDoc::Markup::Formatter
Defined in: lib/rdoc/markup/to_table_of_contents.rb

Overview

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

Class Method Summary

Formatter - Inherited

.gen_relative_url

Converts a target url to one that is relative to a given path.

.new

Creates a new Formatter.

Instance Attribute Summary

Formatter - Inherited

#in_tt?

Are we currently inside tt tags?

Instance Method Summary

Formatter - Inherited

#accept_document

Adds document to the output.

#add_regexp_handling_RDOCLINK

Adds a regexp handling for links of the form rdoc-…:

#add_regexp_handling_TIDYLINK

Adds a regexp handling for links of the form <text> and <word>.

#add_tag

Add a new set of tags for an attribute.

#annotate

Allows tag to be decorated with additional information.

#convert

Marks up content

#convert_flow

Converts flow items flow

#convert_regexp_handling

Converts added regexp handlings.

#convert_string

Converts a string to be fancier if desired.

#ignore

Use ignore in your subclass to ignore the content of a node.

#off_tags

Turns off tags for item on #res

#on_tags

Turns on tags for item on #res

#parse_url

Extracts and a scheme, url and an anchor id from url and returns them.

#tt?

Is tag a tt tag?

Constructor Details

.newToTableOfContents

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rdoc/markup/to_table_of_contents.rb', line 27

def initialize # :nodoc:
  super nil

  @omit_headings_below = nil
end

Class Method Details

.to_toc

Singleton for table-of-contents generation

[ GitHub ]

  
# File 'lib/rdoc/markup/to_table_of_contents.rb', line 13

def self.to_toc
  @to_toc ||= new
end

Instance Attribute Details

#omit_headings_below (rw)

Omits headings with a level less than the given level.

[ GitHub ]

  
# File 'lib/rdoc/markup/to_table_of_contents.rb', line 25

attr_accessor :omit_headings_below

#res (readonly)

Output accumulator

[ GitHub ]

  
# File 'lib/rdoc/markup/to_table_of_contents.rb', line 20

attr_reader :res

Instance Method Details

#accept_blank_line(*node)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rdoc/markup/to_table_of_contents.rb', line 77

alias accept_blank_line      ignore

#accept_block_quote(*node)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rdoc/markup/to_table_of_contents.rb', line 74

alias accept_block_quote     ignore

#accept_document(document)

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

[ GitHub ]

  
# File 'lib/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)

Adds heading to the table of contents

[ GitHub ]

  
# File 'lib/rdoc/markup/to_table_of_contents.rb', line 45

def accept_heading heading
  @res << heading unless suppressed? heading
end

#accept_list_end(*node)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rdoc/markup/to_table_of_contents.rb', line 80

alias accept_list_end        ignore

#accept_list_end_bullet(*node)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rdoc/markup/to_table_of_contents.rb', line 83

alias accept_list_end_bullet ignore

#accept_list_item_end(*node)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rdoc/markup/to_table_of_contents.rb', line 82

alias accept_list_item_end   ignore

#accept_list_item_start(*node)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rdoc/markup/to_table_of_contents.rb', line 81

alias accept_list_item_start ignore

#accept_list_start(*node)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rdoc/markup/to_table_of_contents.rb', line 84

alias accept_list_start      ignore

#accept_paragraph(*node)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rdoc/markup/to_table_of_contents.rb', line 78

alias accept_paragraph       ignore

#accept_raw(*node)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rdoc/markup/to_table_of_contents.rb', line 75

alias accept_raw             ignore

#accept_rule(*node)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rdoc/markup/to_table_of_contents.rb', line 76

alias accept_rule            ignore

#accept_table(*node)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rdoc/markup/to_table_of_contents.rb', line 85

alias accept_table           ignore

#accept_verbatim(*node)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rdoc/markup/to_table_of_contents.rb', line 79

alias accept_verbatim        ignore

#end_accepting

Returns the table of contents

[ GitHub ]

  
# File 'lib/rdoc/markup/to_table_of_contents.rb', line 52

def end_accepting
  @res
end

#start_accepting

Prepares the visitor for text generation

[ GitHub ]

  
# File 'lib/rdoc/markup/to_table_of_contents.rb', line 59

def start_accepting
  @omit_headings_below = nil
  @res = []
end

#suppressed?(heading) ⇒ Boolean

Returns true if heading is below the display threshold

[ GitHub ]

  
# 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