class RDoc::Markup::ToTtOnly
Extracts sections of text enclosed in plus, tt or code. Used to discover undocumented parameters.
Attributes
Stack of list types
Output accumulator
Public Class Methods
Source
# File lib/rdoc/markup/to_tt_only.rb, line 21 def initialize(markup = nil) super nil, markup end
Creates a new tt-only formatter.
Calls superclass method
RDoc::Markup::Formatter::new
Public Instance Methods
Source
# File lib/rdoc/markup/to_tt_only.rb, line 28 def accept_block_quote(block_quote) tt_sections block_quote.text end
Adds tts from block_quote to the output
Source
# File lib/rdoc/markup/to_tt_only.rb, line 35 def accept_list_end(list) @list_type.pop end
Pops the list type for list from list_type
Source
# File lib/rdoc/markup/to_tt_only.rb, line 49 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
Prepares the visitor for consuming list_item
Source
# File lib/rdoc/markup/to_tt_only.rb, line 42 def accept_list_start(list) @list_type << list.type end
Pushes the list type for list onto list_type
Source
# File lib/rdoc/markup/to_tt_only.rb, line 61 def accept_paragraph(paragraph) tt_sections(paragraph.text) end
Adds paragraph to the output
Source
# File lib/rdoc/markup/to_tt_only.rb, line 69 def do_nothing(markup_item) end
Does nothing to markup_item because it doesnβt have any user-built content
Source
# File lib/rdoc/markup/to_tt_only.rb, line 101 def end_accepting @res.compact end
Returns an Array of items that were wrapped in plus, tt or code.
Source
# File lib/rdoc/markup/to_tt_only.rb, line 108 def start_accepting @res = [] @list_type = [] end
Prepares the visitor for gathering tt sections
Source
# File lib/rdoc/markup/to_tt_only.rb, line 82 def tt_sections(text) parsed = RDoc::Markup::InlineParser.new(text).parse traverse = -> node { next if String === node if node[:type] == :TT res << nil res << node[:children][0] || '' res << nil else node[:children].each(&traverse) end } parsed.each(&traverse) res end
Extracts tt sections from text