123456789_123456789_123456789_123456789_123456789_

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

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

Formatter - Inherited

#in_tt?

Are we currently inside tt tags?

Instance Method Summary

Formatter - Inherited

#accept_document

Adds document to the output.

#add_regexp_handling_RDOCLINK

Adds a regexp handling for links of the form rdoc-…:

#add_regexp_handling_TIDYLINK

Adds a regexp handling for links of the form <text> and <word>.

#add_tag

Add a new set of tags for an attribute.

#annotate

Allows tag to be decorated with additional information.

#convert

Marks up content

#convert_flow

Converts flow items flow

#convert_regexp_handling

Converts added regexp handlings.

#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 item on #res

#on_tags

Turns on tags for item on #res

#parse_url

Extracts and a scheme, url and an anchor id from url and returns them.

#tt?

Is tag a tt tag?

Constructor Details

.new(markup = nil) ⇒ ToTtOnly

Creates a new tt-only formatter.

[ GitHub ]

  
# 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

[ GitHub ]

  
# File 'lib/rdoc/markup/to_tt_only.rb', line 11

attr_reader :list_type

#res (readonly)

Output accumulator

[ GitHub ]

  
# File 'lib/rdoc/markup/to_tt_only.rb', line 16

attr_reader :res

Instance Method Details

#accept_blank_line(markup_item)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rdoc/markup/to_tt_only.rb', line 74

alias accept_blank_line    do_nothing # :nodoc:

#accept_block_quote(block_quote)

Adds tts from block_quote to the output

[ GitHub ]

  
# File 'lib/rdoc/markup/to_tt_only.rb', line 30

def accept_block_quote block_quote
  tt_sections block_quote.text
end

#accept_heading(markup_item)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rdoc/markup/to_tt_only.rb', line 75

alias accept_heading       do_nothing # :nodoc:

#accept_list_end(list)

Pops the list type for list from #list_type

[ GitHub ]

  
# File 'lib/rdoc/markup/to_tt_only.rb', line 37

def accept_list_end list
  @list_type.pop
end

#accept_list_item_end(markup_item)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rdoc/markup/to_tt_only.rb', line 76

alias accept_list_item_end do_nothing # :nodoc:

#accept_list_item_start(list_item)

Prepares the visitor for consuming list_item

[ GitHub ]

  
# 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

[ GitHub ]

  
# 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

[ GitHub ]

  
# File 'lib/rdoc/markup/to_tt_only.rb', line 63

def accept_paragraph paragraph
  tt_sections(paragraph.text)
end

#accept_raw(markup_item)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rdoc/markup/to_tt_only.rb', line 77

alias accept_raw           do_nothing # :nodoc:

#accept_rule(markup_item)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rdoc/markup/to_tt_only.rb', line 78

alias accept_rule          do_nothing # :nodoc:

#accept_verbatim(markup_item)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rdoc/markup/to_tt_only.rb', line 79

alias accept_verbatim      do_nothing # :nodoc:

#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

[ GitHub ]

  
# 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.

[ GitHub ]

  
# 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

[ GitHub ]

  
# 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

[ GitHub ]

  
# 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
      off_tags res, item
      on_tags res, item
    when RDoc::Markup::RegexpHandling then
      @res << convert_regexp_handling(item) if in_tt? # TODO can this happen?
    else
      raise "Unknown flow element: #{item.inspect}"
    end
  end

  res
end