rdoc 2.4.3 → 2.5

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 (139) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.autotest +3 -1
  3. data/History.txt +68 -0
  4. data/LICENSE.txt +57 -0
  5. data/Manifest.txt +37 -19
  6. data/README.txt +2 -12
  7. data/Rakefile +12 -12
  8. data/bin/rdoc +4 -4
  9. data/lib/rdoc.rb +32 -9
  10. data/lib/rdoc/alias.rb +2 -2
  11. data/lib/rdoc/any_method.rb +108 -16
  12. data/lib/rdoc/attr.rb +87 -1
  13. data/lib/rdoc/class_module.rb +131 -5
  14. data/lib/rdoc/code_object.rb +28 -5
  15. data/lib/rdoc/constant.rb +22 -0
  16. data/lib/rdoc/context.rb +80 -37
  17. data/lib/rdoc/gauntlet.rb +48 -0
  18. data/lib/rdoc/generator/darkfish.rb +25 -23
  19. data/lib/rdoc/generator/markup.rb +6 -29
  20. data/lib/rdoc/generator/ri.rb +39 -189
  21. data/lib/rdoc/generator/template/darkfish/classpage.rhtml +17 -1
  22. data/lib/rdoc/generator/template/darkfish/filepage.rhtml +10 -0
  23. data/lib/rdoc/generator/template/darkfish/images/brick.png +0 -0
  24. data/lib/rdoc/generator/template/darkfish/images/brick_link.png +0 -0
  25. data/lib/rdoc/generator/template/darkfish/images/bullet_black.png +0 -0
  26. data/lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png +0 -0
  27. data/lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png +0 -0
  28. data/lib/rdoc/generator/template/darkfish/images/date.png +0 -0
  29. data/lib/rdoc/generator/template/darkfish/images/find.png +0 -0
  30. data/lib/rdoc/generator/template/darkfish/images/package.png +0 -0
  31. data/lib/rdoc/generator/template/darkfish/images/page_green.png +0 -0
  32. data/lib/rdoc/generator/template/darkfish/images/page_white_text.png +0 -0
  33. data/lib/rdoc/generator/template/darkfish/images/page_white_width.png +0 -0
  34. data/lib/rdoc/generator/template/darkfish/images/plugin.png +0 -0
  35. data/lib/rdoc/generator/template/darkfish/images/ruby.png +0 -0
  36. data/lib/rdoc/generator/template/darkfish/images/tag_green.png +0 -0
  37. data/lib/rdoc/generator/template/darkfish/images/wrench.png +0 -0
  38. data/lib/rdoc/generator/template/darkfish/images/wrench_orange.png +0 -0
  39. data/lib/rdoc/generator/template/darkfish/images/zoom.png +0 -0
  40. data/lib/rdoc/generator/template/darkfish/index.rhtml +2 -2
  41. data/lib/rdoc/generator/template/darkfish/rdoc.css +38 -33
  42. data/lib/rdoc/include.rb +22 -0
  43. data/lib/rdoc/markup.rb +10 -262
  44. data/lib/rdoc/markup/attribute_manager.rb +57 -50
  45. data/lib/rdoc/markup/blank_line.rb +19 -0
  46. data/lib/rdoc/markup/document.rb +72 -0
  47. data/lib/rdoc/markup/formatter.rb +118 -0
  48. data/lib/rdoc/markup/formatter_test_case.rb +341 -0
  49. data/lib/rdoc/markup/heading.rb +17 -0
  50. data/lib/rdoc/markup/inline.rb +6 -5
  51. data/lib/rdoc/markup/list.rb +78 -0
  52. data/lib/rdoc/markup/list_item.rb +83 -0
  53. data/lib/rdoc/markup/paragraph.rb +66 -0
  54. data/lib/rdoc/markup/parser.rb +528 -0
  55. data/lib/rdoc/markup/rule.rb +17 -0
  56. data/lib/rdoc/markup/to_ansi.rb +72 -0
  57. data/lib/rdoc/markup/to_bs.rb +74 -0
  58. data/lib/rdoc/markup/to_html.rb +106 -172
  59. data/lib/rdoc/markup/to_html_crossref.rb +10 -4
  60. data/lib/rdoc/markup/to_rdoc.rb +243 -0
  61. data/lib/rdoc/markup/to_test.rb +27 -16
  62. data/lib/rdoc/markup/verbatim.rb +42 -0
  63. data/lib/rdoc/normal_class.rb +38 -1
  64. data/lib/rdoc/normal_module.rb +38 -8
  65. data/lib/rdoc/options.rb +39 -151
  66. data/lib/rdoc/parser.rb +36 -18
  67. data/lib/rdoc/parser/c.rb +102 -109
  68. data/lib/rdoc/parser/ruby.rb +359 -1662
  69. data/lib/rdoc/parser/ruby_tools.rb +157 -0
  70. data/lib/rdoc/parser/simple.rb +0 -2
  71. data/lib/rdoc/rdoc.rb +142 -82
  72. data/lib/rdoc/ri.rb +10 -0
  73. data/lib/rdoc/ri/driver.rb +674 -444
  74. data/lib/rdoc/ri/formatter.rb +2 -651
  75. data/lib/rdoc/ri/paths.rb +70 -45
  76. data/lib/rdoc/ri/store.rb +248 -0
  77. data/lib/rdoc/ruby_lex.rb +1284 -0
  78. data/lib/rdoc/ruby_token.rb +416 -0
  79. data/lib/rdoc/single_class.rb +5 -0
  80. data/lib/rdoc/stats.rb +152 -83
  81. data/lib/rdoc/task.rb +27 -49
  82. data/lib/rdoc/text.rb +130 -0
  83. data/lib/rdoc/tokenstream.rb +28 -9
  84. data/lib/rdoc/top_level.rb +49 -43
  85. data/test/hidden.zip.txt +1 -0
  86. data/test/test_attribute_manager.rb +9 -16
  87. data/test/test_rdoc_any_method.rb +23 -0
  88. data/test/test_rdoc_attr.rb +40 -0
  89. data/test/test_rdoc_class_module.rb +100 -0
  90. data/test/test_rdoc_code_object.rb +18 -2
  91. data/test/test_rdoc_context.rb +41 -0
  92. data/test/test_rdoc_generator_ri.rb +56 -0
  93. data/test/test_rdoc_markup.rb +21 -610
  94. data/test/test_rdoc_markup_attribute_manager.rb +14 -17
  95. data/test/test_rdoc_markup_document.rb +51 -0
  96. data/test/test_rdoc_markup_paragraph.rb +27 -0
  97. data/test/test_rdoc_markup_parser.rb +1327 -0
  98. data/test/test_rdoc_markup_to_ansi.rb +426 -0
  99. data/test/test_rdoc_markup_to_bs.rb +443 -0
  100. data/test/test_rdoc_markup_to_html.rb +183 -18
  101. data/test/test_rdoc_markup_to_html_crossref.rb +1 -3
  102. data/test/test_rdoc_markup_to_rdoc.rb +426 -0
  103. data/test/test_rdoc_normal_class.rb +17 -0
  104. data/test/test_rdoc_normal_module.rb +6 -6
  105. data/test/test_rdoc_options.rb +41 -0
  106. data/test/test_rdoc_parser.rb +66 -13
  107. data/test/test_rdoc_parser_c.rb +93 -38
  108. data/test/test_rdoc_parser_perl.rb +2 -3
  109. data/test/test_rdoc_parser_ruby.rb +291 -28
  110. data/test/test_rdoc_parser_simple.rb +48 -0
  111. data/test/test_rdoc_rdoc.rb +66 -0
  112. data/test/test_rdoc_ri_driver.rb +752 -38
  113. data/test/test_rdoc_ri_paths.rb +39 -0
  114. data/test/test_rdoc_ri_store.rb +309 -0
  115. data/test/test_rdoc_text.rb +157 -0
  116. data/test/test_rdoc_top_level.rb +35 -9
  117. data/test/xref_data.rb +9 -1
  118. data/test/xref_test_case.rb +8 -3
  119. metadata +110 -38
  120. metadata.gz.sig +0 -0
  121. data/lib/rdoc/cache.rb +0 -41
  122. data/lib/rdoc/diagram.rb +0 -340
  123. data/lib/rdoc/dot.rb +0 -249
  124. data/lib/rdoc/markup/fragments.rb +0 -377
  125. data/lib/rdoc/markup/lines.rb +0 -156
  126. data/lib/rdoc/markup/to_flow.rb +0 -211
  127. data/lib/rdoc/markup/to_latex.rb +0 -328
  128. data/lib/rdoc/markup/to_texinfo.rb +0 -73
  129. data/lib/rdoc/ri/cache.rb +0 -187
  130. data/lib/rdoc/ri/descriptions.rb +0 -156
  131. data/lib/rdoc/ri/display.rb +0 -340
  132. data/lib/rdoc/ri/reader.rb +0 -106
  133. data/lib/rdoc/ri/util.rb +0 -79
  134. data/lib/rdoc/ri/writer.rb +0 -68
  135. data/test/test_rdoc_ri_attribute_formatter.rb +0 -44
  136. data/test/test_rdoc_ri_default_display.rb +0 -302
  137. data/test/test_rdoc_ri_formatter.rb +0 -320
  138. data/test/test_rdoc_ri_html_formatter.rb +0 -141
  139. data/test/test_rdoc_ri_overstrike_formatter.rb +0 -71
@@ -0,0 +1,426 @@
1
+ require 'rubygems'
2
+ require 'rdoc/markup/formatter_test_case'
3
+ require 'rdoc/markup/to_ansi'
4
+ require 'minitest/autorun'
5
+
6
+ class TestRDocMarkupToAnsi < RDoc::Markup::FormatterTestCase
7
+
8
+ add_visitor_tests
9
+
10
+ def setup
11
+ super
12
+
13
+ @to = RDoc::Markup::ToAnsi.new
14
+ end
15
+
16
+ def accept_blank_line
17
+ assert_equal "\e[0m\n", @to.res.join
18
+ end
19
+
20
+ def accept_heading
21
+ assert_equal "\e[0mHello\n", @to.res.join
22
+ end
23
+
24
+ def accept_list_end_bullet
25
+ assert_empty @to.list_index
26
+ assert_empty @to.list_type
27
+ assert_empty @to.list_width
28
+ end
29
+
30
+ def accept_list_end_label
31
+ assert_empty @to.list_index
32
+ assert_empty @to.list_type
33
+ assert_empty @to.list_width
34
+ end
35
+
36
+ def accept_list_end_lalpha
37
+ assert_empty @to.list_index
38
+ assert_empty @to.list_type
39
+ assert_empty @to.list_width
40
+ end
41
+
42
+ def accept_list_end_note
43
+ assert_empty @to.list_index
44
+ assert_empty @to.list_type
45
+ assert_empty @to.list_width
46
+ end
47
+
48
+ def accept_list_end_number
49
+ assert_empty @to.list_index
50
+ assert_empty @to.list_type
51
+ assert_empty @to.list_width
52
+ end
53
+
54
+ def accept_list_end_ualpha
55
+ assert_empty @to.list_index
56
+ assert_empty @to.list_type
57
+ assert_empty @to.list_width
58
+ end
59
+
60
+ def accept_list_item_end_bullet
61
+ assert_equal 0, @to.indent, 'indent'
62
+ end
63
+
64
+ def accept_list_item_end_label
65
+ assert_equal "\e[0m\n", @to.res.join
66
+ assert_equal 0, @to.indent, 'indent'
67
+ end
68
+
69
+ def accept_list_item_end_lalpha
70
+ assert_equal 0, @to.indent, 'indent'
71
+ assert_equal 'b', @to.list_index.last
72
+ end
73
+
74
+ def accept_list_item_end_note
75
+ assert_equal "\e[0m\n", @to.res.join
76
+ assert_equal 0, @to.indent, 'indent'
77
+ end
78
+
79
+ def accept_list_item_end_number
80
+ assert_equal 0, @to.indent, 'indent'
81
+ assert_equal 2, @to.list_index.last
82
+ end
83
+
84
+ def accept_list_item_end_ualpha
85
+ assert_equal 0, @to.indent, 'indent'
86
+ assert_equal 'B', @to.list_index.last
87
+ end
88
+
89
+ def accept_list_item_start_bullet
90
+ assert_equal %W"\e[0m", @to.res
91
+ assert_equal '* ', @to.prefix
92
+ end
93
+
94
+ def accept_list_item_start_label
95
+ assert_equal %W"\e[0m", @to.res
96
+ assert_equal "cat:\n ", @to.prefix
97
+
98
+ assert_equal 2, @to.indent
99
+ end
100
+
101
+ def accept_list_item_start_lalpha
102
+ assert_equal %W"\e[0m", @to.res
103
+ assert_equal 'a. ', @to.prefix
104
+
105
+ assert_equal 'a', @to.list_index.last
106
+ assert_equal 3, @to.indent
107
+ end
108
+
109
+ def accept_list_item_start_note
110
+ assert_equal %W"\e[0m", @to.res
111
+ assert_equal "cat:\n ", @to.prefix
112
+
113
+ assert_equal 2, @to.indent
114
+ end
115
+
116
+ def accept_list_item_start_number
117
+ assert_equal %W"\e[0m", @to.res
118
+ assert_equal '1. ', @to.prefix
119
+
120
+ assert_equal 1, @to.list_index.last
121
+ assert_equal 3, @to.indent
122
+ end
123
+
124
+ def accept_list_item_start_ualpha
125
+ assert_equal %W"\e[0m", @to.res
126
+ assert_equal 'A. ', @to.prefix
127
+
128
+ assert_equal 'A', @to.list_index.last
129
+ assert_equal 3, @to.indent
130
+ end
131
+
132
+ def accept_list_start_bullet
133
+ assert_equal "\e[0m", @to.res.join
134
+ assert_equal [nil], @to.list_index
135
+ assert_equal [:BULLET], @to.list_type
136
+ assert_equal [1], @to.list_width
137
+ end
138
+
139
+ def accept_list_start_label
140
+ assert_equal "\e[0m", @to.res.join
141
+ assert_equal [nil], @to.list_index
142
+ assert_equal [:LABEL], @to.list_type
143
+ assert_equal [2], @to.list_width
144
+ end
145
+
146
+ def accept_list_start_lalpha
147
+ assert_equal "\e[0m", @to.res.join
148
+ assert_equal ['a'], @to.list_index
149
+ assert_equal [:LALPHA], @to.list_type
150
+ assert_equal [1], @to.list_width
151
+ end
152
+
153
+ def accept_list_start_note
154
+ assert_equal "\e[0m", @to.res.join
155
+ assert_equal [nil], @to.list_index
156
+ assert_equal [:NOTE], @to.list_type
157
+ assert_equal [2], @to.list_width
158
+ end
159
+
160
+ def accept_list_start_number
161
+ assert_equal "\e[0m", @to.res.join
162
+ assert_equal [1], @to.list_index
163
+ assert_equal [:NUMBER], @to.list_type
164
+ assert_equal [1], @to.list_width
165
+ end
166
+
167
+ def accept_list_start_ualpha
168
+ assert_equal "\e[0m", @to.res.join
169
+ assert_equal ['A'], @to.list_index
170
+ assert_equal [:UALPHA], @to.list_type
171
+ assert_equal [1], @to.list_width
172
+ end
173
+
174
+ def accept_paragraph
175
+ assert_equal "\e[0mhi\n", @to.res.join
176
+ end
177
+
178
+ def accept_rule
179
+ assert_equal "\e[0m#{'-' * 78}\n", @to.res.join
180
+ end
181
+
182
+ def accept_verbatim # FormatterTestCase doesn't set indent for ToAnsi
183
+ assert_equal "\e[0m hi\n world\n\n", @to.res.join
184
+ end
185
+
186
+ def end_accepting
187
+ assert_equal "\e[0mhi", @to.end_accepting
188
+ end
189
+
190
+ def start_accepting
191
+ assert_equal 0, @to.indent
192
+ assert_equal %W"\e[0m", @to.res
193
+ assert_empty @to.list_index
194
+ assert_empty @to.list_type
195
+ assert_empty @to.list_width
196
+ end
197
+
198
+ def test_accept_heading_1
199
+ @to.start_accepting
200
+ @to.accept_heading @RM::Heading.new(1, 'Hello')
201
+
202
+ assert_equal "\e[0m\e[1;32mHello\e[m\n", @to.end_accepting
203
+ end
204
+
205
+ def test_accept_heading_2
206
+ @to.start_accepting
207
+ @to.accept_heading @RM::Heading.new(2, 'Hello')
208
+
209
+ assert_equal "\e[0m\e[4;32mHello\e[m\n", @to.end_accepting
210
+ end
211
+
212
+ def test_accept_heading_3
213
+ @to.start_accepting
214
+ @to.accept_heading @RM::Heading.new(3, 'Hello')
215
+
216
+ assert_equal "\e[0m\e[32mHello\e[m\n", @to.end_accepting
217
+ end
218
+
219
+ def test_accept_heading_4
220
+ @to.start_accepting
221
+ @to.accept_heading @RM::Heading.new(4, 'Hello')
222
+
223
+ assert_equal "\e[0mHello\n", @to.end_accepting
224
+ end
225
+
226
+ def test_accept_heading_indent
227
+ @to.start_accepting
228
+ @to.indent = 3
229
+ @to.accept_heading @RM::Heading.new(1, 'Hello')
230
+
231
+ assert_equal "\e[0m \e[1;32mHello\e[m\n", @to.end_accepting
232
+ end
233
+
234
+ def test_accept_heading_b
235
+ @to.start_accepting
236
+ @to.indent = 3
237
+ @to.accept_heading @RM::Heading.new(1, '*Hello*')
238
+
239
+ assert_equal "\e[0m \e[1;32m\e[1mHello\e[m\e[m\n", @to.end_accepting
240
+ end
241
+
242
+ def test_accept_list_item_start_note_2
243
+ list = @RM::List.new(:NOTE,
244
+ @RM::ListItem.new('<tt>teletype</tt>',
245
+ @RM::Paragraph.new('teletype description')))
246
+
247
+ @to.start_accepting
248
+
249
+ list.accept @to
250
+
251
+ expected = "\e[0m\e[7mteletype\e[m:\n teletype description\n\n"
252
+
253
+ assert_equal expected, @to.end_accepting
254
+ end
255
+
256
+ def test_accept_paragraph_b
257
+ @to.start_accepting
258
+ @to.accept_paragraph @RM::Paragraph.new('reg <b>bold words</b> reg')
259
+
260
+ expected = "\e[0mreg \e[1mbold words\e[m reg\n"
261
+
262
+ assert_equal expected, @to.end_accepting
263
+ end
264
+
265
+ def test_accept_paragraph_i
266
+ @to.start_accepting
267
+ @to.accept_paragraph @RM::Paragraph.new('reg <em>italic words</em> reg')
268
+
269
+ expected = "\e[0mreg \e[4mitalic words\e[m reg\n"
270
+
271
+ assert_equal expected, @to.end_accepting
272
+ end
273
+
274
+ def test_accept_paragraph_indent
275
+ @to.start_accepting
276
+ @to.indent = 3
277
+ @to.accept_paragraph @RM::Paragraph.new('words ' * 30)
278
+
279
+ expected = <<-EXPECTED
280
+ \e[0m words words words words words words words words words words words words
281
+ words words words words words words words words words words words words
282
+ words words words words words words
283
+ EXPECTED
284
+
285
+ assert_equal expected, @to.end_accepting
286
+ end
287
+
288
+ def test_accept_paragraph_plus
289
+ @to.start_accepting
290
+ @to.accept_paragraph @RM::Paragraph.new('regular +teletype+ regular')
291
+
292
+ expected = "\e[0mregular \e[7mteletype\e[m regular\n"
293
+
294
+ assert_equal expected, @to.end_accepting
295
+ end
296
+
297
+ def test_accept_paragraph_star
298
+ @to.start_accepting
299
+ @to.accept_paragraph @RM::Paragraph.new('regular *bold* regular')
300
+
301
+ expected = "\e[0mregular \e[1mbold\e[m regular\n"
302
+
303
+ assert_equal expected, @to.end_accepting
304
+ end
305
+
306
+ def test_accept_paragraph_underscore
307
+ @to.start_accepting
308
+ @to.accept_paragraph @RM::Paragraph.new('regular _italic_ regular')
309
+
310
+ expected = "\e[0mregular \e[4mitalic\e[m regular\n"
311
+
312
+ assert_equal expected, @to.end_accepting
313
+ end
314
+
315
+ def test_accept_paragraph_wrap
316
+ @to.start_accepting
317
+ @to.accept_paragraph @RM::Paragraph.new('words ' * 30)
318
+
319
+ expected = <<-EXPECTED
320
+ \e[0mwords words words words words words words words words words words words words
321
+ words words words words words words words words words words words words words
322
+ words words words words
323
+ EXPECTED
324
+
325
+ assert_equal expected, @to.end_accepting
326
+ end
327
+
328
+ def test_accept_rule_indent
329
+ @to.start_accepting
330
+ @to.indent = 3
331
+
332
+ @to.accept_rule @RM::Rule.new(1)
333
+
334
+ assert_equal "\e[0m #{'-' * 75}\n", @to.end_accepting
335
+ end
336
+
337
+ def test_accept_verbatim_indent
338
+ @to.start_accepting
339
+
340
+ @to.indent = 2
341
+
342
+ @to.accept_verbatim @RM::Verbatim.new(' ', 'hi', "\n",
343
+ ' ', 'world', "\n")
344
+
345
+ assert_equal "\e[0m hi\n world\n\n", @to.end_accepting
346
+ end
347
+
348
+ def test_accept_verbatim_big_indent
349
+ @to.start_accepting
350
+
351
+ @to.indent = 2
352
+
353
+ @to.accept_verbatim @RM::Verbatim.new(' ', 'hi', "\n",
354
+ ' ', 'world', "\n")
355
+
356
+ assert_equal "\e[0m hi\n world\n\n", @to.end_accepting
357
+ end
358
+
359
+ def test_attributes
360
+ assert_equal 'Dog', @to.attributes("\\Dog")
361
+ end
362
+
363
+ def test_list_nested
364
+ doc = @RM::Document.new(
365
+ @RM::List.new(:BULLET,
366
+ @RM::ListItem.new(nil,
367
+ @RM::Paragraph.new('l1'),
368
+ @RM::List.new(:BULLET,
369
+ @RM::ListItem.new(nil,
370
+ @RM::Paragraph.new('l1.1')))),
371
+ @RM::ListItem.new(nil,
372
+ @RM::Paragraph.new('l2'))))
373
+
374
+ output = doc.accept @to
375
+
376
+ expected = <<-EXPECTED
377
+ \e[0m* l1
378
+ * l1.1
379
+ * l2
380
+ EXPECTED
381
+
382
+ assert_equal expected, output
383
+ end
384
+
385
+ def test_list_verbatim # HACK overblown
386
+ doc = @RM::Document.new(
387
+ @RM::List.new(:BULLET,
388
+ @RM::ListItem.new(nil,
389
+ @RM::Paragraph.new('list', 'stuff'),
390
+ @RM::BlankLine.new(),
391
+ @RM::Verbatim.new(' ', '*', ' ', 'list', "\n",
392
+ ' ', 'with', "\n",
393
+ "\n",
394
+ ' ', 'second', "\n",
395
+ "\n",
396
+ ' ', '1.', ' ', 'indented', "\n",
397
+ ' ', '2.', ' ', 'numbered', "\n",
398
+ "\n",
399
+ ' ', 'third', "\n",
400
+ "\n",
401
+ ' ', '*', ' ', 'second', "\n"))))
402
+
403
+ output = doc.accept @to
404
+
405
+ expected = <<-EXPECTED
406
+ \e[0m* list stuff
407
+
408
+ * list
409
+ with
410
+
411
+ second
412
+
413
+ 1. indented
414
+ 2. numbered
415
+
416
+ third
417
+
418
+ * second
419
+
420
+ EXPECTED
421
+
422
+ assert_equal expected, output
423
+ end
424
+
425
+ end
426
+
@@ -0,0 +1,443 @@
1
+ require 'rubygems'
2
+ require 'rdoc/markup/formatter_test_case'
3
+ require 'rdoc/markup/to_bs'
4
+ require 'minitest/autorun'
5
+
6
+ class TestRDocMarkupToBs < RDoc::Markup::FormatterTestCase
7
+
8
+ add_visitor_tests
9
+
10
+ def setup
11
+ super
12
+
13
+ @to = RDoc::Markup::ToBs.new
14
+ end
15
+
16
+ def accept_blank_line
17
+ assert_equal "\n", @to.res.join
18
+ end
19
+
20
+ def accept_heading
21
+ skip "No String#chars, upgrade your ruby" unless ''.respond_to? :chars
22
+ assert_equal "===== H\bHe\bel\bll\blo\bo\n", @to.res.join
23
+ end
24
+
25
+ def accept_list_end_bullet
26
+ assert_empty @to.list_index
27
+ assert_empty @to.list_type
28
+ assert_empty @to.list_width
29
+ end
30
+
31
+ def accept_list_end_label
32
+ assert_empty @to.list_index
33
+ assert_empty @to.list_type
34
+ assert_empty @to.list_width
35
+ end
36
+
37
+ def accept_list_end_lalpha
38
+ assert_empty @to.list_index
39
+ assert_empty @to.list_type
40
+ assert_empty @to.list_width
41
+ end
42
+
43
+ def accept_list_end_note
44
+ assert_empty @to.list_index
45
+ assert_empty @to.list_type
46
+ assert_empty @to.list_width
47
+ end
48
+
49
+ def accept_list_end_number
50
+ assert_empty @to.list_index
51
+ assert_empty @to.list_type
52
+ assert_empty @to.list_width
53
+ end
54
+
55
+ def accept_list_end_ualpha
56
+ assert_empty @to.list_index
57
+ assert_empty @to.list_type
58
+ assert_empty @to.list_width
59
+ end
60
+
61
+ def accept_list_item_end_bullet
62
+ assert_equal 0, @to.indent, 'indent'
63
+ end
64
+
65
+ def accept_list_item_end_label
66
+ assert_equal 0, @to.indent, 'indent'
67
+ end
68
+
69
+ def accept_list_item_end_lalpha
70
+ assert_equal 0, @to.indent, 'indent'
71
+ assert_equal 'b', @to.list_index.last
72
+ end
73
+
74
+ def accept_list_item_end_note
75
+ assert_equal 0, @to.indent, 'indent'
76
+ end
77
+
78
+ def accept_list_item_end_number
79
+ assert_equal 0, @to.indent, 'indent'
80
+ assert_equal 2, @to.list_index.last
81
+ end
82
+
83
+ def accept_list_item_end_ualpha
84
+ assert_equal 0, @to.indent, 'indent'
85
+ assert_equal 'B', @to.list_index.last
86
+ end
87
+
88
+ def accept_list_item_start_bullet
89
+ assert_equal [''], @to.res
90
+ assert_equal '* ', @to.prefix
91
+ end
92
+
93
+ def accept_list_item_start_label
94
+ assert_equal [''], @to.res
95
+ assert_equal "cat:\n ", @to.prefix
96
+
97
+ assert_equal 2, @to.indent
98
+ end
99
+
100
+ def accept_list_item_start_lalpha
101
+ assert_equal [''], @to.res
102
+ assert_equal 'a. ', @to.prefix
103
+
104
+ assert_equal 'a', @to.list_index.last
105
+ assert_equal 3, @to.indent
106
+ end
107
+
108
+ def accept_list_item_start_note
109
+ assert_equal [''], @to.res
110
+ assert_equal "cat:\n ", @to.prefix
111
+
112
+ assert_equal 2, @to.indent
113
+ end
114
+
115
+ def accept_list_item_start_number
116
+ assert_equal [''], @to.res
117
+ assert_equal '1. ', @to.prefix
118
+
119
+ assert_equal 1, @to.list_index.last
120
+ assert_equal 3, @to.indent
121
+ end
122
+
123
+ def accept_list_item_start_ualpha
124
+ assert_equal [''], @to.res
125
+ assert_equal 'A. ', @to.prefix
126
+
127
+ assert_equal 'A', @to.list_index.last
128
+ assert_equal 3, @to.indent
129
+ end
130
+
131
+ def accept_list_start_bullet
132
+ assert_equal "", @to.res.join
133
+ assert_equal [nil], @to.list_index
134
+ assert_equal [:BULLET], @to.list_type
135
+ assert_equal [1], @to.list_width
136
+ end
137
+
138
+ def accept_list_start_label
139
+ assert_equal "", @to.res.join
140
+ assert_equal [nil], @to.list_index
141
+ assert_equal [:LABEL], @to.list_type
142
+ assert_equal [2], @to.list_width
143
+ end
144
+
145
+ def accept_list_start_lalpha
146
+ assert_equal "", @to.res.join
147
+ assert_equal ['a'], @to.list_index
148
+ assert_equal [:LALPHA], @to.list_type
149
+ assert_equal [1], @to.list_width
150
+ end
151
+
152
+ def accept_list_start_note
153
+ assert_equal "", @to.res.join
154
+ assert_equal [nil], @to.list_index
155
+ assert_equal [:NOTE], @to.list_type
156
+ assert_equal [2], @to.list_width
157
+ end
158
+
159
+ def accept_list_start_number
160
+ assert_equal "", @to.res.join
161
+ assert_equal [1], @to.list_index
162
+ assert_equal [:NUMBER], @to.list_type
163
+ assert_equal [1], @to.list_width
164
+ end
165
+
166
+ def accept_list_start_ualpha
167
+ assert_equal "", @to.res.join
168
+ assert_equal ['A'], @to.list_index
169
+ assert_equal [:UALPHA], @to.list_type
170
+ assert_equal [1], @to.list_width
171
+ end
172
+
173
+ def accept_paragraph
174
+ assert_equal "hi\n", @to.res.join
175
+ end
176
+
177
+ def accept_rule
178
+ assert_equal "#{'-' * 78}\n", @to.res.join
179
+ end
180
+
181
+ def accept_verbatim # FormatterTestCase doesn't set indent for ToAnsi
182
+ assert_equal " hi\n world\n\n", @to.res.join
183
+ end
184
+
185
+ def end_accepting
186
+ assert_equal "hi", @to.end_accepting
187
+ end
188
+
189
+ def start_accepting
190
+ assert_equal 0, @to.indent
191
+ assert_equal [''], @to.res
192
+ assert_empty @to.list_index
193
+ assert_empty @to.list_type
194
+ assert_empty @to.list_width
195
+ end
196
+
197
+ def test_accept_heading_1
198
+ skip "No String#chars, upgrade your ruby" unless ''.respond_to? :chars
199
+ @to.start_accepting
200
+ @to.accept_heading @RM::Heading.new(1, 'Hello')
201
+
202
+ assert_equal "= H\bHe\bel\bll\blo\bo\n", @to.end_accepting
203
+ end
204
+
205
+ def test_accept_heading_2
206
+ skip "No String#chars, upgrade your ruby" unless ''.respond_to? :chars
207
+ @to.start_accepting
208
+ @to.accept_heading @RM::Heading.new(2, 'Hello')
209
+
210
+ assert_equal "== H\bHe\bel\bll\blo\bo\n", @to.end_accepting
211
+ end
212
+
213
+ def test_accept_heading_3
214
+ skip "No String#chars, upgrade your ruby" unless ''.respond_to? :chars
215
+ @to.start_accepting
216
+ @to.accept_heading @RM::Heading.new(3, 'Hello')
217
+
218
+ assert_equal "=== H\bHe\bel\bll\blo\bo\n", @to.end_accepting
219
+ end
220
+
221
+ def test_accept_heading_4
222
+ skip "No String#chars, upgrade your ruby" unless ''.respond_to? :chars
223
+ @to.start_accepting
224
+ @to.accept_heading @RM::Heading.new(4, 'Hello')
225
+
226
+ assert_equal "==== H\bHe\bel\bll\blo\bo\n", @to.end_accepting
227
+ end
228
+
229
+ def test_accept_heading_indent
230
+ skip "No String#chars, upgrade your ruby" unless ''.respond_to? :chars
231
+ @to.start_accepting
232
+ @to.indent = 3
233
+ @to.accept_heading @RM::Heading.new(1, 'Hello')
234
+
235
+ assert_equal " = H\bHe\bel\bll\blo\bo\n", @to.end_accepting
236
+ end
237
+
238
+ def test_accept_heading_b
239
+ skip "No String#chars, upgrade your ruby" unless ''.respond_to? :chars
240
+ @to.start_accepting
241
+ @to.indent = 3
242
+ @to.accept_heading @RM::Heading.new(1, '*Hello*')
243
+
244
+ assert_equal " = H\bHe\bel\bll\blo\bo\n", @to.end_accepting
245
+ end
246
+
247
+ def test_accept_heading_suppressed_crossref
248
+ skip "No String#chars, upgrade your ruby" unless ''.respond_to? :chars
249
+ @to.start_accepting
250
+ @to.accept_heading @RM::Heading.new(1, '\\Hello')
251
+
252
+ assert_equal "= H\bHe\bel\bll\blo\bo\n", @to.end_accepting
253
+ end
254
+
255
+ def test_accept_list_item_start_note_2
256
+ list = @RM::List.new(:NOTE,
257
+ @RM::ListItem.new('<tt>teletype</tt>',
258
+ @RM::Paragraph.new('teletype description')))
259
+
260
+ @to.start_accepting
261
+
262
+ list.accept @to
263
+
264
+ expected = "teletype:\n teletype description\n\n"
265
+
266
+ assert_equal expected, @to.end_accepting
267
+ end
268
+
269
+ def test_accept_paragraph_b
270
+ skip "No String#chars, upgrade your ruby" unless ''.respond_to? :chars
271
+ @to.start_accepting
272
+ @to.accept_paragraph @RM::Paragraph.new('reg <b>bold words</b> reg')
273
+
274
+ expected = "reg b\bbo\bol\bld\bd \b w\bwo\bor\brd\bds\bs reg\n"
275
+
276
+ assert_equal expected, @to.end_accepting
277
+ end
278
+
279
+ def test_accept_paragraph_i
280
+ skip "No String#chars, upgrade your ruby" unless ''.respond_to? :chars
281
+ @to.start_accepting
282
+ @to.accept_paragraph @RM::Paragraph.new('reg <em>italic words</em> reg')
283
+
284
+ expected = "reg _\bi_\bt_\ba_\bl_\bi_\bc_\b _\bw_\bo_\br_\bd_\bs reg\n"
285
+
286
+ assert_equal expected, @to.end_accepting
287
+ end
288
+
289
+ def test_accept_paragraph_indent
290
+ @to.start_accepting
291
+ @to.indent = 3
292
+ @to.accept_paragraph @RM::Paragraph.new('words ' * 30)
293
+
294
+ expected = <<-EXPECTED
295
+ words words words words words words words words words words words words
296
+ words words words words words words words words words words words words
297
+ words words words words words words
298
+ EXPECTED
299
+
300
+ assert_equal expected, @to.end_accepting
301
+ end
302
+
303
+ def test_accept_paragraph_plus
304
+ @to.start_accepting
305
+ @to.accept_paragraph @RM::Paragraph.new('regular +teletype+ regular')
306
+
307
+ expected = "regular teletype regular\n"
308
+
309
+ assert_equal expected, @to.end_accepting
310
+ end
311
+
312
+ def test_accept_paragraph_star
313
+ skip "No String#chars, upgrade your ruby" unless ''.respond_to? :chars
314
+ @to.start_accepting
315
+ @to.accept_paragraph @RM::Paragraph.new('regular *bold* regular')
316
+
317
+ expected = "regular b\bbo\bol\bld\bd regular\n"
318
+
319
+ assert_equal expected, @to.end_accepting
320
+ end
321
+
322
+ def test_accept_paragraph_underscore
323
+ skip "No String#chars, upgrade your ruby" unless ''.respond_to? :chars
324
+ @to.start_accepting
325
+ @to.accept_paragraph @RM::Paragraph.new('regular _italic_ regular')
326
+
327
+ expected = "regular _\bi_\bt_\ba_\bl_\bi_\bc regular\n"
328
+
329
+ assert_equal expected, @to.end_accepting
330
+ end
331
+
332
+ def test_accept_paragraph_wrap
333
+ @to.start_accepting
334
+ @to.accept_paragraph @RM::Paragraph.new('words ' * 30)
335
+
336
+ expected = <<-EXPECTED
337
+ words words words words words words words words words words words words words
338
+ words words words words words words words words words words words words words
339
+ words words words words
340
+ EXPECTED
341
+
342
+ assert_equal expected, @to.end_accepting
343
+ end
344
+
345
+ def test_accept_rule_indent
346
+ @to.start_accepting
347
+ @to.indent = 3
348
+
349
+ @to.accept_rule @RM::Rule.new(1)
350
+
351
+ assert_equal " #{'-' * 75}\n", @to.end_accepting
352
+ end
353
+
354
+ def test_accept_verbatim_indent
355
+ @to.start_accepting
356
+
357
+ @to.indent = 2
358
+
359
+ @to.accept_verbatim @RM::Verbatim.new(' ', 'hi', "\n",
360
+ ' ', 'world', "\n")
361
+
362
+ assert_equal " hi\n world\n\n", @to.end_accepting
363
+ end
364
+
365
+ def test_accept_verbatim_big_indent
366
+ @to.start_accepting
367
+
368
+ @to.indent = 2
369
+
370
+ @to.accept_verbatim @RM::Verbatim.new(' ', 'hi', "\n",
371
+ ' ', 'world', "\n")
372
+
373
+ assert_equal " hi\n world\n\n", @to.end_accepting
374
+ end
375
+
376
+ def test_attributes
377
+ assert_equal 'Dog', @to.attributes("\\Dog")
378
+ end
379
+
380
+ def test_list_nested
381
+ doc = @RM::Document.new(
382
+ @RM::List.new(:BULLET,
383
+ @RM::ListItem.new(nil,
384
+ @RM::Paragraph.new('l1'),
385
+ @RM::List.new(:BULLET,
386
+ @RM::ListItem.new(nil,
387
+ @RM::Paragraph.new('l1.1')))),
388
+ @RM::ListItem.new(nil,
389
+ @RM::Paragraph.new('l2'))))
390
+
391
+ output = doc.accept @to
392
+
393
+ expected = <<-EXPECTED
394
+ * l1
395
+ * l1.1
396
+ * l2
397
+ EXPECTED
398
+
399
+ assert_equal expected, output
400
+ end
401
+
402
+ def test_list_verbatim # HACK overblown
403
+ doc = @RM::Document.new(
404
+ @RM::List.new(:BULLET,
405
+ @RM::ListItem.new(nil,
406
+ @RM::Paragraph.new('list', 'stuff'),
407
+ @RM::BlankLine.new(),
408
+ @RM::Verbatim.new(' ', '*', ' ', 'list', "\n",
409
+ ' ', 'with', "\n",
410
+ "\n",
411
+ ' ', 'second', "\n",
412
+ "\n",
413
+ ' ', '1.', ' ', 'indented', "\n",
414
+ ' ', '2.', ' ', 'numbered', "\n",
415
+ "\n",
416
+ ' ', 'third', "\n",
417
+ "\n",
418
+ ' ', '*', ' ', 'second', "\n"))))
419
+
420
+ output = doc.accept @to
421
+
422
+ expected = <<-EXPECTED
423
+ * list stuff
424
+
425
+ * list
426
+ with
427
+
428
+ second
429
+
430
+ 1. indented
431
+ 2. numbered
432
+
433
+ third
434
+
435
+ * second
436
+
437
+ EXPECTED
438
+
439
+ assert_equal expected, output
440
+ end
441
+
442
+ end
443
+