* lib/rdoc*: Updated to RDoc 4.0 (pre-release)

* bin/rdoc:  ditto
* test/rdoc:  ditto
* NEWS:  Updated with RDoc 4.0 information


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37889 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
drbrain 2012-11-27 04:28:14 +00:00
parent c72f0daa87
commit 1c279a7d27
233 changed files with 45019 additions and 5100 deletions

View file

@ -1,8 +1,3 @@
require 'rubygems'
require 'minitest/autorun'
require 'rdoc/rdoc'
require 'rdoc/code_objects'
require 'rdoc/markup/to_html_crossref'
require File.expand_path '../xref_test_case', __FILE__
class TestRDocMarkupToHtmlCrossref < XrefTestCase
@ -10,25 +5,93 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
def setup
super
@to = RDoc::Markup::ToHtmlCrossref.new 'index.html', @c1, true
@options.hyperlink_all = true
@to = RDoc::Markup::ToHtmlCrossref.new @options, 'index.html', @c1
end
def test_convert_CROSSREF
result = @to.convert 'C1'
assert_equal "\n<p><a href=\"C1.html\">C1</a></p>\n", result
assert_equal para("<a href=\"C1.html\">C1</a>"), result
end
def test_convert_HYPERLINK_rdoc_ref
def test_convert_CROSSREF_label
result = @to.convert 'C1@foo'
assert_equal para("<a href=\"C1.html#label-foo\">foo at C1</a>"), result
result = @to.convert 'C1#m@foo'
assert_equal para("<a href=\"C1.html#method-i-m-label-foo\">foo at C1#m</a>"),
result
end
def test_convert_CROSSREF_label_period
result = @to.convert 'C1@foo.'
assert_equal para("<a href=\"C1.html#label-foo\">foo at C1</a>."), result
end
def test_convert_CROSSREF_label_space
result = @to.convert 'C1@foo+bar'
assert_equal para("<a href=\"C1.html#label-foo+bar\">foo bar at C1</a>"),
result
end
def test_convert_RDOCLINK_rdoc_ref
result = @to.convert 'rdoc-ref:C1'
assert_equal "\n<p><a href=\"C1.html\">C1</a></p>\n", result
assert_equal para("<a href=\"C1.html\">C1</a>"), result
end
def test_convert_TIDYLINK_rdoc_ref
result = @to.convert '{foo}[rdoc-ref:C1]'
def test_convert_RDOCLINK_rdoc_ref_method
result = @to.convert 'rdoc-ref:C1#m'
assert_equal "\n<p><a href=\"C1.html\">foo</a></p>\n", result
assert_equal para("<a href=\"C1.html#method-i-m\">#m</a>"), result
end
def test_convert_RDOCLINK_rdoc_ref_method_label
result = @to.convert 'rdoc-ref:C1#m@foo'
assert_equal para("<a href=\"C1.html#method-i-m-label-foo\">foo at C1#m</a>"),
result, 'rdoc-ref:C1#m@foo'
end
def test_convert_RDOCLINK_rdoc_ref_method_percent
m = @c1.add_method RDoc::AnyMethod.new nil, '%'
m.singleton = false
result = @to.convert 'rdoc-ref:C1#%'
assert_equal para("<a href=\"C1.html#method-i-25\">#%</a>"), result
m.singleton = true
result = @to.convert 'rdoc-ref:C1::%'
assert_equal para("<a href=\"C1.html#method-c-25\">::%</a>"), result
end
def test_convert_RDOCLINK_rdoc_ref_method_percent_label
m = @c1.add_method RDoc::AnyMethod.new nil, '%'
m.singleton = false
result = @to.convert 'rdoc-ref:C1#%@f'
assert_equal para("<a href=\"C1.html#method-i-25-label-f\">f at C1#%</a>"),
result
m.singleton = true
result = @to.convert 'rdoc-ref:C1::%@f'
assert_equal para("<a href=\"C1.html#method-c-25-label-f\">f at C1::%</a>"),
result
end
def test_convert_RDOCLINK_rdoc_ref_label
result = @to.convert 'rdoc-ref:C1@foo'
assert_equal para("<a href=\"C1.html#label-foo\">foo at C1</a>"), result,
'rdoc-ref:C1@foo'
end
def test_gen_url
@ -43,6 +106,11 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
assert_equal "<a href=\"C2/C3.html\">C2::C3</a>", SPECIAL('C2::C3')
end
def test_handle_special_CROSSREF_label
assert_equal "<a href=\"C1.html#method-i-m-label-foo\">foo at C1#m</a>",
SPECIAL('C1#m@foo')
end
def test_handle_special_CROSSREF_show_hash_false
@to.show_hash = false
@ -51,8 +119,10 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
end
def test_handle_special_HYPERLINK_rdoc
RDoc::TopLevel.new 'README.txt'
@to = RDoc::Markup::ToHtmlCrossref.new 'C2.html', @c2, true
readme = @store.add_file 'README.txt'
readme.parser = RDoc::Parser::Simple
@to = RDoc::Markup::ToHtmlCrossref.new @options, 'C2.html', @c2
link = @to.handle_special_HYPERLINK hyper 'C2::C3'
@ -68,8 +138,10 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
end
def test_handle_special_TIDYLINK_rdoc
RDoc::TopLevel.new 'README.txt'
@to = RDoc::Markup::ToHtmlCrossref.new 'C2.html', @c2, true
readme = @store.add_file 'README.txt'
readme.parser = RDoc::Parser::Simple
@to = RDoc::Markup::ToHtmlCrossref.new @options, 'C2.html', @c2
link = @to.handle_special_TIDYLINK tidy 'C2::C3'
@ -79,15 +151,51 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
assert_equal '<a href="C4.html">tidy</a>', link
link = @to.handle_special_TIDYLINK tidy 'C1#m'
assert_equal '<a href="C1.html#method-i-m">tidy</a>', link
link = @to.handle_special_TIDYLINK tidy 'README.txt'
assert_equal '<a href="README_txt.html">tidy</a>', link
end
def test_handle_special_TIDYLINK_label
link = @to.handle_special_TIDYLINK tidy 'C1#m@foo'
assert_equal "<a href=\"C1.html#method-i-m-label-foo\">tidy</a>",
link, 'C1#m@foo'
end
def test_to_html_CROSSREF_email
@options.hyperlink_all = false
@to = RDoc::Markup::ToHtmlCrossref.new @options, 'index.html', @c1
result = @to.to_html 'first.last@example.com'
assert_equal 'first.last@example.com', result
end
def test_to_html_CROSSREF_email_hyperlink_all
result = @to.to_html 'first.last@example.com'
assert_equal 'first.last@example.com', result
end
def test_link
assert_equal 'n', @to.link('n', 'n')
assert_equal '<a href="C1.html#method-c-m">m</a>', @to.link('m', 'm')
assert_equal '<a href="C1.html#method-c-m">::m</a>', @to.link('m', 'm')
end
def test_link_class_method_full
assert_equal '<a href="Parent.html#method-c-m">Parent.m</a>',
@to.link('Parent::m', 'Parent::m')
end
def para text
"\n<p>#{text}</p>\n"
end
def SPECIAL text