Class: RDoc::Markup::ToTtOnly
Overview
Extracts sections of text enclosed in plus, tt or code. Used to discover undocumented parameters.
Instance Attribute Summary (collapse)
-
- (Object) list_type
readonly
Stack of list types.
-
- (Object) res
readonly
Output accumulator.
Instance Method Summary (collapse)
-
- (Object) accept_list_end(list)
Pops the list type for list from #list_type.
-
- (Object) accept_list_item_start(list_item)
Prepares the visitor for consuming list_item.
-
- (Object) accept_list_start(list)
Pushes the list type for list onto #list_type.
-
- (Object) accept_paragraph(paragraph)
Adds paragraph to the output.
-
- (Object) 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.
-
- (Object) end_accepting
Returns an Array of items that were wrapped in plus, tt or code.
-
- (ToTtOnly) initialize
constructor
Creates a new tt-only formatter.
-
- (Object) start_accepting
Prepares the visitor for gathering tt sections.
-
- (Object) tt_sections(text)
Extracts tt sections from text.
Methods inherited from Formatter
#add_tag, #annotate, #convert, #convert_flow, #convert_special, #convert_string, #in_tt?, #off_tags, #on_tags, #tt?
Constructor Details
- (ToTtOnly) initialize
Creates a new tt-only formatter.
23 24 25 26 27 |
# File 'lib/rdoc/markup/to_tt_only.rb', line 23 def initialize super add_tag :TT, nil, nil end |
Instance Attribute Details
- (Object) list_type (readonly)
Stack of list types
13 14 15 |
# File 'lib/rdoc/markup/to_tt_only.rb', line 13 def list_type @list_type end |
- (Object) res (readonly)
Output accumulator
18 19 20 |
# File 'lib/rdoc/markup/to_tt_only.rb', line 18 def res @res end |
Instance Method Details
- (Object) accept_list_end(list)
Pops the list type for list from #list_type
32 33 34 |
# File 'lib/rdoc/markup/to_tt_only.rb', line 32 def accept_list_end list @list_type.pop end |
- (Object) accept_list_item_start(list_item)
Prepares the visitor for consuming list_item
46 47 48 49 50 51 |
# File 'lib/rdoc/markup/to_tt_only.rb', line 46 def accept_list_item_start list_item case @list_type.last when :NOTE, :LABEL then tt_sections(list_item.label) end end |
- (Object) accept_list_start(list)
Pushes the list type for list onto #list_type
39 40 41 |
# File 'lib/rdoc/markup/to_tt_only.rb', line 39 def accept_list_start list @list_type << list.type end |
- (Object) accept_paragraph(paragraph)
Adds paragraph to the output
56 57 58 |
# File 'lib/rdoc/markup/to_tt_only.rb', line 56 def accept_paragraph paragraph tt_sections(paragraph.text) end |
- (Object) 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
64 65 |
# File 'lib/rdoc/markup/to_tt_only.rb', line 64 def do_nothing markup_item end |
- (Object) end_accepting
Returns an Array of items that were wrapped in plus, tt or code.
100 101 102 |
# File 'lib/rdoc/markup/to_tt_only.rb', line 100 def end_accepting @res.compact end |
- (Object) start_accepting
Prepares the visitor for gathering tt sections
107 108 109 110 111 |
# File 'lib/rdoc/markup/to_tt_only.rb', line 107 def start_accepting @res = [] @list_type = [] end |
- (Object) tt_sections(text)
Extracts tt sections from text
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/rdoc/markup/to_tt_only.rb', line 77 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 |