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
@@ -1,14 +1,16 @@
1
1
  require 'rubygems'
2
- require 'minitest/unit'
3
- require 'rdoc/markup'
2
+ require 'rdoc/markup/formatter_test_case'
4
3
  require 'rdoc/markup/to_html'
4
+ require 'minitest/autorun'
5
5
 
6
- class TestRDocMarkupToHtml < MiniTest::Unit::TestCase
6
+ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
7
+
8
+ add_visitor_tests
7
9
 
8
10
  def setup
9
- @m = RDoc::Markup.new
10
- @am = RDoc::Markup::AttributeManager.new
11
- @th = RDoc::Markup::ToHtml.new
11
+ super
12
+
13
+ @to = RDoc::Markup::ToHtml.new
12
14
  end
13
15
 
14
16
  def test_class_gen_relative_url
@@ -24,25 +26,189 @@ class TestRDocMarkupToHtml < MiniTest::Unit::TestCase
24
26
  assert_equal 'a/c.html', gen('a.html', 'a/c.html')
25
27
  end
26
28
 
29
+ def accept_blank_line
30
+ assert_empty @to.res.join
31
+ end
32
+
33
+ def accept_heading
34
+ assert_equal "<h5>Hello</h5>\n", @to.res.join
35
+ end
36
+
37
+ def accept_list_end_bullet
38
+ assert_equal [], @to.list
39
+ assert_equal [], @to.in_list_entry
40
+
41
+ assert_equal "<ul>\n</ul>\n", @to.res.join
42
+ end
43
+
44
+ def accept_list_end_label
45
+ assert_equal [], @to.list
46
+ assert_equal [], @to.in_list_entry
47
+
48
+ assert_equal "<dl>\n</dl>\n", @to.res.join
49
+ end
50
+
51
+ def accept_list_end_lalpha
52
+ assert_equal [], @to.list
53
+ assert_equal [], @to.in_list_entry
54
+
55
+ assert_equal "<ol style=\"display: lower-alpha\">\n</ol>\n", @to.res.join
56
+ end
57
+
58
+ def accept_list_end_number
59
+ assert_equal [], @to.list
60
+ assert_equal [], @to.in_list_entry
61
+
62
+ assert_equal "<ol>\n</ol>\n", @to.res.join
63
+ end
64
+
65
+ def accept_list_end_note
66
+ assert_equal [], @to.list
67
+ assert_equal [], @to.in_list_entry
68
+
69
+ assert_equal "<table>\n</table>\n", @to.res.join
70
+ end
71
+
72
+ def accept_list_end_ualpha
73
+ assert_equal [], @to.list
74
+ assert_equal [], @to.in_list_entry
75
+
76
+ assert_equal "<ol style=\"display: upper-alpha\">\n</ol>\n", @to.res.join
77
+ end
78
+
79
+ def accept_list_item_end_bullet
80
+ assert_equal %w[</li>], @to.in_list_entry
81
+ end
82
+
83
+ def accept_list_item_end_label
84
+ assert_equal %w[</dd>], @to.in_list_entry
85
+ end
86
+
87
+ def accept_list_item_end_lalpha
88
+ assert_equal %w[</li>], @to.in_list_entry
89
+ end
90
+
91
+ def accept_list_item_end_note
92
+ assert_equal %w[</td></tr>], @to.in_list_entry
93
+ end
94
+
95
+ def accept_list_item_end_number
96
+ assert_equal %w[</li>], @to.in_list_entry
97
+ end
98
+
99
+ def accept_list_item_end_ualpha
100
+ assert_equal %w[</li>], @to.in_list_entry
101
+ end
102
+
103
+ def accept_list_item_start_bullet
104
+ assert_equal "<ul>\n<li>", @to.res.join
105
+ end
106
+
107
+ def accept_list_item_start_label
108
+ assert_equal "<dl>\n<dt>cat</dt><dd>", @to.res.join
109
+ end
110
+
111
+ def accept_list_item_start_lalpha
112
+ assert_equal "<ol style=\"display: lower-alpha\">\n<li>", @to.res.join
113
+ end
114
+
115
+ def accept_list_item_start_note
116
+ assert_equal "<table>\n<tr><td valign=\"top\">cat</td><td>", @to.res.join
117
+ end
118
+
119
+ def accept_list_item_start_number
120
+ assert_equal "<ol>\n<li>", @to.res.join
121
+ end
122
+
123
+ def accept_list_item_start_ualpha
124
+ assert_equal "<ol style=\"display: upper-alpha\">\n<li>", @to.res.join
125
+ end
126
+
127
+ def accept_list_start_bullet
128
+ assert_equal [:BULLET], @to.list
129
+ assert_equal [false], @to.in_list_entry
130
+
131
+ assert_equal "<ul>\n", @to.res.join
132
+ end
133
+
134
+ def accept_list_start_label
135
+ assert_equal [:LABEL], @to.list
136
+ assert_equal [false], @to.in_list_entry
137
+
138
+ assert_equal "<dl>\n", @to.res.join
139
+ end
140
+
141
+ def accept_list_start_lalpha
142
+ assert_equal [:LALPHA], @to.list
143
+ assert_equal [false], @to.in_list_entry
144
+
145
+ assert_equal "<ol style=\"display: lower-alpha\">\n", @to.res.join
146
+ end
147
+
148
+ def accept_list_start_note
149
+ assert_equal [:NOTE], @to.list
150
+ assert_equal [false], @to.in_list_entry
151
+
152
+ assert_equal "<table>\n", @to.res.join
153
+ end
154
+
155
+ def accept_list_start_number
156
+ assert_equal [:NUMBER], @to.list
157
+ assert_equal [false], @to.in_list_entry
158
+
159
+ assert_equal "<ol>\n", @to.res.join
160
+ end
161
+
162
+ def accept_list_start_ualpha
163
+ assert_equal [:UALPHA], @to.list
164
+ assert_equal [false], @to.in_list_entry
165
+
166
+ assert_equal "<ol style=\"display: upper-alpha\">\n", @to.res.join
167
+ end
168
+
169
+ def accept_paragraph
170
+ assert_equal "<p>\nhi\n</p>\n", @to.res.join
171
+ end
172
+
173
+ def accept_rule
174
+ assert_equal '<hr style="height: 4px"></hr>', @to.res.join
175
+ end
176
+
177
+ def accept_verbatim
178
+ assert_equal "<pre>\n hi\n world\n</pre>\n", @to.res.join
179
+ end
180
+
181
+ def end_accepting
182
+ assert_equal 'hi', @to.end_accepting
183
+ end
184
+
185
+ def start_accepting
186
+ assert_equal [], @to.res
187
+ assert_equal [], @to.in_list_entry
188
+ assert_equal [], @to.list
189
+ end
190
+
27
191
  def test_list_verbatim
28
192
  str = "* one\n verb1\n verb2\n* two\n"
29
193
 
30
194
  expected = <<-EXPECTED
31
195
  <ul>
32
- <li>one
33
-
196
+ <li><p>
197
+ one
198
+ </p>
34
199
  <pre>
35
200
  verb1
36
201
  verb2
37
202
  </pre>
38
203
  </li>
39
- <li>two
40
-
204
+ <li><p>
205
+ two
206
+ </p>
41
207
  </li>
42
208
  </ul>
43
209
  EXPECTED
44
210
 
45
- assert_equal expected, @m.convert(str, @th)
211
+ assert_equal expected, @m.convert(str, @to)
46
212
  end
47
213
 
48
214
  def test_tt_formatting
@@ -64,18 +230,17 @@ class TestRDocMarkupToHtml < MiniTest::Unit::TestCase
64
230
  assert_equal "<p>\ncat&#8217;s-\n</p>\n", util_format("cat\'s-")
65
231
  end
66
232
 
67
- def util_fragment(text)
68
- RDoc::Markup::Fragment.new 0, nil, nil, text
233
+ def util_paragraph(text)
234
+ RDoc::Markup::Paragraph.new text
69
235
  end
70
236
 
71
237
  def util_format(text)
72
- fragment = util_fragment text
238
+ paragraph = util_paragraph text
73
239
 
74
- @th.start_accepting
75
- @th.accept_paragraph @am, fragment
76
- @th.end_accepting
240
+ @to.start_accepting
241
+ @to.accept_paragraph paragraph
242
+ @to.end_accepting
77
243
  end
78
244
 
79
245
  end
80
246
 
81
- MiniTest::Unit.autorun
@@ -1,5 +1,5 @@
1
1
  require 'rubygems'
2
- require 'minitest/unit'
2
+ require 'minitest/autorun'
3
3
  require 'rdoc/rdoc'
4
4
  require 'rdoc/code_objects'
5
5
  require 'rdoc/markup/to_html_crossref'
@@ -157,5 +157,3 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
157
157
 
158
158
  end
159
159
 
160
- MiniTest::Unit.autorun
161
-
@@ -0,0 +1,426 @@
1
+ require 'rubygems'
2
+ require 'rdoc/markup/formatter_test_case'
3
+ require 'rdoc/markup/to_rdoc'
4
+ require 'minitest/autorun'
5
+
6
+ class TestRDocMarkupToRdoc < RDoc::Markup::FormatterTestCase
7
+
8
+ add_visitor_tests
9
+
10
+ def setup
11
+ super
12
+
13
+ @to = RDoc::Markup::ToRdoc.new
14
+ end
15
+
16
+ def accept_blank_line
17
+ assert_equal "\n", @to.res.join
18
+ end
19
+
20
+ def accept_heading
21
+ assert_equal "===== Hello\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 "\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 "\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 [""], @to.res
91
+ assert_equal '* ', @to.prefix
92
+ end
93
+
94
+ def accept_list_item_start_label
95
+ assert_equal [""], @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 [""], @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 [""], @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 [""], @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 [""], @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 "", @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 "", @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 "", @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 "", @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 "", @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 "", @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 "hi\n", @to.res.join
176
+ end
177
+
178
+ def accept_rule
179
+ assert_equal "#{'-' * 78}\n", @to.res.join
180
+ end
181
+
182
+ def accept_verbatim # FormatterTestCase doesn't set indent for ToAnsi
183
+ assert_equal " hi\n world\n\n", @to.res.join
184
+ end
185
+
186
+ def end_accepting
187
+ assert_equal "hi", @to.end_accepting
188
+ end
189
+
190
+ def start_accepting
191
+ assert_equal 0, @to.indent
192
+ assert_equal [""], @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 "= Hello\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 "== Hello\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 "=== Hello\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 "==== Hello\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 " = Hello\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 " = <b>Hello</b>\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 = "<tt>teletype</tt>:\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 = "reg <b>bold words</b> 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 = "reg <em>italic words</em> 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
+ 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 = "regular <tt>teletype</tt> 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 = "regular <b>bold</b> 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 = "regular <em>italic</em> 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
+ words 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 " #{'-' * 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 " 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 " 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
+ * 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
+ * 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
+