rdoc 3.12.2 → 4.0.0.preview2
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.
- checksums.yaml +6 -6
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.autotest +3 -2
- data/DEVELOPERS.rdoc +53 -0
- data/History.rdoc +159 -25
- data/LEGAL.rdoc +12 -0
- data/Manifest.txt +56 -3
- data/README.rdoc +87 -19
- data/Rakefile +11 -2
- data/TODO.rdoc +20 -13
- data/bin/rdoc +4 -0
- data/lib/gauntlet_rdoc.rb +1 -1
- data/lib/rdoc.rb +32 -71
- data/lib/rdoc/any_method.rb +75 -21
- data/lib/rdoc/attr.rb +49 -10
- data/lib/rdoc/class_module.rb +182 -32
- data/lib/rdoc/code_object.rb +54 -12
- data/lib/rdoc/comment.rb +8 -1
- data/lib/rdoc/constant.rb +100 -6
- data/lib/rdoc/context.rb +93 -41
- data/lib/rdoc/context/section.rb +143 -28
- data/lib/rdoc/cross_reference.rb +58 -50
- data/lib/rdoc/encoding.rb +34 -29
- data/lib/rdoc/erb_partial.rb +18 -0
- data/lib/rdoc/extend.rb +117 -0
- data/lib/rdoc/generator.rb +11 -6
- data/lib/rdoc/generator/darkfish.rb +250 -62
- data/lib/rdoc/generator/json_index.rb +20 -12
- data/lib/rdoc/generator/markup.rb +10 -12
- data/lib/rdoc/generator/ri.rb +7 -60
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +7 -7
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +16 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +14 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +13 -0
- data/lib/rdoc/generator/template/darkfish/class.rhtml +15 -1
- data/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
- data/lib/rdoc/generator/template/darkfish/index.rhtml +3 -3
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +7 -9
- data/lib/rdoc/generator/template/darkfish/page.rhtml +2 -0
- data/lib/rdoc/generator/template/darkfish/rdoc.css +31 -0
- data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +18 -0
- data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +37 -0
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +3 -3
- data/lib/rdoc/include.rb +12 -3
- data/lib/rdoc/markdown.kpeg +1186 -0
- data/lib/rdoc/markdown.rb +16336 -0
- data/lib/rdoc/markdown/entities.rb +2128 -0
- data/lib/rdoc/markdown/literals_1_8.kpeg +18 -0
- data/lib/rdoc/markdown/literals_1_8.rb +454 -0
- data/lib/rdoc/markdown/literals_1_9.kpeg +22 -0
- data/lib/rdoc/markdown/literals_1_9.rb +417 -0
- data/lib/rdoc/markup.rb +69 -10
- data/lib/rdoc/markup/attr_changer.rb +2 -5
- data/lib/rdoc/markup/attribute_manager.rb +23 -14
- data/lib/rdoc/markup/attributes.rb +70 -0
- data/lib/rdoc/markup/block_quote.rb +14 -0
- data/lib/rdoc/markup/document.rb +20 -4
- data/lib/rdoc/markup/formatter.rb +17 -6
- data/lib/rdoc/markup/formatter_test_case.rb +93 -24
- data/lib/rdoc/markup/hard_break.rb +31 -0
- data/lib/rdoc/markup/heading.rb +1 -1
- data/lib/rdoc/markup/indented_paragraph.rb +14 -0
- data/lib/rdoc/markup/list.rb +23 -4
- data/lib/rdoc/markup/list_item.rb +17 -4
- data/lib/rdoc/markup/paragraph.rb +14 -0
- data/lib/rdoc/markup/parser.rb +107 -60
- data/lib/rdoc/markup/raw.rb +4 -4
- data/lib/rdoc/markup/special.rb +3 -3
- data/lib/rdoc/markup/to_ansi.rb +7 -1
- data/lib/rdoc/markup/to_html.rb +42 -14
- data/lib/rdoc/markup/to_html_crossref.rb +10 -9
- data/lib/rdoc/markup/to_html_snippet.rb +20 -4
- data/lib/rdoc/markup/to_joined_paragraph.rb +68 -0
- data/lib/rdoc/markup/to_label.rb +20 -1
- data/lib/rdoc/markup/to_markdown.rb +134 -0
- data/lib/rdoc/markup/to_rdoc.rb +36 -5
- data/lib/rdoc/markup/to_table_of_contents.rb +6 -1
- data/lib/rdoc/markup/to_tt_only.rb +11 -2
- data/lib/rdoc/markup/verbatim.rb +19 -0
- data/lib/rdoc/method_attr.rb +33 -19
- data/lib/rdoc/normal_class.rb +26 -7
- data/lib/rdoc/normal_module.rb +10 -5
- data/lib/rdoc/options.rb +95 -21
- data/lib/rdoc/parser.rb +6 -2
- data/lib/rdoc/parser/c.rb +212 -97
- data/lib/rdoc/parser/markdown.rb +23 -0
- data/lib/rdoc/parser/ruby.rb +115 -35
- data/lib/rdoc/parser/ruby_tools.rb +8 -3
- data/lib/rdoc/rd.rb +8 -4
- data/lib/rdoc/rd/block_parser.rb +1 -1
- data/lib/rdoc/rd/block_parser.ry +1 -1
- data/lib/rdoc/rdoc.rb +45 -21
- data/lib/rdoc/ri/driver.rb +322 -76
- data/lib/rdoc/ri/paths.rb +90 -31
- data/lib/rdoc/ri/store.rb +2 -353
- data/lib/rdoc/ruby_lex.rb +5 -21
- data/lib/rdoc/ruby_token.rb +2 -3
- data/lib/rdoc/rubygems_hook.rb +21 -9
- data/lib/rdoc/servlet.rb +302 -0
- data/lib/rdoc/stats.rb +28 -20
- data/lib/rdoc/store.rb +881 -0
- data/lib/rdoc/task.rb +2 -1
- data/lib/rdoc/test_case.rb +103 -1
- data/lib/rdoc/text.rb +5 -4
- data/lib/rdoc/tom_doc.rb +17 -16
- data/lib/rdoc/top_level.rb +43 -285
- data/test/MarkdownTest_1.0.3/Amps and angle encoding.text +21 -0
- data/test/MarkdownTest_1.0.3/Auto links.text +13 -0
- data/test/MarkdownTest_1.0.3/Backslash escapes.text +120 -0
- data/test/MarkdownTest_1.0.3/Blockquotes with code blocks.text +11 -0
- data/test/MarkdownTest_1.0.3/Code Blocks.text +14 -0
- data/test/MarkdownTest_1.0.3/Code Spans.text +6 -0
- data/test/MarkdownTest_1.0.3/Hard-wrapped paragraphs with list-like lines.text +8 -0
- data/test/MarkdownTest_1.0.3/Horizontal rules.text +67 -0
- data/test/MarkdownTest_1.0.3/Inline HTML (Advanced).text +15 -0
- data/test/MarkdownTest_1.0.3/Inline HTML (Simple).text +69 -0
- data/test/MarkdownTest_1.0.3/Inline HTML comments.text +13 -0
- data/test/MarkdownTest_1.0.3/Links, inline style.text +12 -0
- data/test/MarkdownTest_1.0.3/Links, reference style.text +71 -0
- data/test/MarkdownTest_1.0.3/Links, shortcut references.text +20 -0
- data/test/MarkdownTest_1.0.3/Literal quotes in titles.text +7 -0
- data/test/MarkdownTest_1.0.3/Markdown Documentation - Basics.text +306 -0
- data/test/MarkdownTest_1.0.3/Markdown Documentation - Syntax.text +888 -0
- data/test/MarkdownTest_1.0.3/Nested blockquotes.text +5 -0
- data/test/MarkdownTest_1.0.3/Ordered and unordered lists.text +131 -0
- data/test/MarkdownTest_1.0.3/Strong and em together.text +7 -0
- data/test/MarkdownTest_1.0.3/Tabs.text +21 -0
- data/test/MarkdownTest_1.0.3/Tidyness.text +5 -0
- data/test/test_attribute_manager.rb +7 -4
- data/test/test_rdoc_any_method.rb +84 -13
- data/test/test_rdoc_attr.rb +59 -9
- data/test/test_rdoc_class_module.rb +670 -73
- data/test/test_rdoc_code_object.rb +21 -1
- data/test/test_rdoc_comment.rb +1 -1
- data/test/test_rdoc_constant.rb +132 -0
- data/test/test_rdoc_context.rb +84 -18
- data/test/test_rdoc_context_section.rb +99 -15
- data/test/test_rdoc_cross_reference.rb +1 -1
- data/test/test_rdoc_encoding.rb +17 -1
- data/test/test_rdoc_extend.rb +94 -0
- data/test/test_rdoc_generator_darkfish.rb +45 -19
- data/test/test_rdoc_generator_json_index.rb +27 -7
- data/test/test_rdoc_generator_markup.rb +3 -3
- data/test/test_rdoc_generator_ri.rb +11 -9
- data/test/test_rdoc_include.rb +12 -0
- data/test/test_rdoc_markdown.rb +977 -0
- data/test/test_rdoc_markdown_test.rb +1891 -0
- data/test/test_rdoc_markup.rb +1 -1
- data/test/test_rdoc_markup_attribute_manager.rb +2 -2
- data/test/test_rdoc_markup_attributes.rb +39 -0
- data/test/test_rdoc_markup_document.rb +16 -1
- data/test/test_rdoc_markup_formatter.rb +7 -4
- data/test/test_rdoc_markup_hard_break.rb +31 -0
- data/test/test_rdoc_markup_indented_paragraph.rb +14 -0
- data/test/test_rdoc_markup_paragraph.rb +15 -1
- data/test/test_rdoc_markup_parser.rb +152 -89
- data/test/test_rdoc_markup_to_ansi.rb +23 -2
- data/test/test_rdoc_markup_to_bs.rb +24 -0
- data/test/test_rdoc_markup_to_html.rb +50 -19
- data/test/test_rdoc_markup_to_html_crossref.rb +23 -5
- data/test/test_rdoc_markup_to_html_snippet.rb +49 -8
- data/test/test_rdoc_markup_to_joined_paragraph.rb +32 -0
- data/test/test_rdoc_markup_to_label.rb +63 -1
- data/test/test_rdoc_markup_to_markdown.rb +352 -0
- data/test/test_rdoc_markup_to_rdoc.rb +22 -2
- data/test/test_rdoc_markup_to_table_of_contents.rb +44 -39
- data/test/test_rdoc_markup_to_tt_only.rb +20 -0
- data/test/test_rdoc_markup_verbatim.rb +13 -0
- data/test/test_rdoc_method_attr.rb +5 -0
- data/test/test_rdoc_normal_class.rb +24 -5
- data/test/test_rdoc_normal_module.rb +1 -1
- data/test/test_rdoc_options.rb +21 -6
- data/test/test_rdoc_parser.rb +24 -0
- data/test/test_rdoc_parser_c.rb +151 -26
- data/test/test_rdoc_parser_markdown.rb +55 -0
- data/test/test_rdoc_parser_rd.rb +2 -2
- data/test/test_rdoc_parser_ruby.rb +468 -109
- data/test/test_rdoc_parser_simple.rb +2 -2
- data/test/test_rdoc_rd_block_parser.rb +0 -4
- data/test/test_rdoc_rdoc.rb +110 -22
- data/test/test_rdoc_ri_driver.rb +415 -80
- data/test/test_rdoc_ri_paths.rb +122 -13
- data/test/test_rdoc_ruby_lex.rb +5 -61
- data/test/test_rdoc_ruby_token.rb +19 -0
- data/test/test_rdoc_rubygems_hook.rb +64 -43
- data/test/test_rdoc_servlet.rb +429 -0
- data/test/test_rdoc_stats.rb +83 -24
- data/test/{test_rdoc_ri_store.rb → test_rdoc_store.rb} +395 -22
- data/test/test_rdoc_task.rb +2 -2
- data/test/test_rdoc_text.rb +37 -11
- data/test/test_rdoc_tom_doc.rb +59 -62
- data/test/test_rdoc_top_level.rb +71 -113
- data/test/xref_test_case.rb +7 -9
- metadata +122 -39
- metadata.gz.sig +0 -0
- data/CVE-2013-0256.rdoc +0 -49
- data/lib/rdoc/markup/attribute.rb +0 -51
@@ -174,7 +174,7 @@ class TestRDocCodeObject < XrefTestCase
|
|
174
174
|
def test_file_name
|
175
175
|
assert_equal nil, @co.file_name
|
176
176
|
|
177
|
-
@co.record_location
|
177
|
+
@co.record_location @store.add_file 'lib/file.rb'
|
178
178
|
|
179
179
|
assert_equal 'lib/file.rb', @co.file_name
|
180
180
|
end
|
@@ -263,6 +263,26 @@ class TestRDocCodeObject < XrefTestCase
|
|
263
263
|
refute @co.ignored?
|
264
264
|
end
|
265
265
|
|
266
|
+
def test_section
|
267
|
+
parent = RDoc::Context.new
|
268
|
+
section = parent.sections.first
|
269
|
+
|
270
|
+
@co.parent = parent
|
271
|
+
@co.instance_variable_set :@section, section
|
272
|
+
|
273
|
+
assert_equal section, @co.section
|
274
|
+
|
275
|
+
@co.instance_variable_set :@section, nil
|
276
|
+
@co.instance_variable_set :@section_title, nil
|
277
|
+
|
278
|
+
assert_equal section, @co.section
|
279
|
+
|
280
|
+
@co.instance_variable_set :@section, nil
|
281
|
+
@co.instance_variable_set :@section_title, 'new title'
|
282
|
+
|
283
|
+
assert_equal 'new title', @co.section.title
|
284
|
+
end
|
285
|
+
|
266
286
|
def test_start_doc
|
267
287
|
@co.document_self = false
|
268
288
|
@co.document_children = false
|
data/test/test_rdoc_comment.rb
CHANGED
data/test/test_rdoc_constant.rb
CHANGED
@@ -8,6 +8,138 @@ class TestRDocConstant < XrefTestCase
|
|
8
8
|
@const = @c1.constants.first
|
9
9
|
end
|
10
10
|
|
11
|
+
def test_full_name
|
12
|
+
assert_equal 'C1::CONST', @const.full_name
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_is_alias_for
|
16
|
+
top_level = @store.add_file 'file.rb'
|
17
|
+
|
18
|
+
c = RDoc::Constant.new 'CONST', nil, 'comment'
|
19
|
+
top_level.add_constant c
|
20
|
+
|
21
|
+
assert_nil c.is_alias_for
|
22
|
+
|
23
|
+
c.is_alias_for = 'C1'
|
24
|
+
|
25
|
+
assert_equal @c1, c.is_alias_for
|
26
|
+
|
27
|
+
c.is_alias_for = 'unknown'
|
28
|
+
|
29
|
+
assert_equal 'unknown', c.is_alias_for
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_marshal_dump
|
33
|
+
top_level = @store.add_file 'file.rb'
|
34
|
+
|
35
|
+
c = RDoc::Constant.new 'CONST', nil, 'this is a comment'
|
36
|
+
c.record_location top_level
|
37
|
+
|
38
|
+
aliased = top_level.add_class RDoc::NormalClass, 'Aliased'
|
39
|
+
c.is_alias_for = aliased
|
40
|
+
|
41
|
+
cm = top_level.add_class RDoc::NormalClass, 'Klass'
|
42
|
+
cm.add_constant c
|
43
|
+
|
44
|
+
section = cm.sections.first
|
45
|
+
|
46
|
+
loaded = Marshal.load Marshal.dump c
|
47
|
+
loaded.store = @store
|
48
|
+
|
49
|
+
comment = doc(para('this is a comment'))
|
50
|
+
|
51
|
+
assert_equal c, loaded
|
52
|
+
|
53
|
+
assert_equal aliased, loaded.is_alias_for
|
54
|
+
assert_equal comment, loaded.comment
|
55
|
+
assert_equal top_level, loaded.file
|
56
|
+
assert_equal 'Klass::CONST', loaded.full_name
|
57
|
+
assert_equal 'CONST', loaded.name
|
58
|
+
assert_nil loaded.visibility
|
59
|
+
assert_equal cm, loaded.parent
|
60
|
+
assert_equal section, loaded.section
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_marshal_load
|
64
|
+
top_level = @store.add_file 'file.rb'
|
65
|
+
|
66
|
+
c = RDoc::Constant.new 'CONST', nil, 'this is a comment'
|
67
|
+
c.record_location top_level
|
68
|
+
|
69
|
+
cm = top_level.add_class RDoc::NormalClass, 'Klass'
|
70
|
+
cm.add_constant c
|
71
|
+
|
72
|
+
section = cm.sections.first
|
73
|
+
|
74
|
+
loaded = Marshal.load Marshal.dump c
|
75
|
+
loaded.store = @store
|
76
|
+
|
77
|
+
comment = doc(para('this is a comment'))
|
78
|
+
|
79
|
+
assert_equal c, loaded
|
80
|
+
|
81
|
+
assert_nil loaded.is_alias_for
|
82
|
+
assert_equal comment, loaded.comment
|
83
|
+
assert_equal top_level, loaded.file
|
84
|
+
assert_equal 'Klass::CONST', loaded.full_name
|
85
|
+
assert_equal 'CONST', loaded.name
|
86
|
+
assert_nil loaded.visibility
|
87
|
+
assert_equal cm, loaded.parent
|
88
|
+
assert_equal section, loaded.section
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_marshal_load_version_0
|
92
|
+
top_level = @store.add_file 'file.rb'
|
93
|
+
|
94
|
+
aliased = top_level.add_class RDoc::NormalClass, 'Aliased'
|
95
|
+
cm = top_level.add_class RDoc::NormalClass, 'Klass'
|
96
|
+
section = cm.sections.first
|
97
|
+
|
98
|
+
loaded = Marshal.load "\x04\bU:\x13RDoc::Constant[\x0Fi\x00I" +
|
99
|
+
"\"\nCONST\x06:\x06ETI\"\x11Klass::CONST\x06" +
|
100
|
+
";\x06T0I\"\fAliased\x06;\x06To" +
|
101
|
+
":\eRDoc::Markup::Document\a:\v@parts[\x06o" +
|
102
|
+
":\x1CRDoc::Markup::Paragraph\x06;\b[\x06I" +
|
103
|
+
"\"\x16this is a comment\x06;\x06T:\n@file0I" +
|
104
|
+
"\"\ffile.rb\x06;\x06TI\"\nKlass\x06" +
|
105
|
+
";\x06Tc\x16RDoc::NormalClass0"
|
106
|
+
|
107
|
+
loaded.store = @store
|
108
|
+
|
109
|
+
comment = doc(para('this is a comment'))
|
110
|
+
|
111
|
+
assert_equal aliased, loaded.is_alias_for
|
112
|
+
assert_equal comment, loaded.comment
|
113
|
+
assert_equal top_level, loaded.file
|
114
|
+
assert_equal 'Klass::CONST', loaded.full_name
|
115
|
+
assert_equal 'CONST', loaded.name
|
116
|
+
assert_nil loaded.visibility
|
117
|
+
assert_equal cm, loaded.parent
|
118
|
+
assert_equal section, loaded.section
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_marshal_round_trip
|
122
|
+
top_level = @store.add_file 'file.rb'
|
123
|
+
|
124
|
+
c = RDoc::Constant.new 'CONST', nil, 'this is a comment'
|
125
|
+
c.record_location top_level
|
126
|
+
c.is_alias_for = 'Unknown'
|
127
|
+
|
128
|
+
cm = top_level.add_class RDoc::NormalClass, 'Klass'
|
129
|
+
cm.add_constant c
|
130
|
+
|
131
|
+
section = cm.sections.first
|
132
|
+
|
133
|
+
loaded = Marshal.load Marshal.dump c
|
134
|
+
loaded.store = @store
|
135
|
+
|
136
|
+
reloaded = Marshal.load Marshal.dump loaded
|
137
|
+
reloaded.store = @store
|
138
|
+
|
139
|
+
assert_equal section, reloaded.section
|
140
|
+
assert_equal 'Unknown', reloaded.is_alias_for
|
141
|
+
end
|
142
|
+
|
11
143
|
def test_path
|
12
144
|
assert_equal 'C1.html#CONST', @const.path
|
13
145
|
end
|
data/test/test_rdoc_context.rb
CHANGED
@@ -6,6 +6,8 @@ class TestRDocContext < XrefTestCase
|
|
6
6
|
super
|
7
7
|
|
8
8
|
@context = RDoc::Context.new
|
9
|
+
@context.store = @store
|
10
|
+
|
9
11
|
@enumerator = # 1.8 vs 1.9
|
10
12
|
Object.const_defined?(:Enumerator) ? Enumerator : Enumerable::Enumerator
|
11
13
|
end
|
@@ -40,7 +42,7 @@ class TestRDocContext < XrefTestCase
|
|
40
42
|
end
|
41
43
|
|
42
44
|
def test_add_alias_method_attr
|
43
|
-
top_level =
|
45
|
+
top_level = @store.add_file 'file.rb'
|
44
46
|
|
45
47
|
attr = RDoc::Attr.new nil, 'old_name', 'R', ''
|
46
48
|
|
@@ -60,7 +62,7 @@ class TestRDocContext < XrefTestCase
|
|
60
62
|
end
|
61
63
|
|
62
64
|
def test_add_alias_method
|
63
|
-
top_level =
|
65
|
+
top_level = @store.add_file 'file.rb'
|
64
66
|
|
65
67
|
meth = RDoc::AnyMethod.new nil, 'old_name'
|
66
68
|
meth.singleton = false
|
@@ -103,7 +105,7 @@ class TestRDocContext < XrefTestCase
|
|
103
105
|
@c1.add_class RDoc::NormalClass, 'Klass', 'Object'
|
104
106
|
|
105
107
|
assert_includes @c1.classes.map { |k| k.full_name }, 'C1::Klass'
|
106
|
-
assert_includes
|
108
|
+
assert_includes @store.all_classes.map { |k| k.full_name }, 'C1::Klass'
|
107
109
|
end
|
108
110
|
|
109
111
|
def test_add_class_basic_object
|
@@ -142,7 +144,7 @@ class TestRDocContext < XrefTestCase
|
|
142
144
|
@c1.add_class RDoc::NormalClass, 'Klass', 'Object'
|
143
145
|
|
144
146
|
assert_includes @c1.classes.map { |k| k.full_name }, 'C1::Klass'
|
145
|
-
assert_includes
|
147
|
+
assert_includes @store.all_classes.map { |k| k.full_name }, 'C1::Klass'
|
146
148
|
end
|
147
149
|
|
148
150
|
def test_add_class_superclass
|
@@ -163,9 +165,9 @@ class TestRDocContext < XrefTestCase
|
|
163
165
|
refute_includes @c1.modules.map { |k| k.full_name }, 'C1::Klass',
|
164
166
|
'c1 modules'
|
165
167
|
|
166
|
-
assert_includes
|
168
|
+
assert_includes @store.all_classes.map { |k| k.full_name }, 'C1::Klass',
|
167
169
|
'TopLevel classes'
|
168
|
-
refute_includes
|
170
|
+
refute_includes @store.all_modules.map { |k| k.full_name }, 'C1::Klass',
|
169
171
|
'TopLevel modules'
|
170
172
|
end
|
171
173
|
|
@@ -176,6 +178,13 @@ class TestRDocContext < XrefTestCase
|
|
176
178
|
assert_equal [const], @context.constants
|
177
179
|
end
|
178
180
|
|
181
|
+
def test_add_extend
|
182
|
+
ext = RDoc::Extend.new 'Name', 'comment'
|
183
|
+
@context.add_extend ext
|
184
|
+
|
185
|
+
assert_equal [ext], @context.extends
|
186
|
+
end
|
187
|
+
|
179
188
|
def test_add_include
|
180
189
|
incl = RDoc::Include.new 'Name', 'comment'
|
181
190
|
@context.add_include incl
|
@@ -207,6 +216,34 @@ class TestRDocContext < XrefTestCase
|
|
207
216
|
assert_equal %w[old_name new_name], @context.method_list.map { |m| m.name }
|
208
217
|
end
|
209
218
|
|
219
|
+
def test_add_method_duplicate
|
220
|
+
@store.rdoc.options.verbosity = 2
|
221
|
+
|
222
|
+
meth1 = RDoc::AnyMethod.new nil, 'name'
|
223
|
+
meth1.record_location @store.add_file 'first.rb'
|
224
|
+
meth1.visibility = nil
|
225
|
+
meth1.comment = comment 'first'
|
226
|
+
|
227
|
+
@context.add_method meth1
|
228
|
+
|
229
|
+
meth2 = RDoc::AnyMethod.new nil, 'name'
|
230
|
+
meth2.record_location @store.add_file 'second.rb'
|
231
|
+
meth2.comment = comment 'second'
|
232
|
+
|
233
|
+
_, err = verbose_capture_io do
|
234
|
+
@context.add_method meth2
|
235
|
+
end
|
236
|
+
|
237
|
+
expected = 'Duplicate method (unknown)#name in file second.rb, ' \
|
238
|
+
'previously in file first.rb'
|
239
|
+
|
240
|
+
assert_equal expected, err.chomp
|
241
|
+
|
242
|
+
method = @context.method_list.first
|
243
|
+
|
244
|
+
assert_equal 'first', method.comment.text
|
245
|
+
end
|
246
|
+
|
210
247
|
def test_add_module
|
211
248
|
@c1.add_module RDoc::NormalModule, 'Mod'
|
212
249
|
|
@@ -214,18 +251,35 @@ class TestRDocContext < XrefTestCase
|
|
214
251
|
end
|
215
252
|
|
216
253
|
def test_add_module_alias
|
217
|
-
tl =
|
254
|
+
tl = @store.add_file 'file.rb'
|
218
255
|
|
219
256
|
c3_c4 = @c2.add_module_alias @c2_c3, 'C4', tl
|
220
257
|
|
221
|
-
c4 = @c2.find_module_named('C4')
|
222
|
-
|
223
258
|
alias_constant = @c2.constants.first
|
224
259
|
|
225
|
-
assert_equal
|
260
|
+
assert_equal 'C2::C4', c3_c4.full_name
|
226
261
|
assert_equal tl, alias_constant.file
|
227
262
|
end
|
228
263
|
|
264
|
+
def test_add_module_alias_top_level
|
265
|
+
store = RDoc::Store.new
|
266
|
+
|
267
|
+
top_level = store.add_file 'file.rb'
|
268
|
+
|
269
|
+
klass = top_level.add_class RDoc::NormalClass, 'Klass'
|
270
|
+
klass.comment = 'klass comment'
|
271
|
+
|
272
|
+
object = top_level.add_class RDoc::NormalClass, 'Object'
|
273
|
+
|
274
|
+
top_level.add_module_alias klass, 'A', top_level
|
275
|
+
|
276
|
+
refute_empty object.constants
|
277
|
+
|
278
|
+
constant = object.constants.first
|
279
|
+
|
280
|
+
assert_equal 'klass comment', constant.comment
|
281
|
+
end
|
282
|
+
|
229
283
|
def test_add_module_class
|
230
284
|
k = @c1.add_class RDoc::NormalClass, 'Klass', nil
|
231
285
|
m = @c1.add_module RDoc::NormalModule, 'Klass'
|
@@ -245,18 +299,20 @@ class TestRDocContext < XrefTestCase
|
|
245
299
|
def test_add_section
|
246
300
|
default_section = @context.sections.first
|
247
301
|
|
248
|
-
@context.add_section nil,
|
302
|
+
@context.add_section nil, comment('comment', @top_level)
|
249
303
|
|
250
304
|
assert_equal 1, @context.sections.length
|
251
|
-
assert_equal
|
305
|
+
assert_equal [comment("comment", @top_level)],
|
306
|
+
@context.sections.first.comments
|
252
307
|
|
253
|
-
@context.add_section nil,
|
308
|
+
@context.add_section nil, comment('new comment', @top_level)
|
254
309
|
|
255
310
|
assert_equal 1, @context.sections.length
|
256
|
-
assert_equal
|
257
|
-
|
311
|
+
assert_equal [comment('comment', @top_level),
|
312
|
+
comment('new comment', @top_level)],
|
313
|
+
@context.sections.first.comments
|
258
314
|
|
259
|
-
@context.add_section 'other',
|
315
|
+
@context.add_section 'other', comment('', @top_level)
|
260
316
|
|
261
317
|
assert_equal 2, @context.sections.length
|
262
318
|
|
@@ -340,7 +396,7 @@ class TestRDocContext < XrefTestCase
|
|
340
396
|
|
341
397
|
def test_classes
|
342
398
|
assert_equal %w[C2::C3], @c2.classes.map { |k| k.full_name }
|
343
|
-
assert_equal %w[C3::H1 C3::H2], @c3.classes.map { |k| k.full_name }
|
399
|
+
assert_equal %w[C3::H1 C3::H2], @c3.classes.map { |k| k.full_name }.sort
|
344
400
|
end
|
345
401
|
|
346
402
|
def test_current_section
|
@@ -357,7 +413,7 @@ class TestRDocContext < XrefTestCase
|
|
357
413
|
def test_defined_in_eh
|
358
414
|
assert @c1.defined_in?(@c1.top_level)
|
359
415
|
|
360
|
-
refute @c1.defined_in?(
|
416
|
+
refute @c1.defined_in?(@store.add_file('name.rb'))
|
361
417
|
end
|
362
418
|
|
363
419
|
def test_equals2
|
@@ -475,6 +531,16 @@ class TestRDocContext < XrefTestCase
|
|
475
531
|
assert_equal @c1__m, @c1.find_symbol('::m')
|
476
532
|
end
|
477
533
|
|
534
|
+
def test_find_symbol_module
|
535
|
+
assert_nil @m1_m2.find_symbol_module 'N'
|
536
|
+
assert_nil @m1_m2.find_symbol_module 'M2::M1'
|
537
|
+
|
538
|
+
@m1_m2.parent = nil # loaded from legacy ri store
|
539
|
+
|
540
|
+
assert_nil @m1_m2.find_symbol_module 'N'
|
541
|
+
assert_nil @m1_m2.find_symbol_module 'M2::M1'
|
542
|
+
end
|
543
|
+
|
478
544
|
def test_fully_documented_eh
|
479
545
|
context = RDoc::Context.new
|
480
546
|
|
@@ -5,32 +5,53 @@ class TestRDocContextSection < RDoc::TestCase
|
|
5
5
|
def setup
|
6
6
|
super
|
7
7
|
|
8
|
+
@top_level = @store.add_file 'file.rb'
|
9
|
+
|
10
|
+
@klass = @top_level.add_class RDoc::NormalClass, 'Object'
|
11
|
+
|
8
12
|
@S = RDoc::Context::Section
|
9
|
-
@s = @S.new
|
13
|
+
@s = @S.new @klass, 'section', comment('# comment', @top_level)
|
10
14
|
end
|
11
15
|
|
12
|
-
def
|
13
|
-
|
16
|
+
def mu_pp obj
|
17
|
+
s = ''
|
18
|
+
s = PP.pp obj, s
|
19
|
+
s.force_encoding Encoding.default_external if defined? Encoding
|
20
|
+
s.chomp
|
21
|
+
end
|
14
22
|
|
15
|
-
|
23
|
+
def test_add_comment
|
24
|
+
file1 = @store.add_file 'file1.rb'
|
16
25
|
|
17
|
-
|
18
|
-
|
26
|
+
klass = file1.add_class RDoc::NormalClass, 'Klass'
|
27
|
+
|
28
|
+
c1 = RDoc::Comment.new "# :section: section\n", file1
|
29
|
+
c2 = RDoc::Comment.new "# hello\n", file1
|
30
|
+
c3 = RDoc::Comment.new "# world\n", file1
|
31
|
+
|
32
|
+
s = @S.new klass, 'section', c1
|
33
|
+
|
34
|
+
assert_empty s.comments
|
19
35
|
|
20
|
-
|
21
|
-
@s.comment = RDoc::Comment.new "# :section: section\n"
|
36
|
+
s.add_comment nil
|
22
37
|
|
23
|
-
|
38
|
+
assert_empty s.comments
|
24
39
|
|
25
|
-
|
40
|
+
s.add_comment c2
|
26
41
|
|
27
|
-
assert_equal
|
42
|
+
assert_equal [c2], s.comments
|
28
43
|
|
29
|
-
s
|
44
|
+
s.add_comment c3
|
30
45
|
|
31
|
-
|
46
|
+
assert_equal [c2, c3], s.comments
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_aref
|
50
|
+
assert_equal 'section', @s.aref
|
51
|
+
|
52
|
+
assert_equal '5Buntitled-5D', @S.new(nil, nil, nil).aref
|
32
53
|
|
33
|
-
assert_equal
|
54
|
+
assert_equal 'one+two', @S.new(nil, 'one two', nil).aref
|
34
55
|
end
|
35
56
|
|
36
57
|
def test_extract_comment
|
@@ -41,8 +62,71 @@ class TestRDocContextSection < RDoc::TestCase
|
|
41
62
|
@s.extract_comment(comment("# a\n# :section: b\n# c")).text
|
42
63
|
end
|
43
64
|
|
65
|
+
def test_marshal_dump
|
66
|
+
loaded = Marshal.load Marshal.dump @s
|
67
|
+
|
68
|
+
expected = RDoc::Comment.new('comment', @top_level).parse
|
69
|
+
expected = doc(expected)
|
70
|
+
|
71
|
+
assert_equal 'section', loaded.title
|
72
|
+
assert_equal expected, loaded.comments
|
73
|
+
assert_nil loaded.parent, 'parent is set manually'
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_marshal_dump_no_comment
|
77
|
+
s = @S.new @klass, 'section', comment('')
|
78
|
+
|
79
|
+
loaded = Marshal.load Marshal.dump s
|
80
|
+
|
81
|
+
assert_equal 'section', loaded.title
|
82
|
+
assert_empty loaded.comments
|
83
|
+
assert_nil loaded.parent, 'parent is set manually'
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_marshal_load_version_0
|
87
|
+
loaded = Marshal.load "\x04\bU:\eRDoc::Context::Section" +
|
88
|
+
"[\bi\x00I\"\fsection\x06:\x06EFo" +
|
89
|
+
":\eRDoc::Markup::Document\a:\v@parts" +
|
90
|
+
"[\x06o;\a\a;\b[\x06o" +
|
91
|
+
":\x1CRDoc::Markup::Paragraph\x06;\b" +
|
92
|
+
"[\x06I\"\fcomment\x06;\x06F:\n@fileI" +
|
93
|
+
"\"\ffile.rb\x06;\x06F;\n0"
|
94
|
+
|
95
|
+
expected = doc RDoc::Comment.new('comment', @top_level).parse
|
96
|
+
|
97
|
+
assert_equal 'section', loaded.title
|
98
|
+
assert_equal expected, loaded.comments
|
99
|
+
assert_nil loaded.parent, 'parent is set manually'
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_remove_comment_array
|
103
|
+
other = @store.add_file 'other.rb'
|
104
|
+
|
105
|
+
other_comment = comment('bogus', other)
|
106
|
+
|
107
|
+
@s.add_comment other_comment
|
108
|
+
|
109
|
+
@s.remove_comment comment('bogus', @top_level)
|
110
|
+
|
111
|
+
assert_equal [other_comment], @s.comments
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_remove_comment_document
|
115
|
+
other = @store.add_file 'other.rb'
|
116
|
+
|
117
|
+
other_comment = comment('bogus', other)
|
118
|
+
|
119
|
+
@s.add_comment other_comment
|
120
|
+
|
121
|
+
loaded = Marshal.load Marshal.dump @s
|
122
|
+
|
123
|
+
loaded.remove_comment comment('bogus', @top_level)
|
124
|
+
|
125
|
+
assert_equal doc(other_comment.parse), loaded.comments
|
126
|
+
end
|
127
|
+
|
44
128
|
def test_sequence
|
45
|
-
_, err =
|
129
|
+
_, err = verbose_capture_io do
|
46
130
|
assert_match(/\ASEC\d{5}\Z/, @s.sequence)
|
47
131
|
end
|
48
132
|
|