Sha256: d05a57404599494d2ca1117f1aeb73a9856b7f436305307c2ce689e2ce074e4e

Contents?: true

Size: 1.14 KB

Versions: 12

Compression:

Stored size: 1.14 KB

Contents

require 'rdoc/markup'
require 'rdoc/markup/formatter'

##
# This Markup outputter is used for testing purposes.

class RDoc::Markup::ToTest < RDoc::Markup::Formatter

  # :stopdoc:

  ##
  # :section: Visitor

  def start_accepting
    @res = []
    @list = []
  end

  def end_accepting
    @res
  end

  def accept_paragraph(paragraph)
    @res << paragraph.text
  end

  def accept_raw raw
    @res << raw.parts.join
  end

  def accept_verbatim(verbatim)
    @res << verbatim.text.gsub(/^(\S)/, '  \1')
  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

  # :startdoc:

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rdoc-3.6.1 lib/rdoc/markup/to_test.rb
rdoc-3.6 lib/rdoc/markup/to_test.rb
rdoc-3.5.3 lib/rdoc/markup/to_test.rb
rdoc-3.5.2 lib/rdoc/markup/to_test.rb
rdoc-3.5.1 lib/rdoc/markup/to_test.rb
rdoc-3.5 lib/rdoc/markup/to_test.rb
rdoc-3.4 lib/rdoc/markup/to_test.rb
rdoc-3.3 lib/rdoc/markup/to_test.rb
rdoc-3.2 lib/rdoc/markup/to_test.rb
rdoc-3.1 lib/rdoc/markup/to_test.rb
rdoc-3.0.1 lib/rdoc/markup/to_test.rb
rdoc-3.0 lib/rdoc/markup/to_test.rb