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
-
.to_toc
Singleton for table-of-contents generation.
- .new ⇒ ToTableOfContents constructor Internal use only
Formatter
- Inherited
.gen_relative_url | Converts a target url to one that is relative to a given path. |
.new | Creates a new |
Instance Attribute Summary
-
#omit_headings_below
rw
Omits headings with a level less than the given level.
-
#res
readonly
Output accumulator.
Formatter
- Inherited
#in_tt? | Are we currently inside tt tags? |
Instance Method Summary
-
#accept_document(document)
Adds
document
to the output, using its heading cutoff if present. -
#accept_heading(heading)
Adds
heading
to the table of contents. -
#end_accepting
Returns the table of contents.
-
#start_accepting
Prepares the visitor for text generation.
-
#suppressed?(heading) ⇒ Boolean
Returns true if
heading
is below the display threshold. - #accept_blank_line(*node) Internal use only
- #accept_block_quote(*node) Internal use only
- #accept_list_end(*node) Internal use only
- #accept_list_end_bullet(*node) Internal use only
- #accept_list_item_end(*node) Internal use only
- #accept_list_item_start(*node) Internal use only
- #accept_list_start(*node) Internal use only
- #accept_paragraph(*node) Internal use only
- #accept_raw(*node) Internal use only
- #accept_rule(*node) Internal use only
- #accept_verbatim(*node) Internal use only
Formatter
- Inherited
#accept_document | Adds |
#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 |
#add_tag | Add a new set of tags for an attribute. |
#annotate | Allows |
#convert | Marks up |
#convert_flow | Converts flow items |
#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 |
#on_tags | Turns on tags for |
#parse_url | Extracts and a scheme, url and an anchor id from |
#tt? | Is |
Constructor Details
.new ⇒ ToTableOfContents
# 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
# 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.
# File 'lib/rdoc/markup/to_table_of_contents.rb', line 25
attr_accessor :omit_headings_below
#res (readonly)
Output accumulator
# File 'lib/rdoc/markup/to_table_of_contents.rb', line 20
attr_reader :res
Instance Method Details
#accept_blank_line(*node)
# File 'lib/rdoc/markup/to_table_of_contents.rb', line 77
alias accept_blank_line ignore
#accept_block_quote(*node)
# 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
# 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
# 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)
# File 'lib/rdoc/markup/to_table_of_contents.rb', line 80
alias accept_list_end ignore
#accept_list_end_bullet(*node)
# File 'lib/rdoc/markup/to_table_of_contents.rb', line 83
alias accept_list_end_bullet ignore
#accept_list_item_end(*node)
# File 'lib/rdoc/markup/to_table_of_contents.rb', line 82
alias accept_list_item_end ignore
#accept_list_item_start(*node)
# File 'lib/rdoc/markup/to_table_of_contents.rb', line 81
alias accept_list_item_start ignore
#accept_list_start(*node)
# File 'lib/rdoc/markup/to_table_of_contents.rb', line 84
alias accept_list_start ignore
#accept_paragraph(*node)
# File 'lib/rdoc/markup/to_table_of_contents.rb', line 78
alias accept_paragraph ignore
#accept_raw(*node)
# File 'lib/rdoc/markup/to_table_of_contents.rb', line 75
alias accept_raw ignore
#accept_rule(*node)
# File 'lib/rdoc/markup/to_table_of_contents.rb', line 76
alias accept_rule ignore
#accept_verbatim(*node)
# File 'lib/rdoc/markup/to_table_of_contents.rb', line 79
alias accept_verbatim ignore
#end_accepting
Returns the table of contents
# File 'lib/rdoc/markup/to_table_of_contents.rb', line 52
def end_accepting @res end
#start_accepting
Prepares the visitor for text generation
# 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
# 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