2008-01-18 19:06:19 -05:00
|
|
|
require 'rdoc/markup'
|
2008-02-09 22:59:08 -05:00
|
|
|
require 'rdoc/markup/formatter'
|
2008-01-18 19:06:19 -05:00
|
|
|
|
|
|
|
##
|
|
|
|
# This Markup outputter is used for testing purposes.
|
|
|
|
|
2008-02-09 22:59:08 -05:00
|
|
|
class RDoc::Markup::ToTest < RDoc::Markup::Formatter
|
2008-01-18 19:06:19 -05:00
|
|
|
|
2010-12-19 22:22:49 -05:00
|
|
|
# :stopdoc:
|
|
|
|
|
2010-04-01 03:45:16 -04:00
|
|
|
##
|
|
|
|
# :section: Visitor
|
|
|
|
|
2008-01-18 19:06:19 -05:00
|
|
|
def start_accepting
|
|
|
|
@res = []
|
2010-04-01 03:45:16 -04:00
|
|
|
@list = []
|
2008-01-18 19:06:19 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def end_accepting
|
|
|
|
@res
|
|
|
|
end
|
|
|
|
|
2010-04-01 03:45:16 -04:00
|
|
|
def accept_paragraph(paragraph)
|
|
|
|
@res << paragraph.text
|
|
|
|
end
|
|
|
|
|
2010-12-19 22:22:49 -05:00
|
|
|
def accept_raw raw
|
|
|
|
@res << raw.parts.join
|
|
|
|
end
|
|
|
|
|
2010-04-01 03:45:16 -04:00
|
|
|
def accept_verbatim(verbatim)
|
2010-12-19 22:22:49 -05:00
|
|
|
@res << verbatim.text.gsub(/^(\S)/, ' \1')
|
2008-01-18 19:06:19 -05:00
|
|
|
end
|
|
|
|
|
2010-04-01 03:45:16 -04:00
|
|
|
def accept_list_start(list)
|
|
|
|
@list << case list.type
|
|
|
|
when :BULLET then
|
|
|
|
'*'
|
|
|
|
when :NUMBER then
|
|
|
|
'1'
|
|
|
|
else
|
|
|
|
list.type
|
|
|
|
end
|
2008-01-18 19:06:19 -05:00
|
|
|
end
|
|
|
|
|
2010-04-01 03:45:16 -04:00
|
|
|
def accept_list_end(list)
|
|
|
|
@list.pop
|
2008-01-18 19:06:19 -05:00
|
|
|
end
|
|
|
|
|
2010-04-01 03:45:16 -04:00
|
|
|
def accept_list_item_start(list_item)
|
|
|
|
@res << "#{' ' * (@list.size - 1)}#{@list.last}: "
|
2008-01-18 19:06:19 -05:00
|
|
|
end
|
|
|
|
|
2010-04-01 03:45:16 -04:00
|
|
|
def accept_list_item_end(list_item)
|
2008-01-18 19:06:19 -05:00
|
|
|
end
|
|
|
|
|
2010-04-01 03:45:16 -04:00
|
|
|
def accept_blank_line(blank_line)
|
|
|
|
@res << "\n"
|
2008-01-18 19:06:19 -05:00
|
|
|
end
|
|
|
|
|
2010-04-01 03:45:16 -04:00
|
|
|
def accept_heading(heading)
|
|
|
|
@res << "#{'=' * heading.level} #{heading.text}"
|
2008-01-18 19:06:19 -05:00
|
|
|
end
|
|
|
|
|
2010-04-01 03:45:16 -04:00
|
|
|
def accept_rule(rule)
|
|
|
|
@res << '-' * rule.weight
|
2008-01-18 19:06:19 -05:00
|
|
|
end
|
|
|
|
|
2010-12-19 22:22:49 -05:00
|
|
|
# :startdoc:
|
|
|
|
|
2008-01-18 19:06:19 -05:00
|
|
|
end
|
|
|
|
|