1
require 'rdoc/markup/formatter'
2
require 'rdoc/markup/inline'
5
# Extracts sections of text enclosed in plus, tt or code. Used to discover
6
# undocumented parameters.
8
class RDoc::Markup::ToTtOnly < RDoc::Markup::Formatter
13
attr_reader :list_type
21
# Creates a new tt-only formatter.
23
def initialize markup = nil
30
# Pops the list type for +list+ from #list_type
32
def accept_list_end list
37
# Pushes the list type for +list+ onto #list_type
39
def accept_list_start list
40
@list_type << list.type
44
# Prepares the visitor for consuming +list_item+
46
def accept_list_item_start list_item
48
when :NOTE, :LABEL then
49
tt_sections(list_item.label)
54
# Adds +paragraph+ to the output
56
def accept_paragraph paragraph
57
tt_sections(paragraph.text)
61
# Does nothing to +markup_item+ because it doesn't have any user-built
64
def do_nothing markup_item
67
alias accept_blank_line do_nothing # :nodoc:
68
alias accept_heading do_nothing # :nodoc:
69
alias accept_list_item_end do_nothing # :nodoc:
70
alias accept_raw do_nothing # :nodoc:
71
alias accept_rule do_nothing # :nodoc:
72
alias accept_verbatim do_nothing # :nodoc:
75
# Extracts tt sections from +text+
78
flow = @am.flow text.dup
83
@res << item if in_tt?
84
when RDoc::Markup::AttrChanger then
87
when RDoc::Markup::Special then
88
@res << convert_special(item) if in_tt? # TODO can this happen?
90
raise "Unknown flow element: #{item.inspect}"
98
# Returns an Array of items that were wrapped in plus, tt or code.
105
# Prepares the visitor for gathering tt sections