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.

Files changed (200) hide show
  1. checksums.yaml +6 -6
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.autotest +3 -2
  5. data/DEVELOPERS.rdoc +53 -0
  6. data/History.rdoc +159 -25
  7. data/LEGAL.rdoc +12 -0
  8. data/Manifest.txt +56 -3
  9. data/README.rdoc +87 -19
  10. data/Rakefile +11 -2
  11. data/TODO.rdoc +20 -13
  12. data/bin/rdoc +4 -0
  13. data/lib/gauntlet_rdoc.rb +1 -1
  14. data/lib/rdoc.rb +32 -71
  15. data/lib/rdoc/any_method.rb +75 -21
  16. data/lib/rdoc/attr.rb +49 -10
  17. data/lib/rdoc/class_module.rb +182 -32
  18. data/lib/rdoc/code_object.rb +54 -12
  19. data/lib/rdoc/comment.rb +8 -1
  20. data/lib/rdoc/constant.rb +100 -6
  21. data/lib/rdoc/context.rb +93 -41
  22. data/lib/rdoc/context/section.rb +143 -28
  23. data/lib/rdoc/cross_reference.rb +58 -50
  24. data/lib/rdoc/encoding.rb +34 -29
  25. data/lib/rdoc/erb_partial.rb +18 -0
  26. data/lib/rdoc/extend.rb +117 -0
  27. data/lib/rdoc/generator.rb +11 -6
  28. data/lib/rdoc/generator/darkfish.rb +250 -62
  29. data/lib/rdoc/generator/json_index.rb +20 -12
  30. data/lib/rdoc/generator/markup.rb +10 -12
  31. data/lib/rdoc/generator/ri.rb +7 -60
  32. data/lib/rdoc/generator/template/darkfish/_head.rhtml +7 -7
  33. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +16 -0
  34. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +1 -1
  35. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +14 -0
  36. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +1 -1
  37. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +13 -0
  38. data/lib/rdoc/generator/template/darkfish/class.rhtml +15 -1
  39. data/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
  40. data/lib/rdoc/generator/template/darkfish/index.rhtml +3 -3
  41. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +7 -9
  42. data/lib/rdoc/generator/template/darkfish/page.rhtml +2 -0
  43. data/lib/rdoc/generator/template/darkfish/rdoc.css +31 -0
  44. data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +18 -0
  45. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +37 -0
  46. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +3 -3
  47. data/lib/rdoc/include.rb +12 -3
  48. data/lib/rdoc/markdown.kpeg +1186 -0
  49. data/lib/rdoc/markdown.rb +16336 -0
  50. data/lib/rdoc/markdown/entities.rb +2128 -0
  51. data/lib/rdoc/markdown/literals_1_8.kpeg +18 -0
  52. data/lib/rdoc/markdown/literals_1_8.rb +454 -0
  53. data/lib/rdoc/markdown/literals_1_9.kpeg +22 -0
  54. data/lib/rdoc/markdown/literals_1_9.rb +417 -0
  55. data/lib/rdoc/markup.rb +69 -10
  56. data/lib/rdoc/markup/attr_changer.rb +2 -5
  57. data/lib/rdoc/markup/attribute_manager.rb +23 -14
  58. data/lib/rdoc/markup/attributes.rb +70 -0
  59. data/lib/rdoc/markup/block_quote.rb +14 -0
  60. data/lib/rdoc/markup/document.rb +20 -4
  61. data/lib/rdoc/markup/formatter.rb +17 -6
  62. data/lib/rdoc/markup/formatter_test_case.rb +93 -24
  63. data/lib/rdoc/markup/hard_break.rb +31 -0
  64. data/lib/rdoc/markup/heading.rb +1 -1
  65. data/lib/rdoc/markup/indented_paragraph.rb +14 -0
  66. data/lib/rdoc/markup/list.rb +23 -4
  67. data/lib/rdoc/markup/list_item.rb +17 -4
  68. data/lib/rdoc/markup/paragraph.rb +14 -0
  69. data/lib/rdoc/markup/parser.rb +107 -60
  70. data/lib/rdoc/markup/raw.rb +4 -4
  71. data/lib/rdoc/markup/special.rb +3 -3
  72. data/lib/rdoc/markup/to_ansi.rb +7 -1
  73. data/lib/rdoc/markup/to_html.rb +42 -14
  74. data/lib/rdoc/markup/to_html_crossref.rb +10 -9
  75. data/lib/rdoc/markup/to_html_snippet.rb +20 -4
  76. data/lib/rdoc/markup/to_joined_paragraph.rb +68 -0
  77. data/lib/rdoc/markup/to_label.rb +20 -1
  78. data/lib/rdoc/markup/to_markdown.rb +134 -0
  79. data/lib/rdoc/markup/to_rdoc.rb +36 -5
  80. data/lib/rdoc/markup/to_table_of_contents.rb +6 -1
  81. data/lib/rdoc/markup/to_tt_only.rb +11 -2
  82. data/lib/rdoc/markup/verbatim.rb +19 -0
  83. data/lib/rdoc/method_attr.rb +33 -19
  84. data/lib/rdoc/normal_class.rb +26 -7
  85. data/lib/rdoc/normal_module.rb +10 -5
  86. data/lib/rdoc/options.rb +95 -21
  87. data/lib/rdoc/parser.rb +6 -2
  88. data/lib/rdoc/parser/c.rb +212 -97
  89. data/lib/rdoc/parser/markdown.rb +23 -0
  90. data/lib/rdoc/parser/ruby.rb +115 -35
  91. data/lib/rdoc/parser/ruby_tools.rb +8 -3
  92. data/lib/rdoc/rd.rb +8 -4
  93. data/lib/rdoc/rd/block_parser.rb +1 -1
  94. data/lib/rdoc/rd/block_parser.ry +1 -1
  95. data/lib/rdoc/rdoc.rb +45 -21
  96. data/lib/rdoc/ri/driver.rb +322 -76
  97. data/lib/rdoc/ri/paths.rb +90 -31
  98. data/lib/rdoc/ri/store.rb +2 -353
  99. data/lib/rdoc/ruby_lex.rb +5 -21
  100. data/lib/rdoc/ruby_token.rb +2 -3
  101. data/lib/rdoc/rubygems_hook.rb +21 -9
  102. data/lib/rdoc/servlet.rb +302 -0
  103. data/lib/rdoc/stats.rb +28 -20
  104. data/lib/rdoc/store.rb +881 -0
  105. data/lib/rdoc/task.rb +2 -1
  106. data/lib/rdoc/test_case.rb +103 -1
  107. data/lib/rdoc/text.rb +5 -4
  108. data/lib/rdoc/tom_doc.rb +17 -16
  109. data/lib/rdoc/top_level.rb +43 -285
  110. data/test/MarkdownTest_1.0.3/Amps and angle encoding.text +21 -0
  111. data/test/MarkdownTest_1.0.3/Auto links.text +13 -0
  112. data/test/MarkdownTest_1.0.3/Backslash escapes.text +120 -0
  113. data/test/MarkdownTest_1.0.3/Blockquotes with code blocks.text +11 -0
  114. data/test/MarkdownTest_1.0.3/Code Blocks.text +14 -0
  115. data/test/MarkdownTest_1.0.3/Code Spans.text +6 -0
  116. data/test/MarkdownTest_1.0.3/Hard-wrapped paragraphs with list-like lines.text +8 -0
  117. data/test/MarkdownTest_1.0.3/Horizontal rules.text +67 -0
  118. data/test/MarkdownTest_1.0.3/Inline HTML (Advanced).text +15 -0
  119. data/test/MarkdownTest_1.0.3/Inline HTML (Simple).text +69 -0
  120. data/test/MarkdownTest_1.0.3/Inline HTML comments.text +13 -0
  121. data/test/MarkdownTest_1.0.3/Links, inline style.text +12 -0
  122. data/test/MarkdownTest_1.0.3/Links, reference style.text +71 -0
  123. data/test/MarkdownTest_1.0.3/Links, shortcut references.text +20 -0
  124. data/test/MarkdownTest_1.0.3/Literal quotes in titles.text +7 -0
  125. data/test/MarkdownTest_1.0.3/Markdown Documentation - Basics.text +306 -0
  126. data/test/MarkdownTest_1.0.3/Markdown Documentation - Syntax.text +888 -0
  127. data/test/MarkdownTest_1.0.3/Nested blockquotes.text +5 -0
  128. data/test/MarkdownTest_1.0.3/Ordered and unordered lists.text +131 -0
  129. data/test/MarkdownTest_1.0.3/Strong and em together.text +7 -0
  130. data/test/MarkdownTest_1.0.3/Tabs.text +21 -0
  131. data/test/MarkdownTest_1.0.3/Tidyness.text +5 -0
  132. data/test/test_attribute_manager.rb +7 -4
  133. data/test/test_rdoc_any_method.rb +84 -13
  134. data/test/test_rdoc_attr.rb +59 -9
  135. data/test/test_rdoc_class_module.rb +670 -73
  136. data/test/test_rdoc_code_object.rb +21 -1
  137. data/test/test_rdoc_comment.rb +1 -1
  138. data/test/test_rdoc_constant.rb +132 -0
  139. data/test/test_rdoc_context.rb +84 -18
  140. data/test/test_rdoc_context_section.rb +99 -15
  141. data/test/test_rdoc_cross_reference.rb +1 -1
  142. data/test/test_rdoc_encoding.rb +17 -1
  143. data/test/test_rdoc_extend.rb +94 -0
  144. data/test/test_rdoc_generator_darkfish.rb +45 -19
  145. data/test/test_rdoc_generator_json_index.rb +27 -7
  146. data/test/test_rdoc_generator_markup.rb +3 -3
  147. data/test/test_rdoc_generator_ri.rb +11 -9
  148. data/test/test_rdoc_include.rb +12 -0
  149. data/test/test_rdoc_markdown.rb +977 -0
  150. data/test/test_rdoc_markdown_test.rb +1891 -0
  151. data/test/test_rdoc_markup.rb +1 -1
  152. data/test/test_rdoc_markup_attribute_manager.rb +2 -2
  153. data/test/test_rdoc_markup_attributes.rb +39 -0
  154. data/test/test_rdoc_markup_document.rb +16 -1
  155. data/test/test_rdoc_markup_formatter.rb +7 -4
  156. data/test/test_rdoc_markup_hard_break.rb +31 -0
  157. data/test/test_rdoc_markup_indented_paragraph.rb +14 -0
  158. data/test/test_rdoc_markup_paragraph.rb +15 -1
  159. data/test/test_rdoc_markup_parser.rb +152 -89
  160. data/test/test_rdoc_markup_to_ansi.rb +23 -2
  161. data/test/test_rdoc_markup_to_bs.rb +24 -0
  162. data/test/test_rdoc_markup_to_html.rb +50 -19
  163. data/test/test_rdoc_markup_to_html_crossref.rb +23 -5
  164. data/test/test_rdoc_markup_to_html_snippet.rb +49 -8
  165. data/test/test_rdoc_markup_to_joined_paragraph.rb +32 -0
  166. data/test/test_rdoc_markup_to_label.rb +63 -1
  167. data/test/test_rdoc_markup_to_markdown.rb +352 -0
  168. data/test/test_rdoc_markup_to_rdoc.rb +22 -2
  169. data/test/test_rdoc_markup_to_table_of_contents.rb +44 -39
  170. data/test/test_rdoc_markup_to_tt_only.rb +20 -0
  171. data/test/test_rdoc_markup_verbatim.rb +13 -0
  172. data/test/test_rdoc_method_attr.rb +5 -0
  173. data/test/test_rdoc_normal_class.rb +24 -5
  174. data/test/test_rdoc_normal_module.rb +1 -1
  175. data/test/test_rdoc_options.rb +21 -6
  176. data/test/test_rdoc_parser.rb +24 -0
  177. data/test/test_rdoc_parser_c.rb +151 -26
  178. data/test/test_rdoc_parser_markdown.rb +55 -0
  179. data/test/test_rdoc_parser_rd.rb +2 -2
  180. data/test/test_rdoc_parser_ruby.rb +468 -109
  181. data/test/test_rdoc_parser_simple.rb +2 -2
  182. data/test/test_rdoc_rd_block_parser.rb +0 -4
  183. data/test/test_rdoc_rdoc.rb +110 -22
  184. data/test/test_rdoc_ri_driver.rb +415 -80
  185. data/test/test_rdoc_ri_paths.rb +122 -13
  186. data/test/test_rdoc_ruby_lex.rb +5 -61
  187. data/test/test_rdoc_ruby_token.rb +19 -0
  188. data/test/test_rdoc_rubygems_hook.rb +64 -43
  189. data/test/test_rdoc_servlet.rb +429 -0
  190. data/test/test_rdoc_stats.rb +83 -24
  191. data/test/{test_rdoc_ri_store.rb → test_rdoc_store.rb} +395 -22
  192. data/test/test_rdoc_task.rb +2 -2
  193. data/test/test_rdoc_text.rb +37 -11
  194. data/test/test_rdoc_tom_doc.rb +59 -62
  195. data/test/test_rdoc_top_level.rb +71 -113
  196. data/test/xref_test_case.rb +7 -9
  197. metadata +122 -39
  198. metadata.gz.sig +0 -0
  199. data/CVE-2013-0256.rdoc +0 -49
  200. data/lib/rdoc/markup/attribute.rb +0 -51
@@ -10,9 +10,9 @@ class TestRDocClassModule < XrefTestCase
10
10
  end
11
11
 
12
12
  def test_add_comment
13
- tl1 = RDoc::TopLevel.new 'one.rb'
14
- tl2 = RDoc::TopLevel.new 'two.rb'
15
- tl3 = RDoc::TopLevel.new 'three.rb'
13
+ tl1 = @store.add_file 'one.rb'
14
+ tl2 = @store.add_file 'two.rb'
15
+ tl3 = @store.add_file 'three.rb'
16
16
 
17
17
  cm = RDoc::ClassModule.new 'Klass'
18
18
  cm.add_comment '# comment 1', tl1
@@ -42,7 +42,7 @@ class TestRDocClassModule < XrefTestCase
42
42
  end
43
43
 
44
44
  def test_add_comment_stopdoc
45
- tl = RDoc::TopLevel.new 'file.rb'
45
+ tl = @store.add_file 'file.rb'
46
46
 
47
47
  cm = RDoc::ClassModule.new 'Klass'
48
48
  cm.stop_doc
@@ -53,7 +53,7 @@ class TestRDocClassModule < XrefTestCase
53
53
  end
54
54
 
55
55
  def test_ancestors
56
- assert_equal [@parent], @child.ancestors
56
+ assert_equal [@parent, "Object"], @child.ancestors
57
57
  end
58
58
 
59
59
  def test_comment_equals
@@ -96,13 +96,16 @@ class TestRDocClassModule < XrefTestCase
96
96
  end
97
97
 
98
98
  def test_each_ancestor
99
- ancestors = []
99
+ assert_equal [@parent], @child.each_ancestor.to_a
100
+ end
100
101
 
101
- @child.each_ancestor do |mod|
102
- ancestors << mod
103
- end
102
+ def test_each_ancestor_cycle
103
+ m_incl = RDoc::Include.new 'M', nil
104
+
105
+ m = @top_level.add_module RDoc::NormalModule, 'M'
106
+ m.add_include m_incl
104
107
 
105
- assert_equal [@parent], ancestors
108
+ assert_empty m.each_ancestor.to_a
106
109
  end
107
110
 
108
111
  # handle making a short module alias of yourself
@@ -114,7 +117,7 @@ class TestRDocClassModule < XrefTestCase
114
117
  end
115
118
 
116
119
  def test_from_module_comment
117
- tl = RDoc::TopLevel.new 'file.rb'
120
+ tl = @store.add_file 'file.rb'
118
121
  klass = tl.add_class RDoc::NormalModule, 'Klass'
119
122
  klass.add_comment 'really a class', tl
120
123
 
@@ -124,7 +127,8 @@ class TestRDocClassModule < XrefTestCase
124
127
  end
125
128
 
126
129
  def test_marshal_dump
127
- tl = RDoc::TopLevel.new 'file.rb'
130
+ @store.path = Dir.tmpdir
131
+ tl = @store.add_file 'file.rb'
128
132
 
129
133
  ns = tl.add_module RDoc::NormalModule, 'Namespace'
130
134
 
@@ -145,14 +149,26 @@ class TestRDocClassModule < XrefTestCase
145
149
  i1 = RDoc::Include.new 'I1', ''
146
150
  i1.record_location tl
147
151
 
152
+ e1 = RDoc::Extend.new 'E1', ''
153
+ e1.record_location tl
154
+
155
+ section_comment = RDoc::Comment.new('section comment')
156
+ section_comment.location = tl
157
+
158
+ assert_equal 1, cm.sections.length, 'sanity, default section only'
159
+ s0 = cm.sections.first
160
+ s1 = cm.add_section 'section', section_comment
161
+
148
162
  cm.add_attribute a1
149
163
  cm.add_attribute a2
150
164
  cm.add_method m1
151
165
  cm.add_constant c1
152
166
  cm.add_include i1
167
+ cm.add_extend e1
153
168
  cm.add_comment 'this is a comment', tl
154
169
 
155
170
  loaded = Marshal.load Marshal.dump cm
171
+ loaded.store = @store
156
172
 
157
173
  assert_equal cm, loaded
158
174
 
@@ -167,9 +183,15 @@ class TestRDocClassModule < XrefTestCase
167
183
  assert_equal [c1], loaded.constants
168
184
  assert_equal 'Namespace::Klass', loaded.full_name
169
185
  assert_equal [i1], loaded.includes
186
+ assert_equal [e1], loaded.extends
170
187
  assert_equal [m1], loaded.method_list
171
188
  assert_equal 'Klass', loaded.name
172
189
  assert_equal 'Super', loaded.superclass
190
+ assert_equal [tl], loaded.in_files
191
+ assert_equal 'Namespace', loaded.parent.name
192
+
193
+ expected = { nil => s0, 'section' => s1 }
194
+ assert_equal expected, loaded.sections_hash
173
195
 
174
196
  assert_equal tl, loaded.attributes.first.file
175
197
 
@@ -177,11 +199,13 @@ class TestRDocClassModule < XrefTestCase
177
199
 
178
200
  assert_equal tl, loaded.includes.first.file
179
201
 
202
+ assert_equal tl, loaded.extends.first.file
203
+
180
204
  assert_equal tl, loaded.method_list.first.file
181
205
  end
182
206
 
183
207
  def test_marshal_load_version_0
184
- tl = RDoc::TopLevel.new 'file.rb'
208
+ tl = @store.add_file 'file.rb'
185
209
  ns = tl.add_module RDoc::NormalModule, 'Namespace'
186
210
  cm = ns.add_class RDoc::NormalClass, 'Klass', 'Super'
187
211
 
@@ -190,25 +214,29 @@ class TestRDocClassModule < XrefTestCase
190
214
  c = RDoc::Constant.new('C1', nil, '')
191
215
  i = RDoc::Include.new('I1', '')
192
216
 
217
+ s0 = cm.sections.first
218
+
193
219
  cm.add_attribute a
194
220
  cm.add_method m
195
221
  cm.add_constant c
196
222
  cm.add_include i
197
223
  cm.add_comment 'this is a comment', tl
198
224
 
199
- loaded = Marshal.load "\x04\bU:\x16RDoc::NormalClass[\x0Ei\x00\"\nKlass" \
200
- "\"\x15Namespace::KlassI\"\nSuper\x06:\x06EF" \
201
- "o:\eRDoc::Markup::Document\x06:\v@parts[\x06" \
202
- "o:\x1CRDoc::Markup::Paragraph\x06;\b[\x06I" \
203
- "\"\x16this is a comment\x06;\x06F[\x06[\aI" \
204
- "\"\aa1\x06;\x06FI\"\aRW\x06;\x06F[\x06[\aI" \
205
- "\"\aC1\x06;\x06Fo;\a\x06;\b[\x00[\x06[\aI" \
206
- "\"\aI1\x06;\x06Fo;\a\x06;\b[\x00[\a[\aI" \
207
- "\"\nclass\x06;\x06F[\b[\a:\vpublic[\x00[\a" \
208
- ":\x0Eprotected[\x00[\a:\fprivate[\x00[\aI" \
209
- "\"\rinstance\x06;\x06F[\b[\a;\n[\x06I" \
225
+ loaded = Marshal.load "\x04\bU:\x16RDoc::NormalClass[\x0Ei\x00\"\nKlass" +
226
+ "\"\x15Namespace::KlassI\"\nSuper\x06:\x06EF" +
227
+ "o:\eRDoc::Markup::Document\x06:\v@parts[\x06" +
228
+ "o:\x1CRDoc::Markup::Paragraph\x06;\b[\x06I" +
229
+ "\"\x16this is a comment\x06;\x06F[\x06[\aI" +
230
+ "\"\aa1\x06;\x06FI\"\aRW\x06;\x06F[\x06[\aI" +
231
+ "\"\aC1\x06;\x06Fo;\a\x06;\b[\x00[\x06[\aI" +
232
+ "\"\aI1\x06;\x06Fo;\a\x06;\b[\x00[\a[\aI" +
233
+ "\"\nclass\x06;\x06F[\b[\a:\vpublic[\x00[\a" +
234
+ ":\x0Eprotected[\x00[\a:\fprivate[\x00[\aI" +
235
+ "\"\rinstance\x06;\x06F[\b[\a;\n[\x06I" +
210
236
  "\"\am1\x06;\x06F[\a;\v[\x00[\a;\f[\x00"
211
237
 
238
+ loaded.store = @store
239
+
212
240
  assert_equal cm, loaded
213
241
 
214
242
  comment = RDoc::Markup::Document.new(
@@ -222,12 +250,300 @@ class TestRDocClassModule < XrefTestCase
222
250
  assert_equal [m], loaded.method_list
223
251
  assert_equal 'Klass', loaded.name
224
252
  assert_equal 'Super', loaded.superclass
225
- assert_equal nil, loaded.file
253
+ assert_nil loaded.file
254
+ assert_empty loaded.in_files
255
+ assert_nil loaded.parent
256
+ assert loaded.current_section
257
+
258
+ expected = { nil => s0 }
259
+ assert_equal expected, loaded.sections_hash
260
+ end
261
+
262
+ def test_marshal_load_version_1
263
+ tl = @store.add_file 'file.rb'
264
+
265
+ ns = tl.add_module RDoc::NormalModule, 'Namespace'
266
+
267
+ cm = ns.add_class RDoc::NormalClass, 'Klass', 'Super'
268
+ cm.record_location tl
269
+
270
+ a1 = RDoc::Attr.new nil, 'a1', 'RW', ''
271
+ a1.record_location tl
272
+ a2 = RDoc::Attr.new nil, 'a2', 'RW', '', true
273
+ a2.record_location tl
274
+
275
+ m1 = RDoc::AnyMethod.new nil, 'm1'
276
+ m1.record_location tl
277
+
278
+ c1 = RDoc::Constant.new 'C1', nil, ''
279
+ c1.record_location tl
280
+
281
+ i1 = RDoc::Include.new 'I1', ''
282
+ i1.record_location tl
283
+
284
+ s0 = cm.sections.first
285
+
286
+ cm.add_attribute a1
287
+ cm.add_attribute a2
288
+ cm.add_method m1
289
+ cm.add_constant c1
290
+ cm.add_include i1
291
+ cm.add_comment 'this is a comment', tl
292
+
293
+ loaded = Marshal.load "\x04\bU:\x16RDoc::NormalClass[\x0Ei\x06I\"\nKlass" +
294
+ "\x06:\x06EFI\"\x15Namespace::Klass\x06;\x06FI" +
295
+ "\"\nSuper\x06;\x06Fo:\eRDoc::Markup::Document\a" +
296
+ ":\v@parts[\x06o;\a\a;\b[\x06o" +
297
+ ":\x1CRDoc::Markup::Paragraph\x06;\b" +
298
+ "[\x06I\"\x16this is a comment\x06;\x06F" +
299
+ ":\n@fileI\"\ffile.rb\x06;\x06F;\n0[\a[\nI" +
300
+ "\"\aa2\x06;\x06FI\"\aRW\x06;\x06F:\vpublicT@\x11" +
301
+ "[\nI\"\aa1\x06;\x06FI\"\aRW\x06;\x06F;\vF@\x11" +
302
+ "[\x06[\bI\"\aC1\x06;\x06Fo;\a\a;\b[\x00;\n0@\x11" +
303
+ "[\x06[\bI\"\aI1\x06;\x06Fo;\a\a;\b[\x00;\n0@\x11" +
304
+ "[\a[\aI\"\nclass\x06;\x06F[\b[\a;\v[\x00" +
305
+ "[\a:\x0Eprotected[\x00[\a:\fprivate[\x00[\aI" +
306
+ "\"\rinstance\x06;\x06F[\b[\a;\v[\x06[\aI" +
307
+ "\"\am1\x06;\x06F@\x11[\a;\f[\x00[\a;\r[\x00"
308
+
309
+ loaded.store = @store
310
+
311
+ assert_equal cm, loaded
312
+
313
+ inner = RDoc::Markup::Document.new(
314
+ RDoc::Markup::Paragraph.new('this is a comment'))
315
+ inner.file = tl
316
+
317
+ comment = RDoc::Markup::Document.new inner
318
+
319
+ assert_equal [a2, a1], loaded.attributes.sort
320
+ assert_equal comment, loaded.comment
321
+ assert_equal [c1], loaded.constants
322
+ assert_equal 'Namespace::Klass', loaded.full_name
323
+ assert_equal [i1], loaded.includes
324
+ assert_empty loaded.extends
325
+ assert_equal [m1], loaded.method_list
326
+ assert_equal 'Klass', loaded.name
327
+ assert_equal 'Super', loaded.superclass
328
+ assert_empty loaded.in_files
329
+ assert_nil loaded.parent
330
+ assert loaded.current_section
331
+
332
+ assert_equal tl, loaded.attributes.first.file
333
+ assert_equal tl, loaded.constants.first.file
334
+ assert_equal tl, loaded.includes.first.file
335
+ assert_equal tl, loaded.method_list.first.file
336
+
337
+ expected = { nil => s0 }
338
+ assert_equal expected, loaded.sections_hash
339
+ end
340
+
341
+ def test_marshal_load_version_2
342
+ tl = @store.add_file 'file.rb'
343
+
344
+ ns = tl.add_module RDoc::NormalModule, 'Namespace'
345
+
346
+ cm = ns.add_class RDoc::NormalClass, 'Klass', 'Super'
347
+ cm.record_location tl
348
+
349
+ a1 = RDoc::Attr.new nil, 'a1', 'RW', ''
350
+ a1.record_location tl
351
+ a2 = RDoc::Attr.new nil, 'a2', 'RW', '', true
352
+ a2.record_location tl
353
+
354
+ m1 = RDoc::AnyMethod.new nil, 'm1'
355
+ m1.record_location tl
356
+
357
+ c1 = RDoc::Constant.new 'C1', nil, ''
358
+ c1.record_location tl
359
+
360
+ i1 = RDoc::Include.new 'I1', ''
361
+ i1.record_location tl
362
+
363
+ e1 = RDoc::Extend.new 'E1', ''
364
+ e1.record_location tl
365
+
366
+ s0 = cm.sections.first
367
+
368
+ cm.add_attribute a1
369
+ cm.add_attribute a2
370
+ cm.add_method m1
371
+ cm.add_constant c1
372
+ cm.add_include i1
373
+ cm.add_extend e1
374
+ cm.add_comment 'this is a comment', tl
375
+
376
+ loaded = Marshal.load "\x04\bU:\x16RDoc::NormalClass[\x0Fi\aI\"\nKlass" +
377
+ "\x06:\x06EFI\"\x15Namespace::Klass\x06;\x06FI" +
378
+ "\"\nSuper\x06;\x06Fo:\eRDoc::Markup::Document\a" +
379
+ ":\v@parts[\x06o;\a\a;\b[\x06o" +
380
+ ":\x1CRDoc::Markup::Paragraph\x06;\b" +
381
+ "[\x06I\"\x16this is a comment\x06;\x06F" +
382
+ ":\n@fileI\"\ffile.rb\x06;\x06F;\n0[\a[\nI" +
383
+ "\"\aa2\x06;\x06FI\"\aRW\x06;\x06F:\vpublicT@\x11" +
384
+ "[\nI\"\aa1\x06;\x06FI\"\aRW\x06;\x06F;\vF@\x11" +
385
+ "[\x06[\bI\"\aC1\x06;\x06Fo;\a\a;\b[\x00;\n0@\x11" +
386
+ "[\x06[\bI\"\aI1\x06;\x06Fo;\a\a;\b[\x00;\n0@\x11" +
387
+ "[\a[\aI\"\nclass\x06;\x06F[\b[\a;\v[\x00" +
388
+ "[\a:\x0Eprotected[\x00[\a:\fprivate[\x00[\aI" +
389
+ "\"\rinstance\x06;\x06F[\b[\a;\v[\x06[\aI" +
390
+ "\"\am1\x06;\x06F@\x11[\a;\f[\x00[\a;\r[\x00" +
391
+ "[\x06[\bI\"\aE1\x06;\x06Fo;\a\a;\b[\x00;\n0@\x11"
392
+
393
+ loaded.store = @store
394
+
395
+ assert_equal cm, loaded
396
+
397
+ inner = RDoc::Markup::Document.new(
398
+ RDoc::Markup::Paragraph.new('this is a comment'))
399
+ inner.file = tl
400
+
401
+ comment = RDoc::Markup::Document.new inner
402
+
403
+ assert_equal [a2, a1], loaded.attributes.sort
404
+ assert_equal comment, loaded.comment
405
+ assert_equal [c1], loaded.constants
406
+ assert_equal 'Namespace::Klass', loaded.full_name
407
+ assert_equal [i1], loaded.includes
408
+ assert_equal [e1], loaded.extends
409
+ assert_equal [m1], loaded.method_list
410
+ assert_equal 'Klass', loaded.name
411
+ assert_equal 'Super', loaded.superclass
412
+ assert_empty loaded.in_files
413
+ assert_nil loaded.parent
414
+ assert loaded.current_section
415
+
416
+ assert_equal tl, loaded.attributes. first.file
417
+ assert_equal tl, loaded.constants. first.file
418
+ assert_equal tl, loaded.includes. first.file
419
+ assert_equal tl, loaded.extends. first.file
420
+ assert_equal tl, loaded.method_list.first.file
421
+
422
+ expected = { nil => s0 }
423
+ assert_equal expected, loaded.sections_hash
424
+ end
425
+
426
+ def test_marshal_load_version_3
427
+ tl = @store.add_file 'file.rb'
428
+
429
+ ns = tl.add_module RDoc::NormalModule, 'Namespace'
430
+
431
+ cm = ns.add_class RDoc::NormalClass, 'Klass', 'Super'
432
+ cm.record_location tl
433
+
434
+ a1 = RDoc::Attr.new nil, 'a1', 'RW', ''
435
+ a1.record_location tl
436
+ a2 = RDoc::Attr.new nil, 'a2', 'RW', '', true
437
+ a2.record_location tl
438
+
439
+ m1 = RDoc::AnyMethod.new nil, 'm1'
440
+ m1.record_location tl
441
+
442
+ c1 = RDoc::Constant.new 'C1', nil, ''
443
+ c1.record_location tl
444
+
445
+ i1 = RDoc::Include.new 'I1', ''
446
+ i1.record_location tl
447
+
448
+ e1 = RDoc::Extend.new 'E1', ''
449
+ e1.record_location tl
450
+
451
+ section_comment = RDoc::Comment.new('section comment')
452
+ section_comment.location = tl
453
+
454
+ assert_equal 1, cm.sections.length, 'sanity, default section only'
455
+ s0 = cm.sections.first
456
+ s1 = cm.add_section 'section', section_comment
457
+
458
+ cm.add_attribute a1
459
+ cm.add_attribute a2
460
+ cm.add_method m1
461
+ cm.add_constant c1
462
+ cm.add_include i1
463
+ cm.add_extend e1
464
+ cm.add_comment 'this is a comment', tl
465
+
466
+ loaded = Marshal.load "\x04\bU:\x16RDoc::NormalClass[\x13i\bI\"\nKlass" +
467
+ "\x06:\x06ETI\"\x15Namespace::Klass\x06;\x06TI" +
468
+ "\"\nSuper\x06;\x06To:\eRDoc::Markup::Document\a" +
469
+ ":\v@parts[\x06o;\a\a;\b[\x06o" +
470
+ ":\x1CRDoc::Markup::Paragraph\x06;\b[\x06I" +
471
+ "\"\x16this is a comment\x06;\x06T:\n@fileI" +
472
+ "\"\ffile.rb\x06;\x06T;\n0[\a[\nI\"\aa2\x06;" +
473
+ "\x06TI\"\aRW\x06;\x06T:\vpublicT@\x11[\nI" +
474
+ "\"\aa1\x06;\x06TI\"\aRW\x06;\x06T;\vF@\x11" +
475
+ "[\x06U:\x13RDoc::Constant[\x0Fi\x00I\"\aC1\x06" +
476
+ ";\x06TI\"\x19Namespace::Klass::C1\x06;\x06T00o" +
477
+ ";\a\a;\b[\x00;\n0@\x11@\ac\x16RDoc::NormalClass0" +
478
+ "[\x06[\bI\"\aI1\x06;\x06To;\a\a;\b[\x00;\n0@\x11" +
479
+ "[\a[\aI\"\nclass\x06;\x06T[\b[\a;\v[\x00[\a" +
480
+ ":\x0Eprotected[\x00[\a:\fprivate[\x00[\aI" +
481
+ "\"\rinstance\x06;\x06T[\b[\a;\v[\x06[\aI" +
482
+ "\"\am1\x06;\x06T@\x11[\a;\r[\x00[\a;\x0E[\x00" +
483
+ "[\x06[\bI\"\aE1\x06;\x06To;\a\a;\b[\x00;\n0@\x11" +
484
+ "[\aU:\eRDoc::Context::Section[\bi\x000o;\a\a;\b" +
485
+ "[\x00;\n0U;\x0F[\bi\x00I\"\fsection\x06;\x06To" +
486
+ ";\a\a;\b[\x06o;\a\a;\b[\x06o;\t\x06;\b[\x06I" +
487
+ "\"\x14section comment\x06;\x06T;\n@\x11;\n0" +
488
+ "[\x06@\x11I\"\x0ENamespace\x06" +
489
+ ";\x06Tc\x17RDoc::NormalModule"
490
+
491
+ loaded.store = @store
492
+
493
+ assert_equal cm, loaded
494
+
495
+ inner = RDoc::Markup::Document.new(
496
+ RDoc::Markup::Paragraph.new('this is a comment'))
497
+ inner.file = tl
498
+
499
+ comment = RDoc::Markup::Document.new inner
500
+
501
+ assert_equal [a2, a1], loaded.attributes.sort
502
+ assert_equal comment, loaded.comment
503
+ assert_equal [c1], loaded.constants
504
+ assert_equal 'Namespace::Klass', loaded.full_name
505
+ assert_equal [i1], loaded.includes
506
+ assert_equal [e1], loaded.extends
507
+ assert_equal [m1], loaded.method_list
508
+ assert_equal 'Klass', loaded.name
509
+ assert_equal 'Super', loaded.superclass
510
+ assert_equal 'Namespace', loaded.parent.name
511
+ assert loaded.current_section
512
+
513
+ expected = {
514
+ nil => s0,
515
+ 'section' => s1,
516
+ }
517
+
518
+ assert_equal expected, loaded.sections_hash
519
+ assert_equal [tl], loaded.in_files
520
+
521
+ assert_equal tl, loaded.attributes. first.file
522
+ assert_equal tl, loaded.constants. first.file
523
+ assert_equal tl, loaded.includes. first.file
524
+ assert_equal tl, loaded.extends. first.file
525
+ assert_equal tl, loaded.method_list.first.file
526
+ end
527
+
528
+ def test_merge
529
+ tl = @store.add_file 'one.rb'
530
+ p1 = tl.add_class RDoc::NormalClass, 'Parent'
531
+ c1 = p1.add_class RDoc::NormalClass, 'Klass'
532
+
533
+ c2 = RDoc::NormalClass.new 'Klass'
534
+
535
+ c2.merge c1
536
+
537
+ assert_equal 'Parent', c1.parent_name, 'original parent name'
538
+ assert_equal 'Parent', c2.parent_name, 'merged parent name'
539
+
540
+ assert c1.current_section, 'original current_section'
541
+ assert c2.current_section, 'merged current_section'
226
542
  end
227
543
 
228
544
  def test_merge_attributes
229
- tl1 = RDoc::TopLevel.new 'one.rb'
230
- tl2 = RDoc::TopLevel.new 'two.rb'
545
+ tl1 = @store.add_file 'one.rb'
546
+ tl2 = @store.add_file 'two.rb'
231
547
 
232
548
  cm1 = RDoc::ClassModule.new 'Klass'
233
549
 
@@ -262,7 +578,7 @@ class TestRDocClassModule < XrefTestCase
262
578
  end
263
579
 
264
580
  def test_merge_attributes_version_0
265
- tl1 = RDoc::TopLevel.new 'one.rb'
581
+ tl1 = @store.add_file 'one.rb'
266
582
 
267
583
  cm1 = RDoc::ClassModule.new 'Klass'
268
584
 
@@ -295,7 +611,7 @@ class TestRDocClassModule < XrefTestCase
295
611
  end
296
612
 
297
613
  def test_merge_collections_drop
298
- tl = RDoc::TopLevel.new 'file'
614
+ tl = @store.add_file 'file'
299
615
 
300
616
  cm1 = RDoc::ClassModule.new 'C'
301
617
  cm1.record_location tl
@@ -322,17 +638,21 @@ class TestRDocClassModule < XrefTestCase
322
638
  end
323
639
 
324
640
  def test_merge_comment
325
- tl1 = RDoc::TopLevel.new 'one.rb'
326
- tl2 = RDoc::TopLevel.new 'two.rb'
641
+ tl1 = @store.add_file 'one.rb'
642
+ tl2 = @store.add_file 'two.rb'
327
643
 
328
- cm1 = RDoc::ClassModule.new 'Klass'
644
+ cm1 = tl1.add_class RDoc::ClassModule, 'Klass'
329
645
  cm1.add_comment 'klass 1', tl1
646
+ cm1.record_location tl1
330
647
 
331
- cm2 = RDoc::ClassModule.new 'Klass'
648
+ cm2 = tl1.add_class RDoc::NormalClass, 'Klass'
332
649
  cm2.add_comment 'klass 2', tl2
333
650
  cm2.add_comment 'klass 3', tl1
651
+ cm2.record_location tl1
652
+ cm2.record_location tl2
334
653
 
335
654
  cm2 = Marshal.load Marshal.dump cm2
655
+ cm2.store = @store
336
656
 
337
657
  cm1.merge cm2
338
658
 
@@ -347,7 +667,7 @@ class TestRDocClassModule < XrefTestCase
347
667
  end
348
668
 
349
669
  def test_merge_comment_version_0
350
- tl = RDoc::TopLevel.new 'file.rb'
670
+ tl = @store.add_file 'file.rb'
351
671
 
352
672
  cm1 = RDoc::ClassModule.new 'Klass'
353
673
  cm1.add_comment 'klass 1', tl
@@ -372,17 +692,19 @@ class TestRDocClassModule < XrefTestCase
372
692
  end
373
693
 
374
694
  def test_merge_constants
375
- tl1 = RDoc::TopLevel.new 'one.rb'
376
- tl2 = RDoc::TopLevel.new 'two.rb'
695
+ tl1 = @store.add_file 'one.rb'
696
+ tl2 = @store.add_file 'two.rb'
377
697
 
378
- cm1 = RDoc::ClassModule.new 'Klass'
698
+ cm1 = tl1.add_class RDoc::ClassModule, 'Klass'
379
699
 
380
700
  const = cm1.add_constant RDoc::Constant.new('C1', nil, 'one')
381
701
  const.record_location tl1
382
702
  const = cm1.add_constant RDoc::Constant.new('C3', nil, 'one')
383
703
  const.record_location tl1
384
704
 
385
- cm2 = RDoc::ClassModule.new 'Klass'
705
+ store = RDoc::Store.new
706
+ tl = store.add_file 'one.rb'
707
+ cm2 = tl.add_class RDoc::ClassModule, 'Klass'
386
708
  cm2.instance_variable_set :@comment, @RM::Document.new
387
709
 
388
710
  const = cm2.add_constant RDoc::Constant.new('C2', nil, 'two')
@@ -406,16 +728,18 @@ class TestRDocClassModule < XrefTestCase
406
728
  end
407
729
 
408
730
  def test_merge_constants_version_0
409
- tl1 = RDoc::TopLevel.new 'one.rb'
731
+ tl1 = @store.add_file 'one.rb'
410
732
 
411
- cm1 = RDoc::ClassModule.new 'Klass'
733
+ cm1 = tl1.add_class RDoc::ClassModule, 'Klass'
412
734
 
413
735
  const = cm1.add_constant RDoc::Constant.new('C1', nil, 'one')
414
736
  const.record_location tl1
415
737
  const = cm1.add_constant RDoc::Constant.new('C3', nil, 'one')
416
738
  const.record_location tl1
417
739
 
418
- cm2 = RDoc::ClassModule.new 'Klass'
740
+ store = RDoc::Store.new
741
+ tl = store.add_file 'one.rb'
742
+ cm2 = tl.add_class RDoc::ClassModule, 'Klass'
419
743
  cm2.instance_variable_set :@comment, @RM::Document.new
420
744
 
421
745
  const = cm2.add_constant RDoc::Constant.new('C2', nil, 'two')
@@ -436,18 +760,55 @@ class TestRDocClassModule < XrefTestCase
436
760
  assert_equal expected, cm1.constants.sort
437
761
  end
438
762
 
763
+ def test_merge_extends
764
+ tl1 = @store.add_file 'one.rb'
765
+ cm1 = tl1.add_class RDoc::ClassModule, 'Klass'
766
+
767
+ ext = cm1.add_extend RDoc::Extend.new('I1', 'one')
768
+ ext.record_location tl1
769
+ ext = cm1.add_extend RDoc::Extend.new('I3', 'one')
770
+ ext.record_location tl1
771
+
772
+ tl2 = @store.add_file 'two.rb'
773
+ tl2.store = RDoc::Store.new
774
+
775
+ cm2 = tl2.add_class RDoc::ClassModule, 'Klass'
776
+ cm2.instance_variable_set :@comment, @RM::Document.new
777
+
778
+ ext = cm2.add_extend RDoc::Extend.new('I2', 'two')
779
+ ext.record_location tl2
780
+ ext = cm2.add_extend RDoc::Extend.new('I3', 'one')
781
+ ext.record_location tl1
782
+ ext = cm2.add_extend RDoc::Extend.new('I4', 'one')
783
+ ext.record_location tl1
784
+
785
+ cm1.merge cm2
786
+
787
+ expected = [
788
+ RDoc::Extend.new('I2', 'two'),
789
+ RDoc::Extend.new('I3', 'one'),
790
+ RDoc::Extend.new('I4', 'one'),
791
+ ]
792
+
793
+ expected.each do |a| a.parent = cm1 end
794
+
795
+ assert_equal expected, cm1.extends.sort
796
+ end
797
+
439
798
  def test_merge_includes
440
- tl1 = RDoc::TopLevel.new 'one.rb'
441
- tl2 = RDoc::TopLevel.new 'two.rb'
799
+ tl1 = @store.add_file 'one.rb'
442
800
 
443
- cm1 = RDoc::ClassModule.new 'Klass'
801
+ cm1 = tl1.add_class RDoc::ClassModule, 'Klass'
444
802
 
445
803
  incl = cm1.add_include RDoc::Include.new('I1', 'one')
446
804
  incl.record_location tl1
447
805
  incl = cm1.add_include RDoc::Include.new('I3', 'one')
448
806
  incl.record_location tl1
449
807
 
450
- cm2 = RDoc::ClassModule.new 'Klass'
808
+ tl2 = @store.add_file 'two.rb'
809
+ tl2.store = RDoc::Store.new
810
+
811
+ cm2 = tl2.add_class RDoc::ClassModule, 'Klass'
451
812
  cm2.instance_variable_set :@comment, @RM::Document.new
452
813
 
453
814
  incl = cm2.add_include RDoc::Include.new('I2', 'two')
@@ -471,16 +832,19 @@ class TestRDocClassModule < XrefTestCase
471
832
  end
472
833
 
473
834
  def test_merge_includes_version_0
474
- tl1 = RDoc::TopLevel.new 'one.rb'
835
+ tl1 = @store.add_file 'one.rb'
475
836
 
476
- cm1 = RDoc::ClassModule.new 'Klass'
837
+ cm1 = tl1.add_class RDoc::ClassModule, 'Klass'
477
838
 
478
839
  incl = cm1.add_include RDoc::Include.new('I1', 'one')
479
840
  incl.record_location tl1
480
841
  incl = cm1.add_include RDoc::Include.new('I3', 'one')
481
842
  incl.record_location tl1
482
843
 
483
- cm2 = RDoc::ClassModule.new 'Klass'
844
+ tl2 = @store.add_file 'one.rb'
845
+ tl2.store = RDoc::Store.new
846
+
847
+ cm2 = tl2.add_class RDoc::ClassModule, 'Klass'
484
848
  cm2.instance_variable_set :@comment, @RM::Document.new
485
849
 
486
850
  incl = cm2.add_include RDoc::Include.new('I2', 'two')
@@ -502,10 +866,10 @@ class TestRDocClassModule < XrefTestCase
502
866
  end
503
867
 
504
868
  def test_merge_methods
505
- tl1 = RDoc::TopLevel.new 'one.rb'
506
- tl2 = RDoc::TopLevel.new 'two.rb'
869
+ tl1 = @store.add_file 'one.rb'
870
+ tl2 = @store.add_file 'two.rb'
507
871
 
508
- cm1 = RDoc::ClassModule.new 'Klass'
872
+ cm1 = tl1.add_class RDoc::NormalClass, 'Klass'
509
873
 
510
874
  meth = cm1.add_method RDoc::AnyMethod.new(nil, 'm1')
511
875
  meth.record_location tl1
@@ -513,6 +877,7 @@ class TestRDocClassModule < XrefTestCase
513
877
  meth.record_location tl1
514
878
 
515
879
  cm2 = RDoc::ClassModule.new 'Klass'
880
+ cm2.store = @store
516
881
  cm2.instance_variable_set :@comment, @RM::Document.new
517
882
 
518
883
  meth = cm2.add_method RDoc::AnyMethod.new(nil, 'm2')
@@ -536,9 +901,9 @@ class TestRDocClassModule < XrefTestCase
536
901
  end
537
902
 
538
903
  def test_merge_methods_version_0
539
- tl1 = RDoc::TopLevel.new 'one.rb'
904
+ tl1 = @store.add_file 'one.rb'
540
905
 
541
- cm1 = RDoc::ClassModule.new 'Klass'
906
+ cm1 = tl1.add_class RDoc::NormalClass, 'Klass'
542
907
 
543
908
  meth = cm1.add_method RDoc::AnyMethod.new(nil, 'm1')
544
909
  meth.record_location tl1
@@ -546,6 +911,7 @@ class TestRDocClassModule < XrefTestCase
546
911
  meth.record_location tl1
547
912
 
548
913
  cm2 = RDoc::ClassModule.new 'Klass'
914
+ cm2.store = @store
549
915
  cm2.instance_variable_set :@comment, @RM::Document.new
550
916
 
551
917
  meth = cm2.add_method RDoc::AnyMethod.new(nil, 'm2')
@@ -566,9 +932,111 @@ class TestRDocClassModule < XrefTestCase
566
932
  assert_equal expected, cm1.method_list.sort
567
933
  end
568
934
 
935
+ def test_merge_sections
936
+ store1 = @store
937
+
938
+ tl1_1 = store1.add_file 'one.rb'
939
+
940
+ cm1 = tl1_1.add_class RDoc::ClassModule, 'Klass'
941
+ cm1.record_location tl1_1
942
+
943
+ s1_0 = cm1.sections.first
944
+ s1_1 = cm1.add_section 'section 1', comment('comment 1', tl1_1)
945
+ cm1.add_section 'section 2', comment('comment 2 a', tl1_1)
946
+ cm1.add_section 'section 4', comment('comment 4 a', tl1_1)
947
+
948
+ store2 = RDoc::Store.new
949
+ tl2_1 = store2.add_file 'one.rb'
950
+ tl2_2 = store2.add_file 'two.rb'
951
+
952
+ cm2 = tl2_1.add_class RDoc::ClassModule, 'Klass'
953
+ cm2.record_location tl2_1
954
+ cm2.record_location tl2_2
955
+
956
+ cm2.sections.first
957
+ s2_2 = cm2.add_section 'section 2', comment('comment 2 b', tl2_1)
958
+ s2_3 = cm2.add_section 'section 3', comment('comment 3', tl2_2)
959
+ cm2.add_section 'section 4', comment('comment 4 b', tl2_2)
960
+
961
+ cm1.merge cm2
962
+
963
+ expected = [
964
+ s1_0,
965
+ s1_1,
966
+ s2_2,
967
+ s2_3,
968
+ RDoc::Context::Section.new(cm1, 'section 4', nil)
969
+ ]
970
+
971
+ merged_sections = cm1.sections.sort_by do |s|
972
+ s.title || ''
973
+ end
974
+
975
+ assert_equal expected, merged_sections
976
+
977
+ assert_equal [comment('comment 2 b', tl2_1)],
978
+ cm1.sections_hash['section 2'].comments
979
+
980
+ expected_s4_comments = [
981
+ comment('comment 4 a', tl2_1),
982
+ comment('comment 4 b', tl2_2),
983
+ ]
984
+
985
+ assert_equal expected_s4_comments, cm1.sections_hash['section 4'].comments
986
+ end
987
+
988
+ def test_merge_sections_overlap
989
+ store1 = @store
990
+
991
+ tl1_1 = store1.add_file 'one.rb'
992
+ tl1_3 = store1.add_file 'three.rb'
993
+
994
+ cm1 = tl1_1.add_class RDoc::ClassModule, 'Klass'
995
+ cm1.record_location tl1_1
996
+
997
+ cm1.add_section 'section', comment('comment 1 a', tl1_1)
998
+ cm1.add_section 'section', comment('comment 3', tl1_3)
999
+
1000
+ store2 = RDoc::Store.new
1001
+ tl2_1 = store2.add_file 'one.rb'
1002
+ tl2_2 = store2.add_file 'two.rb'
1003
+ tl2_3 = store2.add_file 'three.rb'
1004
+
1005
+ cm2 = tl2_1.add_class RDoc::ClassModule, 'Klass'
1006
+ cm2.record_location tl2_1
1007
+ cm2.record_location tl2_2
1008
+
1009
+ s2_0 = cm2.sections.first
1010
+ s2_1 = cm2.add_section 'section', comment('comment 1 b', tl1_1)
1011
+ cm2.add_section 'section', comment('comment 2', tl2_2)
1012
+
1013
+ cm1.merge_sections cm2
1014
+
1015
+ expected = [
1016
+ s2_0,
1017
+ s2_1,
1018
+ ]
1019
+
1020
+ merged_sections = cm1.sections.sort_by do |s|
1021
+ s.title || ''
1022
+ end
1023
+
1024
+ assert_equal expected, merged_sections
1025
+
1026
+ expected = [
1027
+ comment('comment 1 b', tl2_1),
1028
+ comment('comment 3', tl2_3),
1029
+ comment('comment 2', tl2_2),
1030
+ ]
1031
+
1032
+ comments = cm1.sections_hash['section'].comments
1033
+
1034
+ assert_equal expected, comments.sort_by { |c| c.file.name }
1035
+ end
1036
+
569
1037
  def test_parse
570
- tl1 = RDoc::TopLevel.new 'one.rb'
571
- tl2 = RDoc::TopLevel.new 'two.rb'
1038
+ tl1 = @store.add_file 'one.rb'
1039
+ tl2 = @store.add_file 'two.rb'
572
1040
 
573
1041
  cm = RDoc::ClassModule.new 'Klass'
574
1042
  cm.add_comment 'comment 1', tl1
@@ -585,7 +1053,7 @@ class TestRDocClassModule < XrefTestCase
585
1053
  end
586
1054
 
587
1055
  def test_parse_comment
588
- tl1 = RDoc::TopLevel.new 'one.rb'
1056
+ tl1 = @store.add_file 'one.rb'
589
1057
 
590
1058
  cm = RDoc::ClassModule.new 'Klass'
591
1059
  cm.comment = comment 'comment 1', tl1
@@ -597,7 +1065,7 @@ class TestRDocClassModule < XrefTestCase
597
1065
  end
598
1066
 
599
1067
  def test_parse_comment_format
600
- tl1 = RDoc::TopLevel.new 'one.rb'
1068
+ tl1 = @store.add_file 'one.rb'
601
1069
 
602
1070
  cm = RDoc::ClassModule.new 'Klass'
603
1071
  cm.comment = comment 'comment ((*1*))', tl1
@@ -610,10 +1078,10 @@ class TestRDocClassModule < XrefTestCase
610
1078
  end
611
1079
 
612
1080
  def test_parse_comment_location
613
- tl1 = RDoc::TopLevel.new 'one.rb'
614
- tl2 = RDoc::TopLevel.new 'two.rb'
1081
+ tl1 = @store.add_file 'one.rb'
1082
+ tl2 = @store.add_file 'two.rb'
615
1083
 
616
- cm = RDoc::ClassModule.new 'Klass'
1084
+ cm = tl1.add_class RDoc::NormalClass, 'Klass'
617
1085
  cm.add_comment 'comment 1', tl1
618
1086
  cm.add_comment 'comment 2', tl2
619
1087
 
@@ -628,12 +1096,12 @@ class TestRDocClassModule < XrefTestCase
628
1096
  end
629
1097
 
630
1098
  def test_remove_nodoc_children
631
- parent = RDoc::ClassModule.new 'A'
1099
+ parent = @top_level.add_class RDoc::ClassModule, 'A'
632
1100
  parent.modules_hash.replace 'B' => true, 'C' => true
633
- RDoc::TopLevel.all_modules_hash.replace 'A::B' => true
1101
+ @store.modules_hash.replace 'A::B' => true
634
1102
 
635
1103
  parent.classes_hash.replace 'D' => true, 'E' => true
636
- RDoc::TopLevel.all_classes_hash.replace 'A::D' => true
1104
+ @store.classes_hash.replace 'A::D' => true
637
1105
 
638
1106
  parent.remove_nodoc_children
639
1107
 
@@ -658,8 +1126,8 @@ class TestRDocClassModule < XrefTestCase
658
1126
  end
659
1127
 
660
1128
  def test_search_record_merged
661
- @c2_c3.add_comment 'comment A', RDoc::TopLevel.new('a.rb')
662
- @c2_c3.add_comment 'comment B', RDoc::TopLevel.new('b.rb')
1129
+ @c2_c3.add_comment 'comment A', @store.add_file('a.rb')
1130
+ @c2_c3.add_comment 'comment B', @store.add_file('b.rb')
663
1131
 
664
1132
  expected = [
665
1133
  'C3',
@@ -674,6 +1142,50 @@ class TestRDocClassModule < XrefTestCase
674
1142
  assert_equal expected, @c2_c3.search_record
675
1143
  end
676
1144
 
1145
+ def test_store_equals
1146
+ # version 2
1147
+ loaded = Marshal.load "\x04\bU:\x16RDoc::NormalClass[\x0Fi\aI\"\nKlass" +
1148
+ "\x06:\x06EFI\"\x15Namespace::Klass\x06;\x06FI" +
1149
+ "\"\nSuper\x06;\x06Fo:\eRDoc::Markup::Document\a" +
1150
+ ":\v@parts[\x06o;\a\a;\b[\x06o" +
1151
+ ":\x1CRDoc::Markup::Paragraph\x06;\b" +
1152
+ "[\x06I\"\x16this is a comment\x06;\x06F" +
1153
+ ":\n@fileI\"\ffile.rb\x06;\x06F;\n0[\a[\nI" +
1154
+ "\"\aa2\x06;\x06FI\"\aRW\x06;\x06F:\vpublicT@\x11" +
1155
+ "[\nI\"\aa1\x06;\x06FI\"\aRW\x06;\x06F;\vF@\x11" +
1156
+ "[\x06[\bI\"\aC1\x06;\x06Fo;\a\a;\b[\x00;\n0@\x11" +
1157
+ "[\x06[\bI\"\aI1\x06;\x06Fo;\a\a;\b[\x00;\n0@\x11" +
1158
+ "[\a[\aI\"\nclass\x06;\x06F[\b[\a;\v[\x00" +
1159
+ "[\a:\x0Eprotected[\x00[\a:\fprivate[\x00[\aI" +
1160
+ "\"\rinstance\x06;\x06F[\b[\a;\v[\x06[\aI" +
1161
+ "\"\am1\x06;\x06F@\x11[\a;\f[\x00[\a;\r[\x00" +
1162
+ "[\x06[\bI\"\aE1\x06;\x06Fo;\a\a;\b[\x00;\n0@\x11"
1163
+
1164
+ loaded.store = @store
1165
+
1166
+ assert_same @store, loaded.store
1167
+
1168
+ a = loaded.attributes.first
1169
+ assert_same @store, a.store
1170
+ assert_same @store, a.file.store
1171
+
1172
+ c = loaded.constants.first
1173
+ assert_same @store, c.store
1174
+ assert_same @store, c.file.store
1175
+
1176
+ i = loaded.includes.first
1177
+ assert_same @store, i.store
1178
+ assert_same @store, i.file.store
1179
+
1180
+ e = loaded.extends.first
1181
+ assert_same @store, e.store
1182
+ assert_same @store, e.file.store
1183
+
1184
+ m = loaded.method_list.first
1185
+ assert_same @store, m.store
1186
+ assert_same @store, m.file.store
1187
+ end
1188
+
677
1189
  def test_superclass
678
1190
  assert_equal @c3_h1, @c3_h2.superclass
679
1191
  end
@@ -751,6 +1263,30 @@ class TestRDocClassModule < XrefTestCase
751
1263
  assert_equal 'O1::A1', o1_a1_m.full_name
752
1264
  end
753
1265
 
1266
+ def test_update_aliases_reparent_root
1267
+ store = RDoc::Store.new
1268
+
1269
+ top_level = store.add_file 'file.rb'
1270
+
1271
+ klass = top_level.add_class RDoc::NormalClass, 'Klass'
1272
+ object = top_level.add_class RDoc::NormalClass, 'Object'
1273
+
1274
+ const = RDoc::Constant.new 'A', nil, ''
1275
+ const.record_location top_level
1276
+ const.is_alias_for = klass
1277
+
1278
+ top_level.add_module_alias klass, 'A', top_level
1279
+
1280
+ object.add_constant const
1281
+
1282
+ object.update_aliases
1283
+
1284
+ assert_equal %w[A Klass Object], store.classes_hash.keys.sort
1285
+
1286
+ assert_equal 'A', store.classes_hash['A'].full_name
1287
+ assert_equal 'Klass', store.classes_hash['Klass'].full_name
1288
+ end
1289
+
754
1290
  def test_update_includes
755
1291
  a = RDoc::Include.new 'M1', nil
756
1292
  b = RDoc::Include.new 'M2', nil
@@ -764,10 +1300,11 @@ class TestRDocClassModule < XrefTestCase
764
1300
  @m1_m2.document_self = nil
765
1301
  assert @m1_m2.remove_from_documentation?
766
1302
 
767
- assert RDoc::TopLevel.all_modules_hash.key? @m1_m2.full_name
768
- refute RDoc::TopLevel.all_modules_hash[@m1_m2.full_name].nil?
769
- RDoc::TopLevel.remove_nodoc RDoc::TopLevel.all_modules_hash
770
- refute RDoc::TopLevel.all_modules_hash.key? @m1_m2.full_name
1303
+ assert @store.modules_hash.key? @m1_m2.full_name
1304
+ refute @store.modules_hash[@m1_m2.full_name].nil?
1305
+
1306
+ @store.remove_nodoc @store.modules_hash
1307
+ refute @store.modules_hash.key? @m1_m2.full_name
771
1308
 
772
1309
  @c1.update_includes
773
1310
 
@@ -800,15 +1337,75 @@ class TestRDocClassModule < XrefTestCase
800
1337
  @m1_m2.document_self = nil
801
1338
  assert @m1_m2.remove_from_documentation?
802
1339
 
803
- assert RDoc::TopLevel.all_modules_hash.key? @m1_m2.full_name
804
- refute RDoc::TopLevel.all_modules_hash[@m1_m2.full_name].nil?
805
- RDoc::TopLevel.remove_nodoc RDoc::TopLevel.all_modules_hash
806
- refute RDoc::TopLevel.all_modules_hash.key? @m1_m2.full_name
1340
+ assert @store.modules_hash.key? @m1_m2.full_name
1341
+ refute @store.modules_hash[@m1_m2.full_name].nil?
1342
+ @store.remove_nodoc @store.modules_hash
1343
+ refute @store.modules_hash.key? @m1_m2.full_name
807
1344
 
808
1345
  @c1.update_includes
809
1346
 
810
1347
  assert_equal [a, c], @c1.includes
811
1348
  end
812
1349
 
1350
+ def test_update_extends
1351
+ a = RDoc::Extend.new 'M1', nil
1352
+ b = RDoc::Extend.new 'M2', nil
1353
+ c = RDoc::Extend.new 'C', nil
1354
+
1355
+ @c1.add_extend a
1356
+ @c1.add_extend b
1357
+ @c1.add_extend c
1358
+ @c1.each_extend do |extend| extend.module end # cache extended modules
1359
+
1360
+ @m1_m2.document_self = nil
1361
+ assert @m1_m2.remove_from_documentation?
1362
+
1363
+ assert @store.modules_hash.key? @m1_m2.full_name
1364
+ refute @store.modules_hash[@m1_m2.full_name].nil?
1365
+ @store.remove_nodoc @store.modules_hash
1366
+ refute @store.modules_hash.key? @m1_m2.full_name
1367
+
1368
+ @c1.update_extends
1369
+
1370
+ assert_equal [a, c], @c1.extends
1371
+ end
1372
+
1373
+ def test_update_extends_trim
1374
+ a = RDoc::Extend.new 'D::M', nil
1375
+ b = RDoc::Extend.new 'D::M', nil
1376
+
1377
+ @c1.add_extend a
1378
+ @c1.add_extend b
1379
+ @c1.each_extend do |extend| extend.module end # cache extended modules
1380
+
1381
+ @c1.update_extends
1382
+
1383
+ assert_equal [a], @c1.extends
1384
+ end
1385
+
1386
+ def test_update_extends_with_colons
1387
+ a = RDoc::Extend.new 'M1', nil
1388
+ b = RDoc::Extend.new 'M1::M2', nil
1389
+ c = RDoc::Extend.new 'C', nil
1390
+
1391
+ @c1.add_extend a
1392
+ @c1.add_extend b
1393
+ @c1.add_extend c
1394
+ @c1.each_extend do |extend| extend.module end # cache extended modules
1395
+
1396
+ @m1_m2.document_self = nil
1397
+ assert @m1_m2.remove_from_documentation?
1398
+
1399
+ assert @store.modules_hash.key? @m1_m2.full_name
1400
+ refute @store.modules_hash[@m1_m2.full_name].nil?
1401
+
1402
+ @store.remove_nodoc @store.modules_hash
1403
+ refute @store.modules_hash.key? @m1_m2.full_name
1404
+
1405
+ @c1.update_extends
1406
+
1407
+ assert_equal [a, c], @c1.extends
1408
+ end
1409
+
813
1410
  end
814
1411