mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
46580b5147
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
64 lines
1 KiB
Ruby
64 lines
1 KiB
Ruby
require 'rdoc/markup'
|
|
require 'rdoc/markup/formatter'
|
|
|
|
##
|
|
# This Markup outputter is used for testing purposes.
|
|
|
|
class RDoc::Markup::ToTest < RDoc::Markup::Formatter
|
|
|
|
##
|
|
# :section: Visitor
|
|
|
|
def start_accepting
|
|
@res = []
|
|
@list = []
|
|
end
|
|
|
|
def end_accepting
|
|
@res
|
|
end
|
|
|
|
def accept_paragraph(paragraph)
|
|
@res << paragraph.text
|
|
end
|
|
|
|
def accept_verbatim(verbatim)
|
|
@res << verbatim.text
|
|
end
|
|
|
|
def accept_list_start(list)
|
|
@list << case list.type
|
|
when :BULLET then
|
|
'*'
|
|
when :NUMBER then
|
|
'1'
|
|
else
|
|
list.type
|
|
end
|
|
end
|
|
|
|
def accept_list_end(list)
|
|
@list.pop
|
|
end
|
|
|
|
def accept_list_item_start(list_item)
|
|
@res << "#{' ' * (@list.size - 1)}#{@list.last}: "
|
|
end
|
|
|
|
def accept_list_item_end(list_item)
|
|
end
|
|
|
|
def accept_blank_line(blank_line)
|
|
@res << "\n"
|
|
end
|
|
|
|
def accept_heading(heading)
|
|
@res << "#{'=' * heading.level} #{heading.text}"
|
|
end
|
|
|
|
def accept_rule(rule)
|
|
@res << '-' * rule.weight
|
|
end
|
|
|
|
end
|
|
|