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
@@ -16,13 +16,13 @@ class TestRDocTask < RDoc::TestCase
16
16
  end
17
17
 
18
18
  def test_inline_source
19
- _, err = capture_io do
19
+ _, err = verbose_capture_io do
20
20
  assert @t.inline_source
21
21
  end
22
22
 
23
23
  assert_equal "RDoc::Task#inline_source is deprecated\n", err
24
24
 
25
- _, err = capture_io do
25
+ _, err = verbose_capture_io do
26
26
  @t.inline_source = false
27
27
  end
28
28
 
@@ -9,7 +9,16 @@ class TestRDocText < RDoc::TestCase
9
9
  def setup
10
10
  super
11
11
 
12
- @top_level = RDoc::TopLevel.new 'file.rb'
12
+ @options = RDoc::Options.new
13
+
14
+ @top_level = @store.add_file 'file.rb'
15
+ end
16
+
17
+ def mu_pp obj
18
+ s = ''
19
+ s = PP.pp obj, s
20
+ s = s.force_encoding Encoding.default_external if defined? Encoding
21
+ s.chomp
13
22
  end
14
23
 
15
24
  def test_self_encode_fallback
@@ -144,7 +153,7 @@ The comments associated with
144
153
  text = <<-TEXT
145
154
  /*
146
155
  * we don't worry too much.
147
- *
156
+ *
148
157
  * The comments associated with
149
158
  */
150
159
  TEXT
@@ -162,7 +171,7 @@ The comments associated with
162
171
  text = <<-TEXT
163
172
  /*
164
173
  * we don't worry too much.
165
- *
174
+ *
166
175
  * The comments associated with
167
176
  */
168
177
  TEXT
@@ -203,6 +212,16 @@ The comments associated with
203
212
  assert_equal RDoc::Markup::Document.new, parse("#\n")
204
213
  end
205
214
 
215
+ def test_parse_format_markdown
216
+ expected =
217
+ @RM::Document.new(
218
+ @RM::Paragraph.new('it _works_'))
219
+
220
+ parsed = parse 'it *works*', 'markdown'
221
+
222
+ assert_equal expected, parsed
223
+ end
224
+
206
225
  def test_parse_format_rd
207
226
  expected =
208
227
  @RM::Document.new(
@@ -214,13 +233,16 @@ The comments associated with
214
233
  end
215
234
 
216
235
  def test_parse_format_tomdoc
236
+ code = verb('1 + 1')
237
+ code.format = :ruby
238
+
217
239
  expected =
218
- @RM::Document.new(
219
- @RM::Paragraph.new('It does a thing'),
220
- @RM::BlankLine.new,
221
- @RM::Heading.new(3, 'Examples'),
222
- @RM::BlankLine.new,
223
- @RM::Verbatim.new("1 + 1"))
240
+ doc(
241
+ para('It does a thing'),
242
+ blank_line,
243
+ head(3, 'Examples'),
244
+ blank_line,
245
+ code)
224
246
 
225
247
  text = <<-TOMDOC
226
248
  It does a thing
@@ -461,6 +483,10 @@ The comments associated with
461
483
  assert_equal 'S', to_html('\\S')
462
484
  end
463
485
 
486
+ def test_to_html_br
487
+ assert_equal '<br>', to_html('<br>')
488
+ end
489
+
464
490
  def test_to_html_copyright
465
491
  assert_equal '©', to_html('(c)')
466
492
  end
@@ -527,7 +553,7 @@ The comments associated with
527
553
  end
528
554
 
529
555
  def test_to_html_tt_tag_mismatch
530
- _, err = capture_io do
556
+ _, err = verbose_capture_io do
531
557
  assert_equal '<tt>hi', to_html('<tt>hi')
532
558
  end
533
559
 
@@ -535,7 +561,7 @@ The comments associated with
535
561
  end
536
562
 
537
563
  def formatter()
538
- RDoc::Markup::ToHtml.new
564
+ RDoc::Markup::ToHtml.new @options
539
565
  end
540
566
 
541
567
  end
@@ -5,7 +5,7 @@ class TestRDocTomDoc < RDoc::TestCase
5
5
  def setup
6
6
  super
7
7
 
8
- @top_level = RDoc::TopLevel.new 'file.rb'
8
+ @top_level = @store.add_file 'file.rb'
9
9
 
10
10
  @TD = RDoc::TomDoc
11
11
  @td = @TD.new
@@ -67,11 +67,11 @@ here - something
67
67
  assert_equal "method_<here>(args)\n", signature
68
68
 
69
69
  expected =
70
- @RM::Document.new(
71
- @RM::Heading.new(3, 'Signature'),
72
- @RM::List.new(:NOTE,
73
- @RM::ListItem.new('here',
74
- @RM::Paragraph.new('something'))))
70
+ doc(
71
+ head(3, 'Signature'),
72
+ list(:NOTE,
73
+ item(%w[here],
74
+ para('something'))))
75
75
  expected.file = @top_level
76
76
 
77
77
  assert_equal expected, c.parse
@@ -115,11 +115,11 @@ here - something
115
115
  assert_equal "method_<here>(args)\n", signature
116
116
 
117
117
  expected =
118
- @RM::Document.new(
119
- @RM::Heading.new(3, 'Signature'),
120
- @RM::List.new(:NOTE,
121
- @RM::ListItem.new('here',
122
- @RM::Paragraph.new('something'))))
118
+ doc(
119
+ head(3, 'Signature'),
120
+ list(:NOTE,
121
+ item(%w[here],
122
+ para('something'))))
123
123
  expected.file = @top_level
124
124
 
125
125
  assert_equal expected, c.parse
@@ -144,17 +144,14 @@ description - arguments description
144
144
  TEXT
145
145
 
146
146
  expected =
147
- @RM::Document.new(
148
- @RM::Paragraph.new('Create new Arg object.'),
149
- @RM::BlankLine.new,
150
- @RM::List.new(
151
- :NOTE,
152
- @RM::ListItem.new(
153
- 'name',
154
- @RM::Paragraph.new('name of argument')),
155
- @RM::ListItem.new(
156
- 'description',
157
- @RM::Paragraph.new('arguments description'))))
147
+ doc(
148
+ para('Create new Arg object.'),
149
+ blank_line,
150
+ list(:NOTE,
151
+ item(%w[name],
152
+ para('name of argument')),
153
+ item(%w[description],
154
+ para('arguments description'))))
158
155
 
159
156
  assert_equal expected, @TD.parse(text)
160
157
  end
@@ -168,15 +165,12 @@ foo - A comment goes here
168
165
  TEXT
169
166
 
170
167
  expected =
171
- @RM::Document.new(
172
- @RM::Paragraph.new('Do some stuff'),
173
- @RM::BlankLine.new,
174
- @RM::List.new(
175
- :NOTE,
176
- @RM::ListItem.new(
177
- 'foo',
178
- @RM::Paragraph.new(
179
- 'A comment goes here', 'and is more than one line'))))
168
+ doc(
169
+ para('Do some stuff'),
170
+ blank_line,
171
+ list(:NOTE,
172
+ item(%w[foo],
173
+ para('A comment goes here', 'and is more than one line'))))
180
174
 
181
175
  assert_equal expected, @TD.parse(text)
182
176
  end
@@ -190,19 +184,15 @@ foo - A comment goes here
190
184
  TEXT
191
185
 
192
186
  expected =
193
- @RM::Document.new(
194
- @RM::Paragraph.new('Do some stuff'),
195
- @RM::BlankLine.new,
196
- @RM::List.new(
197
- :NOTE,
198
- @RM::ListItem.new(
199
- 'foo',
200
- @RM::Paragraph.new('A comment goes here'),
201
- @RM::List.new(
202
- :NOTE,
203
- @RM::ListItem.new(
204
- ':bar',
205
- @RM::Paragraph.new('bar documentation'))))))
187
+ doc(
188
+ para('Do some stuff'),
189
+ blank_line,
190
+ list(:NOTE,
191
+ item(%w[foo],
192
+ para('A comment goes here'),
193
+ list(:NOTE,
194
+ item(%w[:bar],
195
+ para('bar documentation'))))))
206
196
 
207
197
  assert_equal expected, @TD.parse(text)
208
198
  end
@@ -216,13 +206,16 @@ Examples
216
206
  1 + 1
217
207
  TEXT
218
208
 
209
+ code = verb("1 + 1\n")
210
+ code.format = :ruby
211
+
219
212
  expected =
220
- @RM::Document.new(
221
- @RM::Paragraph.new('Do some stuff'),
222
- @RM::BlankLine.new,
223
- @RM::Heading.new(3, 'Examples'),
224
- @RM::BlankLine.new,
225
- @RM::Verbatim.new("1 + 1\n"))
213
+ doc(
214
+ para('Do some stuff'),
215
+ blank_line,
216
+ head(3, 'Examples'),
217
+ blank_line,
218
+ code)
226
219
 
227
220
  document = @TD.parse(text)
228
221
  assert_equal expected, document
@@ -242,21 +235,25 @@ Signature
242
235
  foo(args)
243
236
  TEXT
244
237
 
238
+ code1 = verb("1 + 1\n")
239
+ code1.format = :ruby
240
+
241
+ code2 = verb("foo(args)\n")
242
+
245
243
  expected =
246
- @RM::Document.new(
247
- @RM::Paragraph.new('Do some stuff'),
248
- @RM::BlankLine.new,
249
- @RM::Heading.new(3, 'Examples'),
250
- @RM::BlankLine.new,
251
- @RM::Verbatim.new("1 + 1\n"),
252
- @RM::Heading.new(3, 'Signature'),
253
- @RM::BlankLine.new,
254
- @RM::Verbatim.new("foo(args)\n"))
244
+ doc(
245
+ para('Do some stuff'),
246
+ blank_line,
247
+ head(3, 'Examples'),
248
+ blank_line,
249
+ code1,
250
+ head(3, 'Signature'),
251
+ blank_line,
252
+ code2)
253
+
254
+ document = @TD.parse text
255
255
 
256
- document = @TD.parse(text)
257
256
  assert_equal expected, document
258
- assert document.parts[4].ruby?
259
- refute document.parts.last.ruby?
260
257
  end
261
258
 
262
259
  def test_parse_returns
@@ -5,112 +5,29 @@ class TestRDocTopLevel < XrefTestCase
5
5
  def setup
6
6
  super
7
7
 
8
- @top_level = RDoc::TopLevel.new 'path/top_level.rb'
8
+ @top_level = @store.add_file 'path/top_level.rb'
9
9
  @top_level.parser = RDoc::Parser::Ruby
10
10
  end
11
11
 
12
- def test_class_all_classes_and_modules
13
- expected = %w[
14
- C1 C2 C2::C3 C2::C3::H1 C3 C3::H1 C3::H2 C4 C4::C4 C5 C5::C1
15
- Child
16
- M1 M1::M2
17
- Parent
18
- ]
19
-
20
- assert_equal expected,
21
- RDoc::TopLevel.all_classes_and_modules.map { |m| m.full_name }.sort
22
- end
23
-
24
- def test_class_classes
25
- expected = %w[
26
- C1 C2 C2::C3 C2::C3::H1 C3 C3::H1 C3::H2 C4 C4::C4 C5 C5::C1
27
- Child Parent
28
- ]
29
-
30
- assert_equal expected, RDoc::TopLevel.classes.map { |m| m.full_name }.sort
31
- end
32
-
33
- def test_class_complete
34
- @c2.add_module_alias @c2_c3, 'A1', @top_level
35
-
36
- RDoc::TopLevel.complete :public
37
-
38
- a1 = @xref_data.find_class_or_module 'C2::A1'
39
-
40
- assert_equal 'C2::A1', a1.full_name
41
- refute_empty a1.aliases
42
- end
43
-
44
- def test_class_files
45
- assert_equal %w[path/top_level.rb xref_data.rb],
46
- RDoc::TopLevel.files.map { |m| m.full_name }.sort
47
- end
48
-
49
- def test_class_find_class_named
50
- assert_equal @c1, RDoc::TopLevel.find_class_named('C1')
51
-
52
- assert_equal @c2_c3, RDoc::TopLevel.find_class_named('C2::C3')
53
- end
54
-
55
- def test_class_find_class_named_from
56
- assert_equal @c5_c1, RDoc::TopLevel.find_class_named_from('C1', 'C5')
57
-
58
- assert_equal @c1, RDoc::TopLevel.find_class_named_from('C1', 'C4')
59
- end
60
-
61
- def test_class_find_class_or_module
62
- assert_equal @m1, RDoc::TopLevel.find_class_or_module('M1')
63
- assert_equal @c1, RDoc::TopLevel.find_class_or_module('C1')
64
-
65
- assert_equal @m1, RDoc::TopLevel.find_class_or_module('::M1')
66
- assert_equal @c1, RDoc::TopLevel.find_class_or_module('::C1')
67
- end
68
-
69
- def test_class_find_file_named
70
- assert_equal @xref_data, RDoc::TopLevel.find_file_named(@file_name)
71
- end
12
+ def test_initialize
13
+ t = RDoc::TopLevel.new 'path/file.rb'
72
14
 
73
- def test_class_find_module_named
74
- assert_equal @m1, RDoc::TopLevel.find_module_named('M1')
75
- assert_equal @m1_m2, RDoc::TopLevel.find_module_named('M1::M2')
15
+ assert_equal 'path/file.rb', t.absolute_name
16
+ assert_equal 'path/file.rb', t.relative_name
76
17
  end
77
18
 
78
- def test_class_modules
79
- assert_equal %w[M1 M1::M2],
80
- RDoc::TopLevel.modules.map { |m| m.full_name }.sort
81
- end
82
-
83
- def test_class_new
84
- tl1 = RDoc::TopLevel.new 'file.rb'
85
- tl2 = RDoc::TopLevel.new 'file.rb'
86
- tl3 = RDoc::TopLevel.new 'other.rb'
87
-
88
- assert_same tl1, tl2
89
- refute_same tl1, tl3
90
- end
91
-
92
- def test_class_page
93
- page = RDoc::TopLevel.new 'PAGE.txt'
94
- page.parser = RDoc::Parser::Simple
95
-
96
- assert_nil RDoc::TopLevel.page 'no such page'
19
+ def test_initialize_relative
20
+ t = RDoc::TopLevel.new 'path/file.rb', 'file.rb'
97
21
 
98
- assert_equal page, RDoc::TopLevel.page('PAGE')
99
- end
100
-
101
- def test_class_reset
102
- RDoc::TopLevel.reset
103
-
104
- assert_empty RDoc::TopLevel.classes
105
- assert_empty RDoc::TopLevel.modules
106
- assert_empty RDoc::TopLevel.files
22
+ assert_equal 'path/file.rb', t.absolute_name
23
+ assert_equal 'file.rb', t.relative_name
107
24
  end
108
25
 
109
26
  def test_add_alias
110
27
  a = RDoc::Alias.new nil, 'old', 'new', nil
111
28
  @top_level.add_alias a
112
29
 
113
- object = RDoc::TopLevel.find_class_named 'Object'
30
+ object = @store.find_class_named 'Object'
114
31
  expected = { '#old' => [a] }
115
32
  assert_equal expected, object.unmatched_alias_lists
116
33
  assert_includes object.in_files, @top_level
@@ -122,7 +39,7 @@ class TestRDocTopLevel < XrefTestCase
122
39
  a = RDoc::Alias.new nil, 'old', 'new', nil
123
40
  @top_level.add_alias a
124
41
 
125
- object = RDoc::TopLevel.find_class_named('Object')
42
+ object = @store.find_class_named('Object')
126
43
  assert_empty object.unmatched_alias_lists
127
44
  assert_includes object.in_files, @top_level
128
45
  end
@@ -131,7 +48,7 @@ class TestRDocTopLevel < XrefTestCase
131
48
  const = RDoc::Constant.new 'C', nil, nil
132
49
  @top_level.add_constant const
133
50
 
134
- object = RDoc::TopLevel.find_class_named 'Object'
51
+ object = @store.find_class_named 'Object'
135
52
  assert_equal [const], object.constants
136
53
  assert_includes object.in_files, @top_level
137
54
  end
@@ -142,7 +59,7 @@ class TestRDocTopLevel < XrefTestCase
142
59
  const = RDoc::Constant.new 'C', nil, nil
143
60
  @top_level.add_constant const
144
61
 
145
- object = RDoc::TopLevel.find_class_named 'Object'
62
+ object = @store.find_class_named 'Object'
146
63
  assert_empty object.constants
147
64
  assert_includes object.in_files, @top_level
148
65
  end
@@ -151,7 +68,7 @@ class TestRDocTopLevel < XrefTestCase
151
68
  include = RDoc::Include.new 'C', nil
152
69
  @top_level.add_include include
153
70
 
154
- object = RDoc::TopLevel.find_class_named 'Object'
71
+ object = @store.find_class_named 'Object'
155
72
  assert_equal [include], object.includes
156
73
  assert_includes object.in_files, @top_level
157
74
  end
@@ -162,7 +79,7 @@ class TestRDocTopLevel < XrefTestCase
162
79
  include = RDoc::Include.new 'C', nil
163
80
  @top_level.add_include include
164
81
 
165
- object = RDoc::TopLevel.find_class_named('Object')
82
+ object = @store.find_class_named('Object')
166
83
  assert_empty object.includes
167
84
  assert_includes object.in_files, @top_level
168
85
  end
@@ -171,7 +88,7 @@ class TestRDocTopLevel < XrefTestCase
171
88
  method = RDoc::AnyMethod.new nil, 'm'
172
89
  @top_level.add_method method
173
90
 
174
- object = RDoc::TopLevel.find_class_named 'Object'
91
+ object = @store.find_class_named 'Object'
175
92
  assert_equal [method], object.method_list
176
93
  assert_includes object.in_files, @top_level
177
94
  end
@@ -182,7 +99,7 @@ class TestRDocTopLevel < XrefTestCase
182
99
  method = RDoc::AnyMethod.new nil, 'm'
183
100
  @top_level.add_method method
184
101
 
185
- object = RDoc::TopLevel.find_class_named('Object')
102
+ object = @store.find_class_named('Object')
186
103
  assert_empty object.method_list
187
104
  assert_includes object.in_files, @top_level
188
105
  end
@@ -194,15 +111,15 @@ class TestRDocTopLevel < XrefTestCase
194
111
  def test_display_eh
195
112
  refute @top_level.display?
196
113
 
197
- page = RDoc::TopLevel.new 'README.txt'
114
+ page = @store.add_file 'README.txt'
198
115
  page.parser = RDoc::Parser::Simple
199
116
 
200
117
  assert page.display?
201
118
  end
202
119
 
203
120
  def test_eql_eh
204
- top_level2 = RDoc::TopLevel.new 'path/top_level.rb'
205
- other_level = RDoc::TopLevel.new 'path/other_level.rb'
121
+ top_level2 = @store.add_file 'path/top_level.rb'
122
+ other_level = @store.add_file 'path/other_level.rb'
206
123
 
207
124
  assert_operator @top_level, :eql?, top_level2
208
125
 
@@ -210,8 +127,8 @@ class TestRDocTopLevel < XrefTestCase
210
127
  end
211
128
 
212
129
  def test_equals2
213
- top_level2 = RDoc::TopLevel.new 'path/top_level.rb'
214
- other_level = RDoc::TopLevel.new 'path/other_level.rb'
130
+ top_level2 = @store.add_file 'path/top_level.rb'
131
+ other_level = @store.add_file 'path/other_level.rb'
215
132
 
216
133
  assert_equal @top_level, top_level2
217
134
 
@@ -230,8 +147,8 @@ class TestRDocTopLevel < XrefTestCase
230
147
  end
231
148
 
232
149
  def test_hash
233
- tl2 = RDoc::TopLevel.new 'path/top_level.rb'
234
- tl3 = RDoc::TopLevel.new 'other/top_level.rb'
150
+ tl2 = @store.add_file 'path/top_level.rb'
151
+ tl3 = @store.add_file 'other/top_level.rb'
235
152
 
236
153
  assert_equal @top_level.hash, tl2.hash
237
154
  refute_equal @top_level.hash, tl3.hash
@@ -249,6 +166,47 @@ class TestRDocTopLevel < XrefTestCase
249
166
  assert_equal 0, @top_level.last_modified
250
167
  end
251
168
 
169
+ def test_marshal_dump
170
+ page = @store.add_file 'README.txt'
171
+ page.parser = RDoc::Parser::Simple
172
+ page.comment = RDoc::Comment.new 'This is a page', page
173
+
174
+ loaded = Marshal.load Marshal.dump page
175
+
176
+ comment = RDoc::Markup::Document.new(
177
+ RDoc::Markup::Paragraph.new('This is a page'))
178
+ comment.file = loaded
179
+
180
+ assert_equal page, loaded
181
+
182
+ assert_equal 'README.txt', loaded.absolute_name
183
+ assert_equal 'README.txt', loaded.relative_name
184
+
185
+ assert_equal RDoc::Parser::Simple, loaded.parser
186
+
187
+ assert_equal comment, loaded.comment
188
+ end
189
+
190
+ def test_marshal_load_version_0
191
+ loaded = Marshal.load "\x04\bU:\x13RDoc::TopLevel" +
192
+ "[\ti\x00I\"\x0FREADME.txt\x06:\x06EF" +
193
+ "c\x19RDoc::Parser::Simple" +
194
+ "o:\eRDoc::Markup::Document\a:\v@parts" +
195
+ "[\x06o:\x1CRDoc::Markup::Paragraph\x06;\b" +
196
+ "[\x06I\"\x13This is a page\x06;\x06F:\n@file@\a"
197
+
198
+ comment = RDoc::Markup::Document.new(
199
+ RDoc::Markup::Paragraph.new('This is a page'))
200
+ comment.file = loaded
201
+
202
+ assert_equal 'README.txt', loaded.absolute_name
203
+ assert_equal 'README.txt', loaded.relative_name
204
+
205
+ assert_equal RDoc::Parser::Simple, loaded.parser
206
+
207
+ assert_equal comment, loaded.comment
208
+ end
209
+
252
210
  def test_name
253
211
  assert_equal 'top_level.rb', @top_level.name
254
212
  end
@@ -256,11 +214,11 @@ class TestRDocTopLevel < XrefTestCase
256
214
  def test_page_name
257
215
  assert_equal 'top_level', @top_level.page_name
258
216
 
259
- tl = RDoc::TopLevel.new 'README.ja.rdoc'
217
+ tl = @store.add_file 'README.ja.rdoc'
260
218
 
261
219
  assert_equal 'README.ja', tl.page_name
262
220
 
263
- tl = RDoc::TopLevel.new 'Rakefile'
221
+ tl = @store.add_file 'Rakefile'
264
222
 
265
223
  assert_equal 'Rakefile', tl.page_name
266
224
  end
@@ -270,7 +228,7 @@ class TestRDocTopLevel < XrefTestCase
270
228
  end
271
229
 
272
230
  def test_search_record_page
273
- page = RDoc::TopLevel.new 'README.txt'
231
+ page = @store.add_file 'README.txt'
274
232
  page.parser = RDoc::Parser::Simple
275
233
  page.comment = 'This is a comment.'
276
234
 
@@ -290,12 +248,12 @@ class TestRDocTopLevel < XrefTestCase
290
248
  def test_text_eh
291
249
  refute @xref_data.text?
292
250
 
293
- rd = RDoc::TopLevel.new 'rd_format.rd'
251
+ rd = @store.add_file 'rd_format.rd'
294
252
  rd.parser = RDoc::Parser::RD
295
253
 
296
254
  assert rd.text?
297
255
 
298
- simple = RDoc::TopLevel.new 'simple.txt'
256
+ simple = @store.add_file 'simple.txt'
299
257
  simple.parser = RDoc::Parser::Simple
300
258
 
301
259
  assert simple.text?
@@ -304,7 +262,7 @@ class TestRDocTopLevel < XrefTestCase
304
262
  def test_text_eh_no_parser
305
263
  refute @xref_data.text?
306
264
 
307
- rd = RDoc::TopLevel.new 'rd_format.rd'
265
+ rd = @store.add_file 'rd_format.rd'
308
266
 
309
267
  refute rd.text?
310
268
  end