Maintenance of Ruby 2.0.0 ended on February 24, 2016. Read more

In Files

  • rdoc/markup/to_tt_only.rb

Class/Module Index [+]

Quicksearch

RDoc::Markup::ToTtOnly

Extracts sections of text enclosed in plus, tt or code. Used to discover undocumented parameters.

Attributes

list_type[R]

Stack of list types

res[R]

Output accumulator

Public Class Methods

new(markup = nil) click to toggle source

Creates a new tt-only formatter.

 
               # File rdoc/markup/to_tt_only.rb, line 20
def initialize markup = nil
  super nil, markup

  add_tag :TT, nil, nil
end
            

Public Instance Methods

accept_blank_line(markup_item) click to toggle source
Alias for: do_nothing
accept_block_quote(block_quote) click to toggle source

Adds tts from block_quote to the output

 
               # File rdoc/markup/to_tt_only.rb, line 29
def accept_block_quote block_quote
  tt_sections block_quote.text
end
            
accept_heading(markup_item) click to toggle source
Alias for: do_nothing
accept_list_end(list) click to toggle source

Pops the list type for list from list_type

 
               # File rdoc/markup/to_tt_only.rb, line 36
def accept_list_end list
  @list_type.pop
end
            
accept_list_item_end(markup_item) click to toggle source
Alias for: do_nothing
accept_list_item_start(list_item) click to toggle source

Prepares the visitor for consuming list_item

 
               # File rdoc/markup/to_tt_only.rb, line 50
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) click to toggle source

Pushes the list type for list onto list_type

 
               # File rdoc/markup/to_tt_only.rb, line 43
def accept_list_start list
  @list_type << list.type
end
            
accept_paragraph(paragraph) click to toggle source

Adds paragraph to the output

 
               # File rdoc/markup/to_tt_only.rb, line 62
def accept_paragraph paragraph
  tt_sections(paragraph.text)
end
            
accept_raw(markup_item) click to toggle source
Alias for: do_nothing
accept_rule(markup_item) click to toggle source
Alias for: do_nothing
accept_verbatim(markup_item) click to toggle source
Alias for: do_nothing
do_nothing(markup_item) click to toggle source

Does nothing to markup_item because it doesn't have any user-built content

 
               # File rdoc/markup/to_tt_only.rb, line 70
def do_nothing markup_item
end
            
end_accepting() click to toggle source

Returns an Array of items that were wrapped in plus, tt or code.

 
               # File rdoc/markup/to_tt_only.rb, line 106
def end_accepting
  @res.compact
end
            
start_accepting() click to toggle source

Prepares the visitor for gathering tt sections

 
               # File rdoc/markup/to_tt_only.rb, line 113
def start_accepting
  @res = []

  @list_type = []
end
            
tt_sections(text) click to toggle source

Extracts tt sections from text

 
               # File rdoc/markup/to_tt_only.rb, line 83
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
      off_tags res, item
      on_tags 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