rdoc 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rdoc might be problematic. Click here for more details.
- data/History.txt +82 -1
- data/Manifest.txt +8 -0
- data/README.txt +33 -9
- data/RI.txt +58 -0
- data/Rakefile +2 -0
- data/bin/ri +1 -2
- data/lib/rdoc.rb +154 -36
- data/lib/rdoc/code_objects.rb +38 -2
- data/lib/rdoc/diagram.rb +17 -15
- data/lib/rdoc/generator.rb +21 -15
- data/lib/rdoc/generator/chm/chm.rb +2 -0
- data/lib/rdoc/generator/html.rb +137 -89
- data/lib/rdoc/generator/html/common.rb +24 -0
- data/lib/rdoc/generator/html/frameless.rb +28 -731
- data/lib/rdoc/generator/html/hefss.rb +47 -311
- data/lib/rdoc/generator/html/html.rb +226 -156
- data/lib/rdoc/generator/html/kilmer.rb +31 -298
- data/lib/rdoc/generator/html/kilmerfactory.rb +427 -0
- data/lib/rdoc/generator/html/one_page_html.rb +6 -5
- data/lib/rdoc/generator/texinfo.rb +3 -6
- data/lib/rdoc/generator/xml.rb +4 -7
- data/lib/rdoc/generator/xml/xml.rb +21 -9
- data/lib/rdoc/markup.rb +0 -95
- data/lib/rdoc/markup/inline.rb +1 -1
- data/lib/rdoc/markup/to_html.rb +9 -6
- data/lib/rdoc/markup/to_html_crossref.rb +67 -21
- data/lib/rdoc/markup/to_texinfo.rb +1 -1
- data/lib/rdoc/parser.rb +22 -1
- data/lib/rdoc/parser/c.rb +14 -16
- data/lib/rdoc/parser/ruby.rb +3 -3
- data/lib/rdoc/parser/simple.rb +1 -1
- data/lib/rdoc/rdoc.rb +0 -1
- data/lib/rdoc/ri/cache.rb +5 -6
- data/lib/rdoc/ri/descriptions.rb +3 -0
- data/lib/rdoc/ri/display.rb +157 -37
- data/lib/rdoc/ri/driver.rb +314 -198
- data/lib/rdoc/ri/formatter.rb +1 -1
- data/lib/rdoc/ri/paths.rb +2 -11
- data/lib/rdoc/ri/reader.rb +3 -3
- data/lib/rdoc/ri/util.rb +0 -2
- data/test/binary.dat +0 -0
- data/test/rdoc_markup_to_html_crossref_reference.rb +31 -0
- data/test/test_attribute_manager.rb +73 -0
- data/test/test_rdoc_info_formatting.rb +6 -6
- data/test/test_rdoc_info_sections.rb +2 -2
- data/test/test_rdoc_markup_attribute_manager.rb +14 -14
- data/test/test_rdoc_markup_to_html.rb +15 -3
- data/test/test_rdoc_markup_to_html_crossref.rb +276 -7
- data/test/test_rdoc_parser.rb +13 -0
- data/test/test_rdoc_parser_c.rb +1 -1
- data/test/test_rdoc_parser_ruby.rb +72 -1
- data/test/test_rdoc_ri_default_display.rb +23 -22
- data/test/test_rdoc_ri_driver.rb +1 -1
- data/test/test_rdoc_ri_formatter.rb +1 -1
- metadata +27 -35
- data.tar.gz.sig +0 -1
- metadata.gz.sig +0 -0
data/lib/rdoc/ri/formatter.rb
CHANGED
data/lib/rdoc/ri/paths.rb
CHANGED
@@ -26,9 +26,9 @@ module RDoc::RI::Paths
|
|
26
26
|
|
27
27
|
DOC_DIR = "doc/rdoc"
|
28
28
|
|
29
|
-
|
29
|
+
VERSION = RbConfig::CONFIG['ruby_version']
|
30
30
|
|
31
|
-
base = File.join(RbConfig::CONFIG['datadir'], "ri",
|
31
|
+
base = File.join(RbConfig::CONFIG['datadir'], "ri", VERSION)
|
32
32
|
SYSDIR = File.join(base, "system")
|
33
33
|
SITEDIR = File.join(base, "site")
|
34
34
|
homedir = ENV['HOME'] || ENV['USERPROFILE'] || ENV['HOMEPATH']
|
@@ -39,9 +39,6 @@ module RDoc::RI::Paths
|
|
39
39
|
HOMEDIR = nil
|
40
40
|
end
|
41
41
|
|
42
|
-
# This is the search path for 'ri'
|
43
|
-
PATH = [ SYSDIR, SITEDIR, HOMEDIR ].find_all {|p| p && File.directory?(p)}
|
44
|
-
|
45
42
|
begin
|
46
43
|
require 'rubygems' unless defined?(Gem) and defined?(Gem::Enable) and
|
47
44
|
Gem::Enable
|
@@ -67,7 +64,6 @@ module RDoc::RI::Paths
|
|
67
64
|
end
|
68
65
|
|
69
66
|
GEMDIRS = ri_paths.map { |k,v| v.last }.sort
|
70
|
-
GEMDIRS.each { |dir| PATH << dir }
|
71
67
|
rescue LoadError
|
72
68
|
GEMDIRS = []
|
73
69
|
end
|
@@ -85,9 +81,6 @@ module RDoc::RI::Paths
|
|
85
81
|
# found.
|
86
82
|
|
87
83
|
def self.raw_path(use_system, use_site, use_home, use_gems, *extra_dirs)
|
88
|
-
return PATH unless use_system or use_site or use_home or use_gems or
|
89
|
-
not extra_dirs.empty?
|
90
|
-
|
91
84
|
path = []
|
92
85
|
path << extra_dirs unless extra_dirs.empty?
|
93
86
|
path << SYSDIR if use_system
|
@@ -97,6 +90,4 @@ module RDoc::RI::Paths
|
|
97
90
|
|
98
91
|
return path.flatten.compact
|
99
92
|
end
|
100
|
-
|
101
93
|
end
|
102
|
-
|
data/lib/rdoc/ri/reader.rb
CHANGED
@@ -45,7 +45,7 @@ class RDoc::RI::Reader
|
|
45
45
|
|
46
46
|
def get_method(method_entry)
|
47
47
|
path = method_entry.path_name
|
48
|
-
File.open(path) { |f| RI::Description.deserialize(f) }
|
48
|
+
File.open(path) { |f| RDoc::RI::Description.deserialize(f) }
|
49
49
|
end
|
50
50
|
|
51
51
|
##
|
@@ -54,8 +54,8 @@ class RDoc::RI::Reader
|
|
54
54
|
def get_class(class_entry)
|
55
55
|
result = nil
|
56
56
|
for path in class_entry.path_names
|
57
|
-
path =
|
58
|
-
desc = File.open(path) {|f| RI::Description.deserialize(f) }
|
57
|
+
path = RDoc::RI::Writer.class_desc_path(path, class_entry)
|
58
|
+
desc = File.open(path) {|f| RDoc::RI::Description.deserialize(f) }
|
59
59
|
if result
|
60
60
|
result.merge_in(desc)
|
61
61
|
else
|
data/lib/rdoc/ri/util.rb
CHANGED
data/test/binary.dat
ADDED
Binary file
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#
|
2
|
+
# This file is parsed by test_rdoc_markup_to_html_crossref.rb
|
3
|
+
# during its tests.
|
4
|
+
#
|
5
|
+
class Ref_Class1
|
6
|
+
end
|
7
|
+
|
8
|
+
class Ref_Class2
|
9
|
+
class Ref_Class3
|
10
|
+
def method
|
11
|
+
end
|
12
|
+
|
13
|
+
class Helper1
|
14
|
+
def method?
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class Ref_Class3
|
21
|
+
class Helper1
|
22
|
+
end
|
23
|
+
|
24
|
+
class Helper2
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class Ref_Class4
|
29
|
+
class Ref_Class4
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'rdoc/markup/attribute_manager'
|
3
|
+
|
4
|
+
class TestAttributeManager < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@am = RDoc::Markup::AttributeManager.new
|
8
|
+
@klass = RDoc::Markup::AttributeManager
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown
|
12
|
+
silently do
|
13
|
+
@klass.const_set(:MATCHING_WORD_PAIRS, {})
|
14
|
+
@klass.const_set(:WORD_PAIR_MAP, {})
|
15
|
+
@klass.const_set(:HTML_TAGS, {})
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_initial_word_pairs
|
20
|
+
word_pairs = @klass::MATCHING_WORD_PAIRS
|
21
|
+
assert word_pairs.is_a?(Hash)
|
22
|
+
assert_equal(3, word_pairs.size)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_initial_html
|
26
|
+
html_tags = @klass::HTML_TAGS
|
27
|
+
assert html_tags.is_a?(Hash)
|
28
|
+
assert_equal(5, html_tags.size)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_add_matching_word_pair
|
32
|
+
@am.add_word_pair("x","x", :TEST)
|
33
|
+
word_pairs = @klass::MATCHING_WORD_PAIRS
|
34
|
+
assert_equal(4,word_pairs.size)
|
35
|
+
assert(word_pairs.has_key?("x"))
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_add_invalid_word_pair
|
39
|
+
assert_raise ArgumentError do
|
40
|
+
@am.add_word_pair("<", "<", :TEST)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_add_word_pair_map
|
45
|
+
@am.add_word_pair("x", "y", :TEST)
|
46
|
+
word_pair_map = @klass::WORD_PAIR_MAP
|
47
|
+
assert_equal(1,word_pair_map.size)
|
48
|
+
assert_equal(word_pair_map. keys.first.source, "(x)(\\S+)(y)")
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_add_html_tag
|
52
|
+
@am.add_html("Test", :TEST)
|
53
|
+
tags = @klass::HTML_TAGS
|
54
|
+
assert_equal(6, tags.size)
|
55
|
+
assert(tags.has_key?("test"))
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_add_special
|
59
|
+
@am.add_special("WikiWord", :WIKIWORD)
|
60
|
+
specials = @klass::SPECIAL
|
61
|
+
assert_equal(1,specials.size)
|
62
|
+
assert(specials.has_key?("WikiWord"))
|
63
|
+
end
|
64
|
+
|
65
|
+
def silently(&block)
|
66
|
+
warn_level = $VERBOSE
|
67
|
+
$VERBOSE = nil
|
68
|
+
result = block.call
|
69
|
+
$VERBOSE = warn_level
|
70
|
+
result
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
@@ -5,7 +5,7 @@ require 'test/unit'
|
|
5
5
|
require 'rdoc/generator/texinfo'
|
6
6
|
|
7
7
|
# From chapter 18 of the Pickaxe 3rd ed. and the TexInfo manual.
|
8
|
-
class
|
8
|
+
class TestRDocInfoFormatting < Test::Unit::TestCase
|
9
9
|
def setup
|
10
10
|
@output_dir = File.join Dir.tmpdir, "test_rdoc_info_formatting_#{$$}"
|
11
11
|
@output_file = File.join @output_dir, 'rdoc.texinfo'
|
@@ -19,7 +19,7 @@ class TestRdocInfoFormatting < Test::Unit::TestCase
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def teardown
|
22
|
-
FileUtils.rm_rf @output_dir
|
22
|
+
# FileUtils.rm_rf @output_dir
|
23
23
|
end
|
24
24
|
|
25
25
|
# Make sure tags like *this* do not make HTML
|
@@ -73,10 +73,10 @@ class TestRdocInfoFormatting < Test::Unit::TestCase
|
|
73
73
|
# === Everything deeper becomes a regular @heading
|
74
74
|
# ====== Regardless of its nesting level
|
75
75
|
def test_headings
|
76
|
-
assert_match(/@majorheading
|
77
|
-
assert_match(/@chapheading
|
78
|
-
assert_match(/@heading
|
79
|
-
assert_match(/@heading
|
76
|
+
assert_match(/@majorheading Huge heading should be a @@majorheading/)
|
77
|
+
assert_match(/@chapheading There is also @@chapheading/)
|
78
|
+
assert_match(/@heading Everything deeper becomes a regular @@heading/)
|
79
|
+
assert_match(/@heading Regardless of its nesting level/)
|
80
80
|
end
|
81
81
|
|
82
82
|
# * list item
|
@@ -6,10 +6,10 @@ require 'tmpdir'
|
|
6
6
|
require 'rdoc/generator/texinfo'
|
7
7
|
|
8
8
|
# give us access to check this stuff before it's rendered
|
9
|
-
class RDoc::Generator::
|
9
|
+
class RDoc::Generator::TEXINFO; attr_reader :files, :classes; end
|
10
10
|
class RDoc::RDoc; attr_reader :options; attr_reader :gen; end
|
11
11
|
|
12
|
-
class
|
12
|
+
class TestRDocInfoSections < Test::Unit::TestCase
|
13
13
|
|
14
14
|
def setup
|
15
15
|
@output_dir = File.join Dir.tmpdir, "test_rdoc_info_sections_#{$$}"
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require "test/unit"
|
2
2
|
require "rdoc/markup/inline"
|
3
|
+
require "rdoc/markup/to_html_crossref"
|
3
4
|
|
4
5
|
class TestRDocMarkupAttributeManager < Test::Unit::TestCase
|
5
6
|
|
@@ -201,24 +202,23 @@ class TestRDocMarkupAttributeManager < Test::Unit::TestCase
|
|
201
202
|
end
|
202
203
|
|
203
204
|
def test_special
|
204
|
-
|
205
|
-
@am.add_special(/(
|
206
|
-
\b([A-Z]\w+(::\w+)*)
|
207
|
-
| \#\w+[!?=]?
|
208
|
-
| \b\w+([_\/\.]+\w+)+[!?=]?
|
209
|
-
)/x,
|
210
|
-
:CROSSREF)
|
205
|
+
@am.add_special(RDoc::Markup::ToHtmlCrossref::CROSSREF_REGEXP, :CROSSREF)
|
211
206
|
|
212
|
-
|
207
|
+
#
|
208
|
+
# The apostrophes in "cats'" and "dogs'" suppress the flagging of these
|
209
|
+
# words as potential cross-references, which is necessary for the unit
|
210
|
+
# tests. Unfortunately, the markup engine right now does not actually
|
211
|
+
# check whether a cross-reference is valid before flagging it.
|
212
|
+
#
|
213
|
+
assert_equal(["cats'"], @am.flow("cats'"))
|
213
214
|
|
214
|
-
assert_equal(["
|
215
|
-
@am.flow("
|
215
|
+
assert_equal(["cats' ", crossref("#fred"), " dogs'"].flatten,
|
216
|
+
@am.flow("cats' #fred dogs'"))
|
216
217
|
|
217
|
-
assert_equal([crossref("#fred"), "
|
218
|
-
@am.flow("#fred
|
218
|
+
assert_equal([crossref("#fred"), " dogs'"].flatten,
|
219
|
+
@am.flow("#fred dogs'"))
|
219
220
|
|
220
|
-
assert_equal(["
|
221
|
+
assert_equal(["cats' ", crossref("#fred")].flatten, @am.flow("cats' #fred"))
|
221
222
|
end
|
222
223
|
|
223
224
|
end
|
224
|
-
|
@@ -2,7 +2,7 @@ require 'test/unit'
|
|
2
2
|
require 'rdoc/markup'
|
3
3
|
require 'rdoc/markup/to_html'
|
4
4
|
|
5
|
-
class
|
5
|
+
class TestRDocMarkupToHtml < Test::Unit::TestCase
|
6
6
|
|
7
7
|
def setup
|
8
8
|
@am = RDoc::Markup::AttributeManager.new
|
@@ -10,11 +10,23 @@ class TestRdocMarkupToHtml < Test::Unit::TestCase
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_tt_formatting
|
13
|
-
assert_equal "<p>\n<tt>--</tt> — <tt>
|
14
|
-
util_format("<tt>--</tt> -- <tt>
|
13
|
+
assert_equal "<p>\n<tt>--</tt> — <tt>cats'</tt> cats’\n</p>\n",
|
14
|
+
util_format("<tt>--</tt> -- <tt>cats'</tt> cats'")
|
15
15
|
assert_equal "<p>\n<b>—</b>\n</p>\n", util_format("<b>--</b>")
|
16
16
|
end
|
17
17
|
|
18
|
+
def test_convert_string_fancy
|
19
|
+
#
|
20
|
+
# The HTML typesetting is broken in a number of ways, but I have fixed
|
21
|
+
# the most glaring issues for single and double quotes. Note that
|
22
|
+
# "strange" symbols (periods or dashes) need to be at the end of the
|
23
|
+
# test case strings in order to suppress cross-references.
|
24
|
+
#
|
25
|
+
assert_equal "<p>\n“cats”.\n</p>\n", util_format("\"cats\".")
|
26
|
+
assert_equal "<p>\n‘cats’.\n</p>\n", util_format("\'cats\'.")
|
27
|
+
assert_equal "<p>\ncat’s-\n</p>\n", util_format("cat\'s-")
|
28
|
+
end
|
29
|
+
|
18
30
|
def util_fragment(text)
|
19
31
|
RDoc::Markup::Fragment.new 0, nil, nil, text
|
20
32
|
end
|
@@ -2,17 +2,286 @@ require 'test/unit'
|
|
2
2
|
require 'rdoc/generator'
|
3
3
|
require 'rdoc/markup/to_html_crossref'
|
4
4
|
|
5
|
-
|
5
|
+
require 'pathname'
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
class TestRDocMarkupToHtmlCrossref < Test::Unit::TestCase
|
8
|
+
|
9
|
+
#
|
10
|
+
# This method parses a source file and returns a Hash mapping
|
11
|
+
# class names (Strings) to RDoc::Generator::Class instances
|
12
|
+
# (classes), which can be used to create RDoc::Markup::ToHtmlCrossref
|
13
|
+
# instances. The unit tests only test against classes starting with
|
14
|
+
# Ref_, so this method only includes such classes in the Hash.
|
15
|
+
#
|
16
|
+
def create_class_hash
|
17
|
+
# The relative gem would help here...
|
18
|
+
# @source_file_name must be cleaned because rdoc does not deal
|
19
|
+
# well with paths containing "." or "..".
|
20
|
+
curr_file = Pathname.new(__FILE__)
|
21
|
+
@source_file_name = curr_file.dirname + "rdoc_markup_to_html_crossref_reference.rb"
|
22
|
+
@source_file_name = @source_file_name.cleanpath.to_s
|
23
|
+
|
24
|
+
RDoc::TopLevel.reset
|
25
|
+
|
26
|
+
# Reset RDoc::Generator::Method so that the method sequence number starts
|
27
|
+
# at 1, making the method sequence numbers for the methods in the Ref_
|
28
|
+
# predicable.
|
29
|
+
RDoc::Generator::Method.reset
|
30
|
+
top_level = RDoc::TopLevel.new @source_file_name
|
31
|
+
|
32
|
+
options = RDoc::Options.new
|
33
|
+
options.quiet = true
|
34
|
+
|
35
|
+
# If this is false, then RDoc::Generator::Method will attempt to create
|
36
|
+
# an HTML file containing the method source code when being instantiated,
|
37
|
+
# which does not work in the context of this unit test.
|
38
|
+
#
|
39
|
+
# RDoc::Generator::Method needs to be refactored so that this does *not*
|
40
|
+
# happen as part of instantiation.
|
41
|
+
options.inline_source = true
|
42
|
+
|
43
|
+
stats = RDoc::Stats.new 0
|
44
|
+
|
45
|
+
parser = RDoc::Parser::Ruby.new(top_level,
|
46
|
+
@source_file_name,
|
47
|
+
IO.read(@source_file_name),
|
48
|
+
options,
|
49
|
+
stats)
|
50
|
+
top_levels = []
|
51
|
+
top_levels.push(parser.scan())
|
52
|
+
|
53
|
+
files, classes = RDoc::Generator::Context.build_indices(top_levels, options)
|
54
|
+
|
55
|
+
class_hash = {}
|
56
|
+
classes.each do |klass|
|
57
|
+
if(klass.name.include?("Ref_"))
|
58
|
+
class_hash[klass.name] = klass
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
return class_hash
|
9
63
|
end
|
10
64
|
|
11
|
-
|
12
|
-
|
65
|
+
#
|
66
|
+
# This method uses xref to cross-reference String reference and
|
67
|
+
# asserts that xref.convert(reference) is equal
|
68
|
+
# to String expected_result.
|
69
|
+
#
|
70
|
+
def verify_convert(xref, reference, expected_result)
|
71
|
+
# Everything converted in the tests will be within paragraph markup, so
|
72
|
+
# add paragraph markup to the expected result.
|
73
|
+
actual_expected_result = "<p>\n#{expected_result}\n</p>\n"
|
74
|
+
|
75
|
+
result = xref.convert(reference)
|
76
|
+
|
77
|
+
# RDoc::Markup::ToHtml word-wraps lines. It is tricky to predict where
|
78
|
+
# a line will be wrapped except that it will happen on a space, so replace
|
79
|
+
# all newlines with spaces in order to not have to worry about this.
|
80
|
+
actual_expected_result.gsub!(/\n/, " ")
|
81
|
+
result.gsub!(/\n/, " ")
|
13
82
|
|
14
|
-
assert_equal
|
83
|
+
assert_equal actual_expected_result, result
|
15
84
|
end
|
16
85
|
|
17
|
-
|
86
|
+
#
|
87
|
+
# This method verifies that xref generates no cross-reference link for
|
88
|
+
# String reference.
|
89
|
+
#
|
90
|
+
def verify_no_crossref(xref, reference)
|
91
|
+
if(reference[0, 1] == "\\") # Remove the markup suppression character
|
92
|
+
expected_result = reference[1, reference.length() - 1]
|
93
|
+
else
|
94
|
+
expected_result = reference
|
95
|
+
end
|
96
|
+
|
97
|
+
verify_convert(xref, reference, expected_result)
|
98
|
+
end
|
99
|
+
|
100
|
+
#
|
101
|
+
# This method verifies that xref generates a cross-reference link to
|
102
|
+
# class_name (String) for String reference.
|
103
|
+
#
|
104
|
+
def verify_class_crossref(xref, reference, class_name)
|
105
|
+
class_file_name = class_name.gsub(/::/, "/")
|
106
|
+
|
107
|
+
result = "<a href=\"../classes/#{class_file_name}.html\">#{reference}</a>"
|
108
|
+
|
109
|
+
verify_convert xref, reference, result
|
110
|
+
end
|
18
111
|
|
112
|
+
#
|
113
|
+
# This method verifies that xref generates a cross-reference link to method
|
114
|
+
# method_seq (String, e.g, "M000001") in class_name (String) for
|
115
|
+
# String reference.
|
116
|
+
#
|
117
|
+
def verify_method_crossref(xref, reference, class_name, method_seq)
|
118
|
+
class_file_name = class_name.gsub(/::/, "/")
|
119
|
+
|
120
|
+
result = "<a href=\"../classes/#{class_file_name}.html##{method_seq}\">#{reference}</a>"
|
121
|
+
|
122
|
+
verify_convert xref, reference, result
|
123
|
+
end
|
124
|
+
|
125
|
+
#
|
126
|
+
# This method verifies that xref generates a cross-reference link to
|
127
|
+
# file_name (String) for String reference.
|
128
|
+
#
|
129
|
+
def verify_file_crossref(xref, reference, file_name)
|
130
|
+
result = "<a href=\"../files/#{file_name.gsub(/\./, '_')}.html\">#{reference}</a>"
|
131
|
+
|
132
|
+
verify_convert xref, reference, result
|
133
|
+
end
|
134
|
+
|
135
|
+
#
|
136
|
+
# This method verifies that several invariant cross-references are
|
137
|
+
# (or are not) generated.
|
138
|
+
#
|
139
|
+
def verify_invariant_crossrefs(xref)
|
140
|
+
# bogus does not exist and so no cross-reference should be generated.
|
141
|
+
verify_no_crossref xref, "bogus"
|
142
|
+
verify_no_crossref xref, "\\bogus"
|
143
|
+
|
144
|
+
# Ref_Class1 is in the top-level namespace, and so a cross-reference always
|
145
|
+
# should be generated, unless markup is suppressed.
|
146
|
+
verify_class_crossref xref, "Ref_Class1", "Ref_Class1"
|
147
|
+
verify_no_crossref xref, "\\Ref_Class1"
|
148
|
+
|
149
|
+
# Ref_Class2 is in the top-level namespace, and so a cross-reference always
|
150
|
+
# should be generated for it and for its nested classes.
|
151
|
+
verify_class_crossref xref, "Ref_Class2", "Ref_Class2"
|
152
|
+
verify_class_crossref xref, "Ref_Class2::Ref_Class3", "Ref_Class2::Ref_Class3"
|
153
|
+
verify_method_crossref xref, "Ref_Class2::Ref_Class3#method", "Ref_Class2::Ref_Class3", "M000001"
|
154
|
+
verify_method_crossref xref, "Ref_Class2::Ref_Class3#method()", "Ref_Class2::Ref_Class3", "M000001"
|
155
|
+
verify_method_crossref xref, "Ref_Class2::Ref_Class3.method()", "Ref_Class2::Ref_Class3", "M000001"
|
156
|
+
verify_method_crossref xref, "Ref_Class2::Ref_Class3.method(*)", "Ref_Class2::Ref_Class3", "M000001"
|
157
|
+
verify_class_crossref xref, "Ref_Class2::Ref_Class3::Helper1", "Ref_Class2::Ref_Class3::Helper1"
|
158
|
+
verify_method_crossref xref, "Ref_Class2::Ref_Class3::Helper1#method?", "Ref_Class2::Ref_Class3::Helper1", "M000002"
|
159
|
+
|
160
|
+
# The hyphen character is not a valid class/method separator character, so
|
161
|
+
# rdoc just generates a class cross-reference (perhaps it should not
|
162
|
+
# generate anything?).
|
163
|
+
result = "<a href=\"../classes/Ref_Class2/Ref_Class3.html\">Ref_Class2::Ref_Class3</a>;method(*)"
|
164
|
+
verify_convert xref, "Ref_Class2::Ref_Class3;method(*)", result
|
165
|
+
|
166
|
+
# There is one Ref_Class3 nested in Ref_Class2 and one defined in the
|
167
|
+
# top-level namespace; regardless, ::Ref_Class3 (Ref_Class3 relative
|
168
|
+
# to the top-level namespace) always should generate a link to the
|
169
|
+
# top-level Ref_Class3 (unless of course cross-references are suppressed).
|
170
|
+
verify_class_crossref xref, "::Ref_Class3", "Ref_Class3"
|
171
|
+
verify_no_crossref xref, "\\::Ref_Class3"
|
172
|
+
verify_class_crossref xref, "::Ref_Class3::Helper1", "Ref_Class3::Helper1"
|
173
|
+
verify_class_crossref xref, "::Ref_Class3::Helper2", "Ref_Class3::Helper2"
|
174
|
+
|
175
|
+
#
|
176
|
+
# Ref_Class3::Helper1 does not have method method.
|
177
|
+
#
|
178
|
+
verify_no_crossref xref, "::Ref_Class3::Helper1#method"
|
179
|
+
verify_no_crossref xref, "\\::Ref_Class3::Helper1#method"
|
180
|
+
|
181
|
+
# References to Ref_Class2 relative to the top-level namespace always should
|
182
|
+
# generate links to Ref_Class2.
|
183
|
+
verify_method_crossref xref, "::Ref_Class2::Ref_Class3#method", "Ref_Class2::Ref_Class3", "M000001"
|
184
|
+
verify_method_crossref xref, "::Ref_Class2::Ref_Class3#method()", "Ref_Class2::Ref_Class3", "M000001"
|
185
|
+
verify_method_crossref xref, "::Ref_Class2::Ref_Class3#method(*)", "Ref_Class2::Ref_Class3", "M000001"
|
186
|
+
verify_class_crossref xref, "::Ref_Class2::Ref_Class3::Helper1", "Ref_Class2::Ref_Class3::Helper1"
|
187
|
+
verify_no_crossref xref, "\\::Ref_Class2::Ref_Class3#method(*)"
|
188
|
+
|
189
|
+
# Suppressing cross-references always should suppress the generation of
|
190
|
+
# links.
|
191
|
+
verify_no_crossref xref, "\\#method"
|
192
|
+
verify_no_crossref xref, "\\#method()"
|
193
|
+
verify_no_crossref xref, "\\#method(*)"
|
194
|
+
|
195
|
+
# Links never should be generated for words solely consisting of lowercase
|
196
|
+
# letters, because too many links would get generated by mistake (i.e., the
|
197
|
+
# word "new" always would be a link).
|
198
|
+
verify_no_crossref xref, "method"
|
199
|
+
|
200
|
+
# A link always should be generated for a file name.
|
201
|
+
verify_file_crossref xref, @source_file_name, @source_file_name
|
202
|
+
|
203
|
+
# References should be generated correctly for a class scoped within
|
204
|
+
# a class of the same name.
|
205
|
+
verify_class_crossref xref, "Ref_Class4::Ref_Class4", "Ref_Class4::Ref_Class4"
|
206
|
+
end
|
207
|
+
|
208
|
+
def test_handle_special_CROSSREF_no_underscore
|
209
|
+
class_hash = create_class_hash
|
210
|
+
|
211
|
+
# Note that we instruct the ToHtmlCrossref instance to show hashes so that
|
212
|
+
# an exception won't have to be made for words starting with a '#'.
|
213
|
+
# I'm also not convinced that the current behavior of the rdoc code
|
214
|
+
# is correct since, without this, it strips the leading # from all
|
215
|
+
# words, whether or not they end up as cross-references.
|
216
|
+
#
|
217
|
+
# After the behavior has been sorted out, this can be changed.
|
218
|
+
#
|
219
|
+
# Create a variety of RDoc::Markup::ToHtmlCrossref instances, for
|
220
|
+
# different classes, and test the cross-references generated by
|
221
|
+
# each.
|
222
|
+
klass = class_hash["Ref_Class1"]
|
223
|
+
xref = RDoc::Markup::ToHtmlCrossref.new 'from_path', klass, true
|
224
|
+
verify_invariant_crossrefs xref
|
225
|
+
verify_class_crossref xref, "Ref_Class3", "Ref_Class3"
|
226
|
+
verify_no_crossref xref, "Ref_Class3#method"
|
227
|
+
verify_no_crossref xref, "#method"
|
228
|
+
verify_class_crossref xref, "Ref_Class3::Helper1", "Ref_Class3::Helper1"
|
229
|
+
verify_class_crossref xref, "Ref_Class3::Helper2", "Ref_Class3::Helper2"
|
230
|
+
verify_no_crossref xref, "Helper1"
|
231
|
+
verify_class_crossref xref, "Ref_Class4", "Ref_Class4"
|
232
|
+
|
233
|
+
klass = class_hash["Ref_Class2"]
|
234
|
+
xref = RDoc::Markup::ToHtmlCrossref.new 'from_path', klass, true
|
235
|
+
verify_invariant_crossrefs xref
|
236
|
+
verify_class_crossref xref, "Ref_Class3", "Ref_Class2::Ref_Class3"
|
237
|
+
verify_method_crossref xref, "Ref_Class3#method", "Ref_Class2::Ref_Class3", "M000001"
|
238
|
+
verify_no_crossref xref, "#method"
|
239
|
+
verify_class_crossref xref, "Ref_Class3::Helper1", "Ref_Class2::Ref_Class3::Helper1"
|
240
|
+
verify_class_crossref xref, "Ref_Class4", "Ref_Class4"
|
241
|
+
|
242
|
+
# This one possibly is an rdoc bug...
|
243
|
+
# Ref_Class2 has a nested Ref_Class3, but
|
244
|
+
# Ref_Class2::Ref_Class3::Helper2 does not exist.
|
245
|
+
# On the other hand, there is a Ref_Class3::Helper2
|
246
|
+
# in the top-level namespace... Should rdoc stop
|
247
|
+
# looking if it finds one class match?
|
248
|
+
verify_no_crossref xref, "Ref_Class3::Helper2"
|
249
|
+
verify_no_crossref xref, "Helper1"
|
250
|
+
|
251
|
+
klass = class_hash["Ref_Class2::Ref_Class3"]
|
252
|
+
xref = RDoc::Markup::ToHtmlCrossref.new 'from_path', klass, true
|
253
|
+
verify_invariant_crossrefs xref
|
254
|
+
verify_class_crossref xref, "Ref_Class3", "Ref_Class2::Ref_Class3"
|
255
|
+
verify_method_crossref xref, "Ref_Class3#method", "Ref_Class2::Ref_Class3", "M000001"
|
256
|
+
verify_method_crossref xref, "#method", "Ref_Class2::Ref_Class3", "M000001"
|
257
|
+
verify_class_crossref xref, "Ref_Class3::Helper1", "Ref_Class2::Ref_Class3::Helper1"
|
258
|
+
verify_no_crossref xref, "Ref_Class3::Helper2"
|
259
|
+
verify_class_crossref xref, "Helper1", "Ref_Class2::Ref_Class3::Helper1"
|
260
|
+
verify_class_crossref xref, "Ref_Class4", "Ref_Class4"
|
261
|
+
|
262
|
+
klass = class_hash["Ref_Class3"]
|
263
|
+
xref = RDoc::Markup::ToHtmlCrossref.new 'from_path', klass, true
|
264
|
+
verify_invariant_crossrefs xref
|
265
|
+
verify_class_crossref xref, "Ref_Class3", "Ref_Class3"
|
266
|
+
verify_no_crossref xref, "Ref_Class3#method"
|
267
|
+
verify_no_crossref xref, "#method"
|
268
|
+
verify_class_crossref xref, "Ref_Class3::Helper1", "Ref_Class3::Helper1"
|
269
|
+
verify_class_crossref xref, "Ref_Class3::Helper2", "Ref_Class3::Helper2"
|
270
|
+
verify_class_crossref xref, "Helper1", "Ref_Class3::Helper1"
|
271
|
+
verify_class_crossref xref, "Ref_Class4", "Ref_Class4"
|
272
|
+
|
273
|
+
klass = class_hash["Ref_Class4"]
|
274
|
+
xref = RDoc::Markup::ToHtmlCrossref.new 'from_path', klass, true
|
275
|
+
verify_invariant_crossrefs xref
|
276
|
+
# A Ref_Class4 reference inside a Ref_Class4 class containing a
|
277
|
+
# Ref_Class4 class should resolve to the contained class.
|
278
|
+
verify_class_crossref xref, "Ref_Class4", "Ref_Class4::Ref_Class4"
|
279
|
+
|
280
|
+
klass = class_hash["Ref_Class4::Ref_Class4"]
|
281
|
+
xref = RDoc::Markup::ToHtmlCrossref.new 'from_path', klass, true
|
282
|
+
verify_invariant_crossrefs xref
|
283
|
+
# A Ref_Class4 reference inside a Ref_Class4 class contained within
|
284
|
+
# a Ref_Class4 class should resolve to the inner Ref_Class4 class.
|
285
|
+
verify_class_crossref xref, "Ref_Class4", "Ref_Class4::Ref_Class4"
|
286
|
+
end
|
287
|
+
end
|