2008-10-24 19:05:28 -04:00
|
|
|
require 'rubygems'
|
2010-04-01 03:45:16 -04:00
|
|
|
require 'minitest/autorun'
|
|
|
|
require 'rdoc/rdoc'
|
2008-10-24 19:05:28 -04:00
|
|
|
require 'rdoc/code_objects'
|
2008-07-17 20:46:16 -04:00
|
|
|
require 'rdoc/markup/to_html_crossref'
|
2010-04-01 03:45:16 -04:00
|
|
|
require File.expand_path '../xref_test_case', __FILE__
|
|
|
|
|
|
|
|
class TestRDocMarkupToHtmlCrossref < XrefTestCase
|
|
|
|
|
|
|
|
def setup
|
|
|
|
super
|
|
|
|
|
2011-07-30 20:19:00 -04:00
|
|
|
@to = RDoc::Markup::ToHtmlCrossref.new 'index.html', @c1, true
|
2010-04-01 03:45:16 -04:00
|
|
|
end
|
|
|
|
|
2011-07-30 20:19:00 -04:00
|
|
|
def test_convert_CROSSREF
|
|
|
|
result = @to.convert 'C1'
|
2008-07-17 20:46:16 -04:00
|
|
|
|
2011-07-30 20:19:00 -04:00
|
|
|
assert_equal "\n<p><a href=\"C1.html\">C1</a></p>\n", result
|
2010-04-01 03:45:16 -04:00
|
|
|
end
|
|
|
|
|
2011-07-30 20:19:00 -04:00
|
|
|
def test_convert_HYPERLINK_rdoc_ref
|
|
|
|
result = @to.convert 'rdoc-ref:C1'
|
2010-04-01 03:45:16 -04:00
|
|
|
|
2011-07-30 20:19:00 -04:00
|
|
|
assert_equal "\n<p><a href=\"C1.html\">C1</a></p>\n", result
|
2008-07-17 20:46:16 -04:00
|
|
|
end
|
|
|
|
|
2011-08-11 14:31:49 -04:00
|
|
|
def test_convert_TIDYLINK_rdoc_ref
|
|
|
|
result = @to.convert '{foo}[rdoc-ref:C1]'
|
|
|
|
|
|
|
|
assert_equal "\n<p><a href=\"C1.html\">foo</a></p>\n", result
|
|
|
|
end
|
|
|
|
|
2011-08-01 01:25:13 -04:00
|
|
|
def test_gen_url
|
|
|
|
assert_equal '<a href="C1.html">Some class</a>',
|
|
|
|
@to.gen_url('rdoc-ref:C1', 'Some class')
|
|
|
|
|
|
|
|
assert_equal '<a href="http://example">HTTP example</a>',
|
|
|
|
@to.gen_url('http://example', 'HTTP example')
|
|
|
|
end
|
|
|
|
|
2011-07-30 20:19:00 -04:00
|
|
|
def test_handle_special_CROSSREF
|
|
|
|
assert_equal "<a href=\"C2/C3.html\">C2::C3</a>", SPECIAL('C2::C3')
|
2010-04-01 03:45:16 -04:00
|
|
|
end
|
|
|
|
|
2011-07-30 20:19:00 -04:00
|
|
|
def test_handle_special_CROSSREF_show_hash_false
|
|
|
|
@to.show_hash = false
|
2010-04-01 03:45:16 -04:00
|
|
|
|
2011-07-30 20:19:00 -04:00
|
|
|
assert_equal "<a href=\"C1.html#method-i-m\">m</a>",
|
|
|
|
SPECIAL('#m')
|
2010-04-01 03:45:16 -04:00
|
|
|
end
|
2009-03-05 22:56:38 -05:00
|
|
|
|
2011-07-30 20:19:00 -04:00
|
|
|
def test_handle_special_HYPERLINK_rdoc
|
|
|
|
RDoc::TopLevel.new 'README.txt'
|
|
|
|
@to = RDoc::Markup::ToHtmlCrossref.new 'C2.html', @c2, true
|
2008-09-24 22:43:03 -04:00
|
|
|
|
2011-07-30 20:19:00 -04:00
|
|
|
link = @to.handle_special_HYPERLINK hyper 'C2::C3'
|
2008-07-17 20:46:16 -04:00
|
|
|
|
2011-07-30 20:19:00 -04:00
|
|
|
assert_equal '<a href="C2/C3.html">C2::C3</a>', link
|
2009-03-05 22:56:38 -05:00
|
|
|
|
2011-07-30 20:19:00 -04:00
|
|
|
link = @to.handle_special_HYPERLINK hyper 'C4'
|
2008-09-24 22:43:03 -04:00
|
|
|
|
2011-07-30 20:19:00 -04:00
|
|
|
assert_equal '<a href="C4.html">C4</a>', link
|
2010-04-01 03:45:16 -04:00
|
|
|
|
2011-07-30 20:19:00 -04:00
|
|
|
link = @to.handle_special_HYPERLINK hyper 'README.txt'
|
2010-04-01 03:45:16 -04:00
|
|
|
|
2011-07-30 20:19:00 -04:00
|
|
|
assert_equal '<a href="README_txt.html">README.txt</a>', link
|
2008-09-24 22:43:03 -04:00
|
|
|
end
|
|
|
|
|
2011-07-30 20:19:00 -04:00
|
|
|
def test_handle_special_TIDYLINK_rdoc
|
|
|
|
RDoc::TopLevel.new 'README.txt'
|
|
|
|
@to = RDoc::Markup::ToHtmlCrossref.new 'C2.html', @c2, true
|
2010-04-01 03:45:16 -04:00
|
|
|
|
2011-07-30 20:19:00 -04:00
|
|
|
link = @to.handle_special_TIDYLINK tidy 'C2::C3'
|
2010-04-01 03:45:16 -04:00
|
|
|
|
2011-07-30 20:19:00 -04:00
|
|
|
assert_equal '<a href="C2/C3.html">tidy</a>', link
|
2008-09-24 22:43:03 -04:00
|
|
|
|
2011-07-30 20:19:00 -04:00
|
|
|
link = @to.handle_special_TIDYLINK tidy 'C4'
|
2010-04-01 03:45:16 -04:00
|
|
|
|
2011-07-30 20:19:00 -04:00
|
|
|
assert_equal '<a href="C4.html">tidy</a>', link
|
2010-04-01 03:45:16 -04:00
|
|
|
|
2011-07-30 20:19:00 -04:00
|
|
|
link = @to.handle_special_TIDYLINK tidy 'README.txt'
|
2010-04-01 03:45:16 -04:00
|
|
|
|
2011-07-30 20:19:00 -04:00
|
|
|
assert_equal '<a href="README_txt.html">tidy</a>', link
|
2008-09-24 22:43:03 -04:00
|
|
|
end
|
|
|
|
|
2011-07-30 20:19:00 -04:00
|
|
|
def test_link
|
|
|
|
assert_equal 'n', @to.link('n', 'n')
|
2010-04-01 03:45:16 -04:00
|
|
|
|
2011-07-30 20:19:00 -04:00
|
|
|
assert_equal '<a href="C1.html#method-c-m">m</a>', @to.link('m', 'm')
|
|
|
|
end
|
2010-04-01 03:45:16 -04:00
|
|
|
|
2011-07-30 20:19:00 -04:00
|
|
|
def SPECIAL text
|
|
|
|
@to.handle_special_CROSSREF special text
|
2008-09-24 22:43:03 -04:00
|
|
|
end
|
|
|
|
|
2011-07-30 20:19:00 -04:00
|
|
|
def hyper reference
|
|
|
|
RDoc::Markup::Special.new 0, "rdoc-ref:#{reference}"
|
|
|
|
end
|
2010-12-19 22:22:49 -05:00
|
|
|
|
2011-07-30 20:19:00 -04:00
|
|
|
def special text
|
|
|
|
RDoc::Markup::Special.new 0, text
|
2010-12-19 22:22:49 -05:00
|
|
|
end
|
|
|
|
|
2011-07-30 20:19:00 -04:00
|
|
|
def tidy reference
|
|
|
|
RDoc::Markup::Special.new 0, "{tidy}[rdoc-ref:#{reference}]"
|
2008-09-24 22:43:03 -04:00
|
|
|
end
|
2010-04-01 03:45:16 -04:00
|
|
|
|
2008-09-24 22:43:03 -04:00
|
|
|
end
|
2008-10-24 19:05:28 -04:00
|
|
|
|