rdoc 3.9.5 → 3.10.pre.1

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 (183) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.autotest +6 -3
  3. data/History.txt +63 -13
  4. data/LICENSE.rdoc +57 -0
  5. data/Manifest.txt +60 -6
  6. data/Rakefile +24 -12
  7. data/TODO.rdoc +30 -0
  8. data/bin/rdoc +0 -2
  9. data/lib/rdoc.rb +55 -2
  10. data/lib/rdoc/alias.rb +0 -2
  11. data/lib/rdoc/anon_class.rb +0 -2
  12. data/lib/rdoc/any_method.rb +0 -3
  13. data/lib/rdoc/attr.rb +0 -2
  14. data/lib/rdoc/class_module.rb +40 -7
  15. data/lib/rdoc/code_object.rb +1 -3
  16. data/lib/rdoc/code_objects.rb +3 -21
  17. data/lib/rdoc/comment.rb +225 -0
  18. data/lib/rdoc/constant.rb +0 -2
  19. data/lib/rdoc/context.rb +37 -120
  20. data/lib/rdoc/context/section.rb +114 -0
  21. data/lib/rdoc/cross_reference.rb +16 -7
  22. data/lib/rdoc/encoding.rb +0 -2
  23. data/lib/rdoc/gauntlet.rb +1 -1
  24. data/lib/rdoc/generator.rb +7 -2
  25. data/lib/rdoc/generator/darkfish.rb +126 -20
  26. data/lib/rdoc/generator/json_index.rb +240 -0
  27. data/lib/rdoc/generator/markup.rb +17 -54
  28. data/lib/rdoc/generator/ri.rb +0 -3
  29. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +5 -0
  30. data/lib/rdoc/generator/template/darkfish/_head.rhtml +16 -0
  31. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +18 -0
  32. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +9 -0
  33. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +8 -0
  34. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +16 -0
  35. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +12 -0
  36. data/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +7 -0
  37. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +12 -0
  38. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +10 -0
  39. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +10 -0
  40. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +10 -0
  41. data/lib/rdoc/generator/template/darkfish/class.rhtml +161 -0
  42. data/lib/rdoc/generator/template/darkfish/fileinfo.rhtml +32 -0
  43. data/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
  44. data/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
  45. data/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
  46. data/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
  47. data/lib/rdoc/generator/template/darkfish/index.rhtml +16 -61
  48. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +99 -64
  49. data/lib/rdoc/generator/template/darkfish/js/jquery.js +15 -29
  50. data/lib/rdoc/generator/template/darkfish/js/search.js +94 -0
  51. data/lib/rdoc/generator/template/darkfish/page.rhtml +16 -0
  52. data/lib/rdoc/generator/template/darkfish/rdoc.css +126 -286
  53. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +50 -0
  54. data/lib/rdoc/generator/template/json_index/js/navigation.js +142 -0
  55. data/lib/rdoc/generator/template/json_index/js/searcher.js +228 -0
  56. data/lib/rdoc/ghost_method.rb +0 -2
  57. data/lib/rdoc/include.rb +0 -2
  58. data/lib/rdoc/markup.rb +204 -43
  59. data/lib/rdoc/markup/attr_changer.rb +25 -0
  60. data/lib/rdoc/markup/attr_span.rb +29 -0
  61. data/lib/rdoc/markup/attribute.rb +51 -0
  62. data/lib/rdoc/markup/document.rb +22 -1
  63. data/lib/rdoc/markup/formatter.rb +4 -11
  64. data/lib/rdoc/markup/formatter_test_case.rb +1 -2
  65. data/lib/rdoc/markup/heading.rb +44 -0
  66. data/lib/rdoc/markup/include.rb +42 -0
  67. data/lib/rdoc/markup/inline.rb +1 -144
  68. data/lib/rdoc/markup/list.rb +2 -1
  69. data/lib/rdoc/markup/parser.rb +6 -16
  70. data/lib/rdoc/markup/pre_process.rb +64 -10
  71. data/lib/rdoc/markup/raw.rb +1 -1
  72. data/lib/rdoc/markup/special.rb +40 -0
  73. data/lib/rdoc/markup/text_formatter_test_case.rb +0 -2
  74. data/lib/rdoc/markup/to_ansi.rb +0 -2
  75. data/lib/rdoc/markup/to_bs.rb +0 -2
  76. data/lib/rdoc/markup/to_html.rb +102 -34
  77. data/lib/rdoc/markup/to_html_crossref.rb +36 -5
  78. data/lib/rdoc/markup/to_html_snippet.rb +270 -0
  79. data/lib/rdoc/markup/to_label.rb +55 -0
  80. data/lib/rdoc/markup/to_rdoc.rb +0 -3
  81. data/lib/rdoc/markup/to_table_of_contents.rb +62 -0
  82. data/lib/rdoc/markup/to_test.rb +0 -3
  83. data/lib/rdoc/markup/to_tt_only.rb +0 -3
  84. data/lib/rdoc/markup/verbatim.rb +18 -0
  85. data/lib/rdoc/meta_method.rb +0 -2
  86. data/lib/rdoc/method_attr.rb +17 -1
  87. data/lib/rdoc/normal_class.rb +0 -2
  88. data/lib/rdoc/normal_module.rb +0 -2
  89. data/lib/rdoc/options.rb +18 -3
  90. data/lib/rdoc/parser.rb +74 -42
  91. data/lib/rdoc/parser/c.rb +79 -118
  92. data/lib/rdoc/parser/rd.rb +22 -0
  93. data/lib/rdoc/parser/ruby.rb +86 -54
  94. data/lib/rdoc/parser/simple.rb +21 -9
  95. data/lib/rdoc/parser/text.rb +11 -0
  96. data/lib/rdoc/rd.rb +95 -0
  97. data/lib/rdoc/rd/block_parser.ry +638 -0
  98. data/lib/rdoc/rd/inline.rb +71 -0
  99. data/lib/rdoc/rd/inline_parser.ry +575 -0
  100. data/lib/rdoc/rdoc.rb +8 -23
  101. data/lib/rdoc/require.rb +0 -2
  102. data/lib/rdoc/ri.rb +4 -2
  103. data/lib/rdoc/ri/driver.rb +2 -6
  104. data/lib/rdoc/ri/store.rb +0 -1
  105. data/lib/rdoc/ruby_lex.rb +43 -20
  106. data/lib/rdoc/ruby_token.rb +44 -2
  107. data/lib/rdoc/single_class.rb +0 -2
  108. data/lib/rdoc/stats.rb +0 -5
  109. data/lib/rdoc/task.rb +2 -6
  110. data/lib/rdoc/test_case.rb +59 -0
  111. data/lib/rdoc/text.rb +42 -30
  112. data/lib/rdoc/token_stream.rb +45 -0
  113. data/lib/rdoc/tom_doc.rb +232 -0
  114. data/lib/rdoc/top_level.rb +36 -4
  115. data/test/test_attribute_manager.rb +26 -29
  116. data/test/test_rdoc_any_method.rb +2 -26
  117. data/test/test_rdoc_attr.rb +4 -4
  118. data/test/test_rdoc_class_module.rb +95 -12
  119. data/test/test_rdoc_code_object.rb +10 -3
  120. data/test/test_rdoc_comment.rb +504 -0
  121. data/test/test_rdoc_context.rb +60 -11
  122. data/test/test_rdoc_context_section.rb +16 -17
  123. data/test/test_rdoc_cross_reference.rb +17 -2
  124. data/test/test_rdoc_encoding.rb +4 -7
  125. data/test/test_rdoc_generator_darkfish.rb +12 -11
  126. data/test/test_rdoc_generator_json_index.rb +255 -0
  127. data/test/test_rdoc_generator_markup.rb +56 -0
  128. data/test/test_rdoc_generator_ri.rb +8 -11
  129. data/test/test_rdoc_markup.rb +9 -5
  130. data/test/test_rdoc_markup_attribute_manager.rb +5 -8
  131. data/test/test_rdoc_markup_document.rb +34 -6
  132. data/test/test_rdoc_markup_formatter.rb +11 -13
  133. data/test/test_rdoc_markup_heading.rb +20 -0
  134. data/test/test_rdoc_markup_include.rb +19 -0
  135. data/test/test_rdoc_markup_indented_paragraph.rb +4 -5
  136. data/test/test_rdoc_markup_paragraph.rb +2 -5
  137. data/test/test_rdoc_markup_parser.rb +87 -7
  138. data/test/test_rdoc_markup_pre_process.rb +60 -9
  139. data/test/test_rdoc_markup_raw.rb +4 -6
  140. data/test/test_rdoc_markup_to_ansi.rb +1 -4
  141. data/test/test_rdoc_markup_to_bs.rb +1 -4
  142. data/test/test_rdoc_markup_to_html.rb +170 -31
  143. data/test/test_rdoc_markup_to_html_crossref.rb +89 -11
  144. data/test/test_rdoc_markup_to_html_snippet.rb +668 -0
  145. data/test/test_rdoc_markup_to_label.rb +50 -0
  146. data/test/test_rdoc_markup_to_rdoc.rb +1 -4
  147. data/test/test_rdoc_markup_to_table_of_contents.rb +90 -0
  148. data/test/test_rdoc_markup_to_tt_only.rb +1 -4
  149. data/test/test_rdoc_markup_verbatim.rb +16 -0
  150. data/test/test_rdoc_method_attr.rb +16 -1
  151. data/test/test_rdoc_options.rb +17 -7
  152. data/test/test_rdoc_parser.rb +75 -6
  153. data/test/test_rdoc_parser_c.rb +56 -104
  154. data/test/test_rdoc_parser_rd.rb +52 -0
  155. data/test/test_rdoc_parser_ruby.rb +264 -323
  156. data/test/test_rdoc_parser_simple.rb +33 -17
  157. data/test/test_rdoc_rd.rb +30 -0
  158. data/test/test_rdoc_rd_block_parser.rb +527 -0
  159. data/test/test_rdoc_rd_inline.rb +63 -0
  160. data/test/test_rdoc_rd_inline_parser.rb +173 -0
  161. data/test/test_rdoc_rdoc.rb +7 -9
  162. data/test/test_rdoc_ri_driver.rb +10 -15
  163. data/test/test_rdoc_ri_paths.rb +6 -6
  164. data/test/test_rdoc_ri_store.rb +6 -13
  165. data/test/test_rdoc_ruby_lex.rb +53 -5
  166. data/test/test_rdoc_rubygems_hook.rb +2 -1
  167. data/test/test_rdoc_stats.rb +83 -103
  168. data/test/test_rdoc_task.rb +5 -4
  169. data/test/test_rdoc_text.rb +156 -11
  170. data/test/test_rdoc_token_stream.rb +42 -0
  171. data/test/test_rdoc_tom_doc.rb +458 -0
  172. data/test/test_rdoc_top_level.rb +49 -2
  173. data/test/xref_test_case.rb +4 -8
  174. metadata +217 -111
  175. metadata.gz.sig +0 -0
  176. checksums.yaml +0 -7
  177. checksums.yaml.gz.sig +0 -0
  178. data/CVE-2013-0256.rdoc +0 -49
  179. data/LICENSE.txt +0 -57
  180. data/lib/rdoc/generator/template/darkfish/classpage.rhtml +0 -321
  181. data/lib/rdoc/generator/template/darkfish/filepage.rhtml +0 -124
  182. data/lib/rdoc/generator/template/darkfish/js/quicksearch.js +0 -114
  183. data/lib/rdoc/generator/template/darkfish/js/thickbox-compressed.js +0 -10
@@ -1,12 +1,10 @@
1
- require 'tempfile'
2
- require 'rubygems'
3
- require 'minitest/autorun'
4
- require 'rdoc/options'
5
- require 'rdoc/parser'
1
+ require 'rdoc/test_case'
6
2
 
7
- class TestRDocParserSimple < MiniTest::Unit::TestCase
3
+ class TestRDocParserSimple < RDoc::TestCase
8
4
 
9
5
  def setup
6
+ super
7
+
10
8
  @tempfile = Tempfile.new self.class.name
11
9
  filename = @tempfile.path
12
10
 
@@ -14,11 +12,11 @@ class TestRDocParserSimple < MiniTest::Unit::TestCase
14
12
  @fn = filename
15
13
  @options = RDoc::Options.new
16
14
  @stats = RDoc::Stats.new 0
17
-
18
- RDoc::TopLevel.reset
19
15
  end
20
16
 
21
17
  def teardown
18
+ super
19
+
22
20
  @tempfile.close
23
21
  end
24
22
 
@@ -45,7 +43,7 @@ Regular expressions (<i>regexp</i>s) are patterns which describe the
45
43
  contents of a string.
46
44
  TEXT
47
45
 
48
- assert_equal expected, @top_level.comment
46
+ assert_equal expected, @top_level.comment.text
49
47
  end
50
48
 
51
49
  # RDoc stops processing comments if it finds a comment line CONTAINING
@@ -74,21 +72,39 @@ contents of a string.
74
72
  # # ---
75
73
 
76
74
  def test_remove_private_comments
77
- parser = util_parser ''
78
- text = "foo\n\n--\nbar\n++\n\nbaz\n"
75
+ parser = util_parser "foo\n\n--\nbar\n++\n\nbaz\n"
76
+
77
+ parser.scan
79
78
 
80
- expected = "foo\n\n\n\nbaz\n"
79
+ expected = "foo\n\n\nbaz"
81
80
 
82
- assert_equal expected, parser.remove_private_comments(text)
81
+ assert_equal expected, @top_level.comment.text
82
+ end
83
+
84
+ def test_remove_private_comments_rule
85
+ parser = util_parser "foo\n---\nbar"
86
+
87
+ parser.scan
88
+
89
+ expected = "foo\n---\nbar"
90
+
91
+ assert_equal expected, @top_level.comment.text
83
92
  end
84
93
 
85
94
  def test_remove_private_comments_star
86
- parser = util_parser ''
95
+ parser = util_parser "* foo\n* bar\n"
96
+
97
+ parser.scan
87
98
 
88
- text = "* foo\n* bar\n"
89
- expected = text.dup
99
+ assert_equal "* foo\n* bar", @top_level.comment.text
100
+ end
101
+
102
+ def test_scan
103
+ parser = util_parser 'it *really* works'
104
+
105
+ parser.scan
90
106
 
91
- assert_equal expected, parser.remove_private_comments(text)
107
+ assert_equal 'it *really* works', @top_level.comment.text
92
108
  end
93
109
 
94
110
  def util_parser(content)
@@ -0,0 +1,30 @@
1
+ require 'rdoc/test_case'
2
+
3
+ class TestRDocRd < RDoc::TestCase
4
+
5
+ def test_class_parse
6
+ expected =
7
+ @RM::Document.new(
8
+ @RM::Paragraph.new('hello'))
9
+
10
+ assert_equal expected, RDoc::RD.parse("hello")
11
+ end
12
+
13
+ def test_class_parse_begin_end
14
+ expected =
15
+ @RM::Document.new(
16
+ @RM::Paragraph.new('hello'))
17
+
18
+ assert_equal expected, RDoc::RD.parse("=begin\nhello\n=end\n")
19
+ end
20
+
21
+ def test_class_parse_newline
22
+ expected =
23
+ @RM::Document.new(
24
+ @RM::Paragraph.new('hello'))
25
+
26
+ assert_equal expected, RDoc::RD.parse("hello\n")
27
+ end
28
+
29
+ end
30
+
@@ -0,0 +1,527 @@
1
+ require 'rdoc/test_case'
2
+
3
+ class TestRDocRdBlockParser < RDoc::TestCase
4
+
5
+ def setup
6
+ super
7
+
8
+ @block_parser = RDoc::RD::BlockParser.new
9
+ end
10
+
11
+ def mu_pp(obj)
12
+ s = ""
13
+ s = PP.pp obj, s
14
+ s = s.force_encoding(Encoding.default_external) if defined? Encoding
15
+ s.chomp
16
+ end
17
+
18
+ def test_parse_desclist
19
+ list = <<-LIST
20
+ :one
21
+ desc one
22
+ :two
23
+ desc two
24
+ LIST
25
+
26
+ expected =
27
+ doc(
28
+ @RM::List.new(:NOTE,
29
+ @RM::ListItem.new("one", @RM::Paragraph.new("desc one")),
30
+ @RM::ListItem.new("two", @RM::Paragraph.new("desc two"))))
31
+
32
+ assert_equal expected, parse(list)
33
+ end
34
+
35
+ def test_parse_enumlist
36
+ list = <<-LIST
37
+ (1) one
38
+ (1) two
39
+ LIST
40
+
41
+ expected =
42
+ doc(
43
+ @RM::List.new(:NUMBER,
44
+ @RM::ListItem.new(nil, @RM::Paragraph.new("one")),
45
+ @RM::ListItem.new(nil, @RM::Paragraph.new("two"))))
46
+
47
+ assert_equal expected, parse(list)
48
+ end
49
+
50
+ def test_parse_enumlist_paragraphs
51
+ list = <<-LIST
52
+ (1) one
53
+
54
+ two
55
+ LIST
56
+
57
+ expected =
58
+ doc(
59
+ @RM::List.new(:NUMBER,
60
+ @RM::ListItem.new(nil,
61
+ @RM::Paragraph.new("one"),
62
+ @RM::Paragraph.new("two"))))
63
+
64
+ assert_equal expected, parse(list)
65
+ end
66
+
67
+ def test_parse_enumlist_multiline
68
+ list = <<-LIST
69
+ (1) one
70
+ two
71
+ LIST
72
+
73
+ contents = "one\n two" # 1.8 vs 1.9
74
+
75
+ expected =
76
+ doc(
77
+ @RM::List.new(:NUMBER,
78
+ @RM::ListItem.new(nil, @RM::Paragraph.new(*contents))))
79
+
80
+ assert_equal expected, parse(list)
81
+ end
82
+
83
+ def test_parse_enumlist_verbatim
84
+ list = <<-LIST
85
+ (1) item
86
+ verbatim
87
+ LIST
88
+
89
+ expected =
90
+ doc(
91
+ @RM::List.new(:NUMBER,
92
+ @RM::ListItem.new(nil,
93
+ @RM::Paragraph.new("item"),
94
+ @RM::Verbatim.new("verbatim\n"))))
95
+
96
+ assert_equal expected, parse(list)
97
+ end
98
+
99
+ def test_parse_enumlist_verbatim_continue
100
+ list = <<-LIST
101
+ (1) one
102
+ verbatim
103
+ two
104
+ LIST
105
+
106
+ expected =
107
+ doc(
108
+ @RM::List.new(:NUMBER,
109
+ @RM::ListItem.new(nil,
110
+ @RM::Paragraph.new("one"),
111
+ @RM::Verbatim.new("verbatim\n"),
112
+ @RM::Paragraph.new("two"))))
113
+
114
+ assert_equal expected, parse(list)
115
+ end
116
+
117
+ def test_parse_footnote
118
+ expected =
119
+ doc(
120
+ @RM::Paragraph.new("{*1}[rdoc-label:foottext-1:footmark-1]"),
121
+ @RM::Rule.new(1),
122
+ @RM::Paragraph.new("{^1}[rdoc-label:footmark-1:foottext-1]", "text"))
123
+
124
+ assert_equal expected, parse("((-text-))")
125
+ end
126
+
127
+ def test_parse_include
128
+ @block_parser.include_path = [Dir.tmpdir]
129
+
130
+ expected = doc(@RM::Include.new("parse_include", [Dir.tmpdir]))
131
+
132
+ assert_equal expected, parse("<<< parse_include")
133
+ end
134
+
135
+ def test_parse_include_subtree
136
+ @block_parser.include_path = [Dir.tmpdir]
137
+
138
+ expected =
139
+ doc(
140
+ @RM::BlankLine.new,
141
+ @RM::Paragraph.new("include <em>worked</em>"),
142
+ @RM::BlankLine.new,
143
+ @RM::BlankLine.new)
144
+
145
+ Tempfile.open %w[parse_include .rd] do |io|
146
+ io.puts "=begin\ninclude ((*worked*))\n=end"
147
+ io.flush
148
+
149
+ str = <<-STR
150
+ <<< #{File.basename io.path}
151
+ STR
152
+
153
+ assert_equal expected, parse(str)
154
+ end
155
+ end
156
+
157
+ def test_parse_heading
158
+ assert_equal doc(@RM::Heading.new(1, "H")), parse("= H")
159
+ assert_equal doc(@RM::Heading.new(2, "H")), parse("== H")
160
+ assert_equal doc(@RM::Heading.new(3, "H")), parse("=== H")
161
+ assert_equal doc(@RM::Heading.new(4, "H")), parse("==== H")
162
+ assert_equal doc(@RM::Heading.new(5, "H")), parse("+ H")
163
+ assert_equal doc(@RM::Heading.new(6, "H")), parse("++ H")
164
+ end
165
+
166
+ def test_parse_itemlist
167
+ list = <<-LIST
168
+ * one
169
+ * two
170
+ LIST
171
+
172
+ expected =
173
+ doc(
174
+ @RM::List.new(:BULLET,
175
+ @RM::ListItem.new(nil, @RM::Paragraph.new("one")),
176
+ @RM::ListItem.new(nil, @RM::Paragraph.new("two"))))
177
+
178
+ assert_equal expected, parse(list)
179
+ end
180
+
181
+ def test_parse_itemlist_multiline
182
+ list = <<-LIST
183
+ * one
184
+ two
185
+ LIST
186
+
187
+ contents = "one\n two" # 1.8 vs 1.9
188
+
189
+ expected =
190
+ doc(
191
+ @RM::List.new(:BULLET,
192
+ @RM::ListItem.new(nil, @RM::Paragraph.new(*contents))))
193
+
194
+ assert_equal expected, parse(list)
195
+ end
196
+
197
+ def test_parse_itemlist_nest
198
+ list = <<-LIST
199
+ * one
200
+ * inner
201
+ * two
202
+ LIST
203
+
204
+ expected =
205
+ doc(
206
+ @RM::List.new(:BULLET,
207
+ @RM::ListItem.new(nil,
208
+ @RM::Paragraph.new("one"),
209
+ @RM::List.new(:BULLET,
210
+ @RM::ListItem.new(nil, @RM::Paragraph.new("inner")))),
211
+ @RM::ListItem.new(nil,
212
+ @RM::Paragraph.new("two"))))
213
+
214
+ assert_equal expected, parse(list)
215
+ end
216
+
217
+ def test_parse_itemlist_paragraphs
218
+ list = <<-LIST
219
+ * one
220
+
221
+ two
222
+ LIST
223
+
224
+ expected =
225
+ doc(
226
+ @RM::List.new(:BULLET,
227
+ @RM::ListItem.new(nil,
228
+ @RM::Paragraph.new("one"),
229
+ @RM::Paragraph.new("two"))))
230
+
231
+ assert_equal expected, parse(list)
232
+ end
233
+
234
+ def test_parse_itemlist_verbatim
235
+ list = <<-LIST
236
+ * item
237
+ verbatim
238
+ LIST
239
+
240
+ expected =
241
+ doc(
242
+ @RM::List.new(:BULLET,
243
+ @RM::ListItem.new(nil,
244
+ @RM::Paragraph.new("item"),
245
+ @RM::Verbatim.new("verbatim\n"))))
246
+
247
+ assert_equal expected, parse(list)
248
+ end
249
+
250
+ def test_parse_itemlist_verbatim_continue
251
+ list = <<-LIST
252
+ * one
253
+ verbatim
254
+ two
255
+ LIST
256
+
257
+ expected =
258
+ doc(
259
+ @RM::List.new(:BULLET,
260
+ @RM::ListItem.new(nil,
261
+ @RM::Paragraph.new("one"),
262
+ @RM::Verbatim.new("verbatim\n"),
263
+ @RM::Paragraph.new("two"))))
264
+
265
+ assert_equal expected, parse(list)
266
+ end
267
+
268
+ def test_parse_lists
269
+ list = <<-LIST
270
+ (1) one
271
+ (1) two
272
+ * three
273
+ * four
274
+ (1) five
275
+ (1) six
276
+ LIST
277
+
278
+ expected =
279
+ doc(
280
+ @RM::List.new(:NUMBER,
281
+ @RM::ListItem.new(nil, @RM::Paragraph.new("one")),
282
+ @RM::ListItem.new(nil, @RM::Paragraph.new("two"))),
283
+ @RM::List.new(:BULLET,
284
+ @RM::ListItem.new(nil, @RM::Paragraph.new("three")),
285
+ @RM::ListItem.new(nil, @RM::Paragraph.new("four"))),
286
+ @RM::List.new(:NUMBER,
287
+ @RM::ListItem.new(nil, @RM::Paragraph.new("five")),
288
+ @RM::ListItem.new(nil, @RM::Paragraph.new("six"))))
289
+
290
+ assert_equal expected, parse(list)
291
+ end
292
+
293
+ def test_parse_lists_nest
294
+ list = <<-LIST
295
+ (1) one
296
+ (1) two
297
+ * three
298
+ * four
299
+ (1) five
300
+ (1) six
301
+ LIST
302
+
303
+ expected =
304
+ doc(
305
+ @RM::List.new(:NUMBER,
306
+ @RM::ListItem.new(nil, @RM::Paragraph.new("one")),
307
+ @RM::ListItem.new(nil,
308
+ @RM::Paragraph.new("two"),
309
+ @RM::List.new(:BULLET,
310
+ @RM::ListItem.new(nil, @RM::Paragraph.new("three")),
311
+ @RM::ListItem.new(nil, @RM::Paragraph.new("four")))),
312
+ @RM::ListItem.new(nil, @RM::Paragraph.new("five")),
313
+ @RM::ListItem.new(nil, @RM::Paragraph.new("six"))))
314
+
315
+ assert_equal expected, parse(list)
316
+ end
317
+
318
+ def test_parse_lists_nest_verbatim
319
+ list = <<-LIST
320
+ (1) one
321
+ (1) two
322
+ * three
323
+ * four
324
+ verbatim
325
+ (1) five
326
+ (1) six
327
+ LIST
328
+
329
+ expected =
330
+ doc(
331
+ @RM::List.new(:NUMBER,
332
+ @RM::ListItem.new(nil, @RM::Paragraph.new("one")),
333
+ @RM::ListItem.new(nil,
334
+ @RM::Paragraph.new("two"),
335
+ @RM::List.new(:BULLET,
336
+ @RM::ListItem.new(nil, @RM::Paragraph.new("three")),
337
+ @RM::ListItem.new(nil, @RM::Paragraph.new("four"))),
338
+ @RM::Verbatim.new("verbatim\n")),
339
+ @RM::ListItem.new(nil, @RM::Paragraph.new("five")),
340
+ @RM::ListItem.new(nil, @RM::Paragraph.new("six"))))
341
+
342
+ assert_equal expected, parse(list)
343
+ end
344
+
345
+ def test_parse_lists_nest_verbatim2
346
+ list = <<-LIST
347
+ (1) one
348
+ (1) two
349
+ * three
350
+ * four
351
+ verbatim
352
+ (1) five
353
+ (1) six
354
+ LIST
355
+
356
+ expected =
357
+ doc(
358
+ @RM::List.new(:NUMBER,
359
+ @RM::ListItem.new(nil, @RM::Paragraph.new("one")),
360
+ @RM::ListItem.new(nil,
361
+ @RM::Paragraph.new("two"),
362
+ @RM::List.new(:BULLET,
363
+ @RM::ListItem.new(nil, @RM::Paragraph.new("three")),
364
+ @RM::ListItem.new(nil, @RM::Paragraph.new("four"))),
365
+ @RM::Verbatim.new("verbatim\n")),
366
+ @RM::ListItem.new(nil, @RM::Paragraph.new("five")),
367
+ @RM::ListItem.new(nil, @RM::Paragraph.new("six"))))
368
+
369
+ assert_equal expected, parse(list)
370
+ end
371
+
372
+ def test_parse_methodlist
373
+ list = <<-LIST
374
+ --- Array#each {|i| ... }
375
+ yield block for each item.
376
+ --- Array#index(val)
377
+ return index of first item which equals with val. if it hasn't
378
+ same item, return nil.
379
+ LIST
380
+
381
+ expected =
382
+ doc(
383
+ @RM::List.new(:LABEL,
384
+ @RM::ListItem.new(
385
+ "<tt>Array#each {|i| ... }</tt>",
386
+ @RM::Paragraph.new("yield block for each item.")),
387
+ @RM::ListItem.new(
388
+ "<tt>Array#index(val)</tt>",
389
+ @RM::Paragraph.new("return index of first item which equals with val. if it hasn't same item, return nil."))))
390
+
391
+ assert_equal expected, parse(list)
392
+ end
393
+
394
+ def test_parse_methodlist_empty
395
+ list = <<-LIST
396
+ --- A#b
397
+
398
+ LIST
399
+
400
+ expected =
401
+ doc(
402
+ @RM::List.new(:LABEL,
403
+ @RM::ListItem.new("<tt>A#b</tt>")))
404
+
405
+ assert_equal expected, parse(list)
406
+ end
407
+
408
+ def test_parse_methodlist_paragraph
409
+ list = <<-LIST
410
+ --- A#b
411
+
412
+ one
413
+ LIST
414
+
415
+ expected =
416
+ doc(
417
+ @RM::List.new(:LABEL,
418
+ @RM::ListItem.new(
419
+ "<tt>A#b</tt>",
420
+ @RM::Paragraph.new("one"))))
421
+
422
+ assert_equal expected, parse(list)
423
+ end
424
+
425
+ def test_parse_methodlist_paragraph2
426
+ list = <<-LIST.chomp
427
+ --- A#b
428
+
429
+ one
430
+ two
431
+ LIST
432
+
433
+ expected =
434
+ doc(
435
+ @RM::List.new(:LABEL,
436
+ @RM::ListItem.new(
437
+ "<tt>A#b</tt>",
438
+ @RM::Paragraph.new("one"))),
439
+ @RM::Paragraph.new("two"))
440
+
441
+ assert_equal expected, parse(list)
442
+ end
443
+
444
+ def test_parse_methodlist_paragraph_verbatim
445
+ list = <<-LIST.chomp
446
+ --- A#b
447
+
448
+ text
449
+ verbatim
450
+ LIST
451
+
452
+ expected =
453
+ doc(
454
+ @RM::List.new(:LABEL,
455
+ @RM::ListItem.new(
456
+ "<tt>A#b</tt>",
457
+ @RM::Paragraph.new("text"),
458
+ @RM::Verbatim.new("verbatim\n"))))
459
+
460
+ assert_equal expected, parse(list)
461
+ end
462
+
463
+ def test_parse_verbatim
464
+ assert_equal doc(@RM::Verbatim.new("verbatim\n")), parse(" verbatim")
465
+ end
466
+
467
+ def test_parse_verbatim_blankline
468
+ expected = doc(@RM::Verbatim.new("one\n", "\n", "two\n"))
469
+
470
+ verbatim = <<-VERBATIM
471
+ one
472
+
473
+ two
474
+ VERBATIM
475
+
476
+ assert_equal expected, parse(verbatim)
477
+ end
478
+
479
+ def test_parse_verbatim_indent
480
+ expected = doc(@RM::Verbatim.new("one\n", " two\n"))
481
+
482
+ verbatim = <<-VERBATIM
483
+ one
484
+ two
485
+ VERBATIM
486
+
487
+ assert_equal expected, parse(verbatim)
488
+ end
489
+
490
+ def test_parse_verbatim_multi
491
+ expected = doc(@RM::Verbatim.new("one\n", "two\n"))
492
+
493
+ verbatim = <<-VERBATIM
494
+ one
495
+ two
496
+ VERBATIM
497
+
498
+ assert_equal expected, parse(verbatim)
499
+ end
500
+
501
+ def test_parse_textblock
502
+ assert_equal doc(@RM::Paragraph.new("text")), parse("text")
503
+ end
504
+
505
+ def test_parse_textblock_multi
506
+ expected = doc(@RM::Paragraph.new("one two"))
507
+
508
+ assert_equal expected, parse("one\ntwo")
509
+ end
510
+
511
+ def doc *parts
512
+ @RM::Document.new(*parts)
513
+ end
514
+
515
+ def parse text
516
+ text = ["=begin", text, "=end"].join "\n"
517
+
518
+ doc = @block_parser.parse text.lines.to_a
519
+
520
+ assert_equal @RM::BlankLine.new, doc.parts.shift, "=begin blankline"
521
+ assert_equal @RM::BlankLine.new, doc.parts.pop, "=end blankline"
522
+
523
+ doc
524
+ end
525
+
526
+ end
527
+