mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	Import RDoc 3
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30249 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									d7effd506f
								
							
						
					
					
						commit
						2ef9c50c6e
					
				
					 106 changed files with 8878 additions and 4179 deletions
				
			
		| 
						 | 
				
			
			@ -1,11 +1,12 @@
 | 
			
		|||
require 'rubygems'
 | 
			
		||||
require 'rdoc/markup/formatter_test_case'
 | 
			
		||||
require 'rdoc/markup/text_formatter_test_case'
 | 
			
		||||
require 'rdoc/markup/to_bs'
 | 
			
		||||
require 'minitest/autorun'
 | 
			
		||||
 | 
			
		||||
class TestRDocMarkupToBs < RDoc::Markup::FormatterTestCase
 | 
			
		||||
class TestRDocMarkupToBs < RDoc::Markup::TextFormatterTestCase
 | 
			
		||||
 | 
			
		||||
  add_visitor_tests
 | 
			
		||||
  add_text_tests
 | 
			
		||||
 | 
			
		||||
  def setup
 | 
			
		||||
    super
 | 
			
		||||
| 
						 | 
				
			
			@ -63,6 +64,7 @@ class TestRDocMarkupToBs < RDoc::Markup::FormatterTestCase
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  def accept_list_item_end_label
 | 
			
		||||
    assert_equal "\n", @to.res.join
 | 
			
		||||
    assert_equal 0, @to.indent, 'indent'
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -72,6 +74,7 @@ class TestRDocMarkupToBs < RDoc::Markup::FormatterTestCase
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  def accept_list_item_end_note
 | 
			
		||||
    assert_equal "\n", @to.res.join
 | 
			
		||||
    assert_equal 0, @to.indent, 'indent'
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -190,8 +193,8 @@ class TestRDocMarkupToBs < RDoc::Markup::FormatterTestCase
 | 
			
		|||
    assert_equal "#{'-' * 78}\n", @to.res.join
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def accept_verbatim # FormatterTestCase doesn't set indent for ToAnsi
 | 
			
		||||
    assert_equal "  hi\n  world\n\n", @to.res.join
 | 
			
		||||
  def accept_verbatim
 | 
			
		||||
    assert_equal "  hi\n    world\n\n", @to.res.join
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def end_accepting
 | 
			
		||||
| 
						 | 
				
			
			@ -206,232 +209,115 @@ class TestRDocMarkupToBs < RDoc::Markup::FormatterTestCase
 | 
			
		|||
    assert_empty @to.list_width
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_accept_heading_1
 | 
			
		||||
  def accept_heading_1
 | 
			
		||||
    skip "No String#chars, upgrade your ruby" unless ''.respond_to? :chars
 | 
			
		||||
    @to.start_accepting
 | 
			
		||||
    @to.accept_heading @RM::Heading.new(1, 'Hello')
 | 
			
		||||
 | 
			
		||||
    assert_equal "= H\bHe\bel\bll\blo\bo\n", @to.end_accepting
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_accept_heading_2
 | 
			
		||||
  def accept_heading_2
 | 
			
		||||
    skip "No String#chars, upgrade your ruby" unless ''.respond_to? :chars
 | 
			
		||||
    @to.start_accepting
 | 
			
		||||
    @to.accept_heading @RM::Heading.new(2, 'Hello')
 | 
			
		||||
 | 
			
		||||
    assert_equal "== H\bHe\bel\bll\blo\bo\n", @to.end_accepting
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_accept_heading_3
 | 
			
		||||
  def accept_heading_3
 | 
			
		||||
    skip "No String#chars, upgrade your ruby" unless ''.respond_to? :chars
 | 
			
		||||
    @to.start_accepting
 | 
			
		||||
    @to.accept_heading @RM::Heading.new(3, 'Hello')
 | 
			
		||||
 | 
			
		||||
    assert_equal "=== H\bHe\bel\bll\blo\bo\n", @to.end_accepting
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_accept_heading_4
 | 
			
		||||
  def accept_heading_4
 | 
			
		||||
    skip "No String#chars, upgrade your ruby" unless ''.respond_to? :chars
 | 
			
		||||
    @to.start_accepting
 | 
			
		||||
    @to.accept_heading @RM::Heading.new(4, 'Hello')
 | 
			
		||||
 | 
			
		||||
    assert_equal "==== H\bHe\bel\bll\blo\bo\n", @to.end_accepting
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_accept_heading_indent
 | 
			
		||||
  def accept_heading_indent
 | 
			
		||||
    skip "No String#chars, upgrade your ruby" unless ''.respond_to? :chars
 | 
			
		||||
    @to.start_accepting
 | 
			
		||||
    @to.indent = 3
 | 
			
		||||
    @to.accept_heading @RM::Heading.new(1, 'Hello')
 | 
			
		||||
 | 
			
		||||
    assert_equal "   = H\bHe\bel\bll\blo\bo\n", @to.end_accepting
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_accept_heading_b
 | 
			
		||||
  def accept_heading_b
 | 
			
		||||
    skip "No String#chars, upgrade your ruby" unless ''.respond_to? :chars
 | 
			
		||||
    @to.start_accepting
 | 
			
		||||
    @to.indent = 3
 | 
			
		||||
    @to.accept_heading @RM::Heading.new(1, '*Hello*')
 | 
			
		||||
 | 
			
		||||
    assert_equal "   = H\bHe\bel\bll\blo\bo\n", @to.end_accepting
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_accept_heading_suppressed_crossref
 | 
			
		||||
    skip "No String#chars, upgrade your ruby" unless ''.respond_to? :chars
 | 
			
		||||
    @to.start_accepting
 | 
			
		||||
    @to.accept_heading @RM::Heading.new(1, '\\Hello')
 | 
			
		||||
 | 
			
		||||
    assert_equal "= H\bHe\bel\bll\blo\bo\n", @to.end_accepting
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_accept_list_item_start_note_2
 | 
			
		||||
    list = @RM::List.new(:NOTE,
 | 
			
		||||
             @RM::ListItem.new('<tt>teletype</tt>',
 | 
			
		||||
                               @RM::Paragraph.new('teletype description')))
 | 
			
		||||
 | 
			
		||||
    @to.start_accepting
 | 
			
		||||
 | 
			
		||||
    list.accept @to
 | 
			
		||||
 | 
			
		||||
    expected = "teletype:\n  teletype description\n\n"
 | 
			
		||||
 | 
			
		||||
    assert_equal expected, @to.end_accepting
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_accept_paragraph_b
 | 
			
		||||
  def accept_heading_suppressed_crossref
 | 
			
		||||
    skip "No String#chars, upgrade your ruby" unless ''.respond_to? :chars
 | 
			
		||||
    @to.start_accepting
 | 
			
		||||
    @to.accept_paragraph @RM::Paragraph.new('reg <b>bold words</b> reg')
 | 
			
		||||
 | 
			
		||||
    expected = "reg b\bbo\bol\bld\bd \b w\bwo\bor\brd\bds\bs reg\n"
 | 
			
		||||
 | 
			
		||||
    assert_equal expected, @to.end_accepting
 | 
			
		||||
    assert_equal "= H\bHe\bel\bll\blo\bo\n", @to.end_accepting
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_accept_paragraph_i
 | 
			
		||||
  def accept_list_item_start_note_2
 | 
			
		||||
    assert_equal "teletype:\n  teletype description\n\n", @to.res.join
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def accept_paragraph_b
 | 
			
		||||
    skip "No String#chars, upgrade your ruby" unless ''.respond_to? :chars
 | 
			
		||||
    @to.start_accepting
 | 
			
		||||
    @to.accept_paragraph @RM::Paragraph.new('reg <em>italic words</em> reg')
 | 
			
		||||
 | 
			
		||||
    expected = "reg _\bi_\bt_\ba_\bl_\bi_\bc_\b _\bw_\bo_\br_\bd_\bs reg\n"
 | 
			
		||||
 | 
			
		||||
    assert_equal expected, @to.end_accepting
 | 
			
		||||
    assert_equal "reg b\bbo\bol\bld\bd \b w\bwo\bor\brd\bds\bs reg\n",
 | 
			
		||||
                 @to.end_accepting
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_accept_paragraph_indent
 | 
			
		||||
    @to.start_accepting
 | 
			
		||||
    @to.indent = 3
 | 
			
		||||
    @to.accept_paragraph @RM::Paragraph.new('words ' * 30)
 | 
			
		||||
  def accept_paragraph_i
 | 
			
		||||
    skip "No String#chars, upgrade your ruby" unless ''.respond_to? :chars
 | 
			
		||||
    assert_equal "reg _\bi_\bt_\ba_\bl_\bi_\bc_\b _\bw_\bo_\br_\bd_\bs reg\n",
 | 
			
		||||
                 @to.end_accepting
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def accept_paragraph_indent
 | 
			
		||||
    expected = <<-EXPECTED
 | 
			
		||||
   words words words words words words words words words words words words
 | 
			
		||||
   words words words words words words words words words words words words
 | 
			
		||||
   words words words words words words 
 | 
			
		||||
   words words words words words words
 | 
			
		||||
    EXPECTED
 | 
			
		||||
 | 
			
		||||
    assert_equal expected, @to.end_accepting
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_accept_paragraph_plus
 | 
			
		||||
    @to.start_accepting
 | 
			
		||||
    @to.accept_paragraph @RM::Paragraph.new('regular +teletype+ regular')
 | 
			
		||||
 | 
			
		||||
    expected = "regular teletype regular\n"
 | 
			
		||||
 | 
			
		||||
    assert_equal expected, @to.end_accepting
 | 
			
		||||
  def accept_paragraph_plus
 | 
			
		||||
    assert_equal "reg teletype reg\n", @to.end_accepting
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_accept_paragraph_star
 | 
			
		||||
  def accept_paragraph_star
 | 
			
		||||
    skip "No String#chars, upgrade your ruby" unless ''.respond_to? :chars
 | 
			
		||||
    @to.start_accepting
 | 
			
		||||
    @to.accept_paragraph @RM::Paragraph.new('regular *bold* regular')
 | 
			
		||||
 | 
			
		||||
    expected = "regular b\bbo\bol\bld\bd regular\n"
 | 
			
		||||
 | 
			
		||||
    assert_equal expected, @to.end_accepting
 | 
			
		||||
    assert_equal "reg b\bbo\bol\bld\bd reg\n", @to.end_accepting
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_accept_paragraph_underscore
 | 
			
		||||
  def accept_paragraph_underscore
 | 
			
		||||
    skip "No String#chars, upgrade your ruby" unless ''.respond_to? :chars
 | 
			
		||||
    @to.start_accepting
 | 
			
		||||
    @to.accept_paragraph @RM::Paragraph.new('regular _italic_ regular')
 | 
			
		||||
 | 
			
		||||
    expected = "regular _\bi_\bt_\ba_\bl_\bi_\bc regular\n"
 | 
			
		||||
 | 
			
		||||
    assert_equal expected, @to.end_accepting
 | 
			
		||||
    assert_equal "reg _\bi_\bt_\ba_\bl_\bi_\bc reg\n", @to.end_accepting
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_accept_paragraph_wrap
 | 
			
		||||
    @to.start_accepting
 | 
			
		||||
    @to.accept_paragraph @RM::Paragraph.new('words ' * 30)
 | 
			
		||||
 | 
			
		||||
  def accept_paragraph_wrap
 | 
			
		||||
    expected = <<-EXPECTED
 | 
			
		||||
words words words words words words words words words words words words words
 | 
			
		||||
words words words words words words words words words words words words words
 | 
			
		||||
words words words words 
 | 
			
		||||
words words words words
 | 
			
		||||
    EXPECTED
 | 
			
		||||
 | 
			
		||||
    assert_equal expected, @to.end_accepting
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_accept_rule_indent
 | 
			
		||||
    @to.start_accepting
 | 
			
		||||
    @to.indent = 3
 | 
			
		||||
 | 
			
		||||
    @to.accept_rule @RM::Rule.new(1)
 | 
			
		||||
 | 
			
		||||
  def accept_rule_indent
 | 
			
		||||
    assert_equal "   #{'-' * 75}\n", @to.end_accepting
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_accept_verbatim_indent
 | 
			
		||||
    @to.start_accepting
 | 
			
		||||
 | 
			
		||||
    @to.indent = 2
 | 
			
		||||
 | 
			
		||||
    @to.accept_verbatim @RM::Verbatim.new('    ', 'hi', "\n",
 | 
			
		||||
                                          '     ', 'world', "\n")
 | 
			
		||||
 | 
			
		||||
  def accept_verbatim_indent
 | 
			
		||||
    assert_equal "    hi\n     world\n\n", @to.end_accepting
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_accept_verbatim_big_indent
 | 
			
		||||
    @to.start_accepting
 | 
			
		||||
 | 
			
		||||
    @to.indent = 2
 | 
			
		||||
 | 
			
		||||
    @to.accept_verbatim @RM::Verbatim.new('    ', 'hi', "\n",
 | 
			
		||||
                                          '    ', 'world', "\n")
 | 
			
		||||
 | 
			
		||||
  def accept_verbatim_big_indent
 | 
			
		||||
    assert_equal "    hi\n    world\n\n", @to.end_accepting
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_attributes
 | 
			
		||||
    assert_equal 'Dog', @to.attributes("\\Dog")
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_list_nested
 | 
			
		||||
    doc = @RM::Document.new(
 | 
			
		||||
            @RM::List.new(:BULLET,
 | 
			
		||||
              @RM::ListItem.new(nil,
 | 
			
		||||
                @RM::Paragraph.new('l1'),
 | 
			
		||||
                @RM::List.new(:BULLET,
 | 
			
		||||
                  @RM::ListItem.new(nil,
 | 
			
		||||
                    @RM::Paragraph.new('l1.1')))),
 | 
			
		||||
              @RM::ListItem.new(nil,
 | 
			
		||||
                @RM::Paragraph.new('l2'))))
 | 
			
		||||
 | 
			
		||||
    output = doc.accept @to
 | 
			
		||||
 | 
			
		||||
  def list_nested
 | 
			
		||||
    expected = <<-EXPECTED
 | 
			
		||||
* l1
 | 
			
		||||
  * l1.1
 | 
			
		||||
* l2
 | 
			
		||||
    EXPECTED
 | 
			
		||||
 | 
			
		||||
    assert_equal expected, output
 | 
			
		||||
    assert_equal expected, @to.end_accepting
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_list_verbatim # HACK overblown
 | 
			
		||||
    doc = @RM::Document.new(
 | 
			
		||||
            @RM::List.new(:BULLET,
 | 
			
		||||
              @RM::ListItem.new(nil,
 | 
			
		||||
                @RM::Paragraph.new('list', 'stuff'),
 | 
			
		||||
                @RM::BlankLine.new(),
 | 
			
		||||
                @RM::Verbatim.new('   ', '*', ' ', 'list', "\n",
 | 
			
		||||
                                  '     ', 'with', "\n",
 | 
			
		||||
                                  "\n",
 | 
			
		||||
                                  '     ', 'second', "\n",
 | 
			
		||||
                                  "\n",
 | 
			
		||||
                                  '     ', '1.', ' ', 'indented', "\n",
 | 
			
		||||
                                  '     ', '2.', ' ', 'numbered', "\n",
 | 
			
		||||
                                  "\n",
 | 
			
		||||
                                  '     ', 'third', "\n",
 | 
			
		||||
                                  "\n",
 | 
			
		||||
                                  '   ', '*', ' ', 'second', "\n"))))
 | 
			
		||||
 | 
			
		||||
    output = doc.accept @to
 | 
			
		||||
 | 
			
		||||
    expected = <<-EXPECTED
 | 
			
		||||
  def list_verbatim
 | 
			
		||||
    expected = <<-EXPECTED # HACK overblown
 | 
			
		||||
* list stuff
 | 
			
		||||
 | 
			
		||||
    * list
 | 
			
		||||
| 
						 | 
				
			
			@ -448,7 +334,7 @@ words words words words
 | 
			
		|||
 | 
			
		||||
    EXPECTED
 | 
			
		||||
 | 
			
		||||
    assert_equal expected, output
 | 
			
		||||
    assert_equal expected, @to.end_accepting
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue