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.
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
-
#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.
Formatter - Inherited
#accept_document | Adds |
|
#add_special_RDOCLINK | Adds a special for links of the form rdoc-…: |
|
#add_special_TIDYLINK | Adds a special for links of the form |
Add a new set of tags for an attribute. |
#annotate | Allows |
|
#convert | Marks up |
|
#convert_flow | Converts flow items |
|
#convert_special | Converts added specials. |
|
#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
This class inherits a constructor from RDoc::Markup::Formatter
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_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
#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