1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/rdoc: Update to RDoc 4.1.0.preview.1

RDoc 4.1.0 contains a number of enhancements including a new default
  style and accessibility support.  You can see the changelog here:

  https://github.com/rdoc/rdoc/blob/v4.1.0.preview.1/History.rdoc

* test/rdoc:  ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
drbrain 2013-09-18 23:33:36 +00:00
parent fed428007c
commit df7dac9174
118 changed files with 5394 additions and 3600 deletions

View file

@ -26,6 +26,12 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
@am.add_word_pair("{", "}", :WOMBAT)
@wombat_on = @am.changed_attribute_by_name([], [:WOMBAT])
@wombat_off = @am.changed_attribute_by_name([:WOMBAT], [])
@klass = RDoc::Markup::AttributeManager
@formatter = RDoc::Markup::Formatter.new @rdoc.options
@formatter.add_tag :BOLD, '<B>', '</B>'
@formatter.add_tag :EM, '<EM>', '</EM>'
@formatter.add_tag :TT, '<CODE>', '</CODE>'
end
def crossref(text)
@ -44,6 +50,21 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
#assert_equal(["cat {and} dog" ], @am.flow("cat \\{and} dog"))
end
def test_add_html_tag
@am.add_html("Test", :TEST)
tags = @am.html_tags
assert_equal(6, tags.size)
assert(tags.has_key?("test"))
end
def test_add_special
@am.add_special "WikiWord", :WIKIWORD
specials = @am.special
assert_equal 1, specials.size
assert specials.assoc "WikiWord"
end
def test_add_word_pair
@am.add_word_pair '%', '&', 'percent and'
@ -60,6 +81,20 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
assert_equal "Word flags may not start with '<'", e.message
end
def test_add_word_pair_invalid
assert_raises ArgumentError do
@am.add_word_pair("<", "<", :TEST)
end
end
def test_add_word_pair_map
@am.add_word_pair("x", "y", :TEST)
word_pair_map = @am.word_pair_map
assert_includes word_pair_map.keys.map { |r| r.source }, "(x)(\\S+)(y)"
end
def test_add_word_pair_matching
@am.add_word_pair '^', '^', 'caret'
@ -151,6 +186,56 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
assert_equal "\000x-y\000", str
end
def test_convert_attrs_ignores_code
assert_equal 'foo <CODE>__send__</CODE> bar', output('foo <code>__send__</code> bar')
end
def test_convert_attrs_ignores_tt
assert_equal 'foo <CODE>__send__</CODE> bar', output('foo <tt>__send__</tt> bar')
end
def test_convert_attrs_preserves_double
assert_equal 'foo.__send__ :bar', output('foo.__send__ :bar')
assert_equal 'use __FILE__ to', output('use __FILE__ to')
end
def test_convert_attrs_does_not_ignore_after_tt
assert_equal 'the <CODE>IF:</CODE><EM>key</EM> directive', output('the <tt>IF:</tt>_key_ directive')
end
def test_escapes
assert_equal '<CODE>text</CODE>', output('<tt>text</tt>')
assert_equal '<tt>text</tt>', output('\\<tt>text</tt>')
assert_equal '<tt>', output('\\<tt>')
assert_equal '<CODE><tt></CODE>', output('<tt>\\<tt></tt>')
assert_equal '<CODE>\\<tt></CODE>', output('<tt>\\\\<tt></tt>')
assert_equal '<B>text</B>', output('*text*')
assert_equal '*text*', output('\\*text*')
assert_equal '\\', output('\\')
assert_equal '\\text', output('\\text')
assert_equal '\\\\text', output('\\\\text')
assert_equal 'text \\ text', output('text \\ text')
assert_equal 'and <CODE>\\s</CODE> matches space',
output('and <tt>\\s</tt> matches space')
assert_equal 'use <CODE><tt>text</CODE></tt> for code',
output('use <tt>\\<tt>text</tt></tt> for code')
assert_equal 'use <CODE><tt>text</tt></CODE> for code',
output('use <tt>\\<tt>text\\</tt></tt> for code')
assert_equal 'use <tt><tt>text</tt></tt> for code',
output('use \\<tt>\\<tt>text</tt></tt> for code')
assert_equal 'use <tt><CODE>text</CODE></tt> for code',
output('use \\<tt><tt>text</tt></tt> for code')
assert_equal 'use <CODE>+text+</CODE> for code',
output('use <tt>\\+text+</tt> for code')
assert_equal 'use <tt><CODE>text</CODE></tt> for code',
output('use \\<tt>+text+</tt> for code')
assert_equal 'illegal <tag>not</tag> changed',
output('illegal <tag>not</tag> changed')
assert_equal 'unhandled <p>tag</p> unchanged',
output('unhandled <p>tag</p> unchanged')
end
def test_html_like_em_bold
assert_equal ["cat ", @em_on, "and ", @em_to_bold, "dog", @bold_off],
@am.flow("cat <i>and </i><b>dog</b>")
@ -191,6 +276,38 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
@am.flow("<tt>cat</tt> <i>and <b></i>dog</b>")
end
def test_initial_html
html_tags = @am.html_tags
assert html_tags.is_a?(Hash)
assert_equal(5, html_tags.size)
end
def test_initial_word_pairs
word_pairs = @am.matching_word_pairs
assert word_pairs.is_a?(Hash)
assert_equal(3, word_pairs.size)
end
def test_mask_protected_sequence
def @am.str() @str end
def @am.str=(str) @str = str end
@am.str = '<code>foo</code>'
@am.mask_protected_sequences
assert_equal "<code>foo</code>", @am.str
@am.str = '<code>foo\\</code>'
@am.mask_protected_sequences
assert_equal "<code>foo<\x04/code>", @am.str, 'escaped close'
@am.str = '<code>foo\\\\</code>'
@am.mask_protected_sequences
assert_equal "<code>foo\\</code>", @am.str, 'escaped backslash'
end
def test_protect
assert_equal(['cat \\ dog'],
@am.flow('cat \\ dog'))
@ -233,5 +350,9 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
@am.flow('<tt>"\n"</tt>')
end
def output str
@formatter.convert_flow @am.flow str
end
end