Class: RDoc::Markup::ToTtOnly
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_tt_only.rb |
Overview
Extracts sections of text enclosed in plus, tt or code. Used to discover undocumented parameters.
Class Method Summary
-
.new(markup = nil) ⇒ ToTtOnly
constructor
Creates a new tt-only formatter.
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
-
#list_type
readonly
Stack of list types.
-
#res
readonly
Output accumulator.
Formatter - Inherited
#in_tt? | Are we currently inside tt tags? |
Instance Method Summary
-
#accept_block_quote(block_quote)
Adds tts from
block_quote
to the output. -
#accept_list_end(list)
Pops the list type for
list
from #list_type -
#accept_list_item_start(list_item)
Prepares the visitor for consuming
list_item
-
#accept_list_start(list)
Pushes the list type for
list
onto #list_type -
#accept_paragraph(paragraph)
Adds
paragraph
to the output. -
#do_nothing(markup_item)
(also: #accept_blank_line, #accept_heading, #accept_list_item_end, #accept_raw, #accept_rule, #accept_verbatim)
Does nothing to
markup_item
because it doesn't have any user-built content. -
#end_accepting
Returns an Array of items that were wrapped in plus, tt or code.
-
#start_accepting
Prepares the visitor for gathering tt sections.
-
#tt_sections(text)
Extracts tt sections from
text
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
.new(markup = nil) ⇒ ToTtOnly
Creates a new tt-only formatter.
# File 'lib/rdoc/markup/to_tt_only.rb', line 21
def initialize markup = nil super nil, markup add_tag :TT, nil, nil end
Instance Attribute Details
#list_type (readonly)
Stack of list types
# File 'lib/rdoc/markup/to_tt_only.rb', line 11
attr_reader :list_type
#res (readonly)
Output accumulator
# File 'lib/rdoc/markup/to_tt_only.rb', line 16
attr_reader :res
Instance Method Details
#accept_block_quote(block_quote)
Adds tts from block_quote
to the output
# File 'lib/rdoc/markup/to_tt_only.rb', line 30
def accept_block_quote block_quote tt_sections block_quote.text end
#accept_list_end(list)
Pops the list type for list
from #list_type
# File 'lib/rdoc/markup/to_tt_only.rb', line 37
def accept_list_end list @list_type.pop end
#accept_list_item_start(list_item)
Prepares the visitor for consuming list_item
# File 'lib/rdoc/markup/to_tt_only.rb', line 51
def accept_list_item_start list_item case @list_type.last when :NOTE, :LABEL then Array(list_item.label).map do |label| tt_sections label end.flatten end end
#accept_list_start(list)
Pushes the list type for list
onto #list_type
# File 'lib/rdoc/markup/to_tt_only.rb', line 44
def accept_list_start list @list_type << list.type end
#accept_paragraph(paragraph)
Adds paragraph
to the output
# File 'lib/rdoc/markup/to_tt_only.rb', line 63
def accept_paragraph paragraph tt_sections(paragraph.text) end
#do_nothing(markup_item) Also known as: #accept_blank_line, #accept_heading, #accept_list_item_end, #accept_raw, #accept_rule, #accept_verbatim
Does nothing to markup_item
because it doesn't have any user-built content
# File 'lib/rdoc/markup/to_tt_only.rb', line 71
def do_nothing markup_item end
#end_accepting
Returns an Array of items that were wrapped in plus, tt or code.
# File 'lib/rdoc/markup/to_tt_only.rb', line 107
def end_accepting @res.compact end
#start_accepting
Prepares the visitor for gathering tt sections
# File 'lib/rdoc/markup/to_tt_only.rb', line 114
def start_accepting @res = [] @list_type = [] end
#tt_sections(text)
Extracts tt sections from text
# File 'lib/rdoc/markup/to_tt_only.rb', line 84
def tt_sections text flow = @am.flow text.dup flow.each do |item| case item when String then @res << item if in_tt? when RDoc::Markup::AttrChanger then res, item res, item when RDoc::Markup::Special then @res << convert_special(item) if in_tt? # TODO can this happen? else raise "Unknown flow element: #{item.inspect}" end end res end