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

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-…:

#annotate

Allows tag to be decorated with additional information.

#apply_regexp_handling

Applies regexp handling to text and returns an array of [text, converted?] pairs.

#convert

Marks up content

#convert_string

Converts a string to be fancier if desired.

#handle_BOLD

Called when processing bold nodes while traversing inline nodes from handle_inline.

#handle_BOLD_WORD

Called when processing bold word nodes while traversing inline nodes from handle_inline.

#handle_EM

Called when processing emphasis nodes while traversing inline nodes from handle_inline.

#handle_EM_WORD

Called when processing emphasis word nodes while traversing inline nodes from handle_inline.

#handle_HARD_BREAK

Called when processing a hard break while traversing inline nodes from handle_inline.

#handle_inline

Parses inline text, traverse the resulting nodes, and calls the appropriate handler methods.

#handle_PLAIN_TEXT

Called when processing plain text while traversing inline nodes from handle_inline.

#handle_REGEXP_HANDLING_TEXT

Called when processing regexp-handling-processed text while traversing inline nodes from handle_inline.

#handle_STRIKE

Called when processing strike nodes while traversing inline nodes from handle_inline.

#handle_TEXT

Called when processing text node while traversing inline nodes from handle_inline.

#handle_TIDYLINK

Called when processing tidylink nodes while traversing inline nodes from handle_inline.

#handle_TT

Called when processing tt nodes while traversing inline nodes from handle_inline.

#ignore

Use ignore in your subclass to ignore the content of a node.

#parse_url

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

#traverse_inline_nodes

Traverses nodes and calls the appropriate handler methods Nodes formats are described in InlineParser#parse

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

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 28

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 73

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 35

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 74

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

#accept_list_start(list)

Pushes the list type for list onto #list_type

[ GitHub ]

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

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 61

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 75

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 76

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 77

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 69

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 101

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 108

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