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
@@ -0,0 +1,42 @@
1
+ require 'rdoc/test_case'
2
+
3
+ class TestRDocTokenStream < RDoc::TestCase
4
+
5
+ def test_class_to_html
6
+ tokens = [
7
+ RDoc::RubyToken::TkCONSTANT. new(0, 0, 0, 'CONSTANT'),
8
+ RDoc::RubyToken::TkDEF. new(0, 0, 0, 'KW'),
9
+ RDoc::RubyToken::TkIVAR. new(0, 0, 0, 'IVAR'),
10
+ RDoc::RubyToken::TkOp. new(0, 0, 0, 'Op'),
11
+ RDoc::RubyToken::TkId. new(0, 0, 0, 'Id'),
12
+ RDoc::RubyToken::TkNode. new(0, 0, 0, 'Node'),
13
+ RDoc::RubyToken::TkCOMMENT. new(0, 0, 0, 'COMMENT'),
14
+ RDoc::RubyToken::TkREGEXP. new(0, 0, 0, 'REGEXP'),
15
+ RDoc::RubyToken::TkSTRING. new(0, 0, 0, 'STRING'),
16
+ RDoc::RubyToken::TkVal. new(0, 0, 0, 'Val'),
17
+ RDoc::RubyToken::TkBACKSLASH.new(0, 0, 0, '\\'),
18
+ ]
19
+
20
+ expected = [
21
+ '<span class="ruby-constant">CONSTANT</span>',
22
+ '<span class="ruby-keyword">KW</span>',
23
+ '<span class="ruby-ivar">IVAR</span>',
24
+ '<span class="ruby-operator">Op</span>',
25
+ '<span class="ruby-identifier">Id</span>',
26
+ '<span class="ruby-node">Node</span>',
27
+ '<span class="ruby-comment">COMMENT</span>',
28
+ '<span class="ruby-regexp">REGEXP</span>',
29
+ '<span class="ruby-string">STRING</span>',
30
+ '<span class="ruby-value">Val</span>',
31
+ '\\'
32
+ ].join
33
+
34
+ assert_equal expected, RDoc::TokenStream.to_html(tokens)
35
+ end
36
+
37
+ def test_class_to_html_empty
38
+ assert_equal '', RDoc::TokenStream.to_html([])
39
+ end
40
+
41
+ end
42
+
@@ -0,0 +1,458 @@
1
+ require 'rdoc/test_case'
2
+
3
+ class TestRDocTomDoc < RDoc::TestCase
4
+
5
+ def setup
6
+ super
7
+
8
+ @top_level = RDoc::TopLevel.new 'file.rb'
9
+
10
+ @TD = RDoc::TomDoc
11
+ @td = @TD.new
12
+ end
13
+
14
+ def mu_pp obj
15
+ s = ''
16
+ s = PP.pp obj, s
17
+ s = s.force_encoding Encoding.default_external if defined? Encoding
18
+ s.chomp
19
+ end
20
+
21
+ def test_class_add_post_processor
22
+ RDoc::TomDoc.add_post_processor
23
+
24
+ pp = RDoc::Markup::PreProcess.new __FILE__, []
25
+
26
+ text = "# Public: Do some stuff\n"
27
+
28
+ comment = RDoc::Comment.new text, nil
29
+ comment.format = 'tomdoc'
30
+
31
+ parent = RDoc::Context.new
32
+
33
+ pp.handle comment, parent
34
+
35
+ method = parent.add_method RDoc::AnyMethod.new(nil, 'm')
36
+
37
+ assert_equal 'Public', method.section.title
38
+ assert_equal "# Do some stuff\n", comment.text
39
+ end
40
+
41
+ def test_class_signature
42
+ c = comment <<-COMMENT
43
+ Signature
44
+
45
+ method_<here>(args)
46
+
47
+ here - something
48
+ COMMENT
49
+ c.format = 'tomdoc'
50
+
51
+ signature = @TD.signature c
52
+
53
+ assert_equal "method_<here>(args)\n", signature
54
+ end
55
+
56
+ def test_class_signature_no_space
57
+ c = comment <<-COMMENT
58
+ Signature
59
+ method_<here>(args)
60
+
61
+ here - something
62
+ COMMENT
63
+ c.format = 'tomdoc'
64
+
65
+ signature = @TD.signature c
66
+
67
+ assert_equal "method_<here>(args)\n", signature
68
+
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'))))
75
+ expected.file = @top_level
76
+
77
+ assert_equal expected, c.parse
78
+ end
79
+
80
+ def test_class_signature_none
81
+ c = comment ''
82
+ c.format = 'tomdoc'
83
+
84
+ assert_nil @TD.signature c
85
+ end
86
+
87
+ def test_class_rdoc
88
+ c = comment <<-COMMENT
89
+ === Signature
90
+
91
+ method_<here>(args)
92
+
93
+ here - something
94
+ COMMENT
95
+ c.format = 'rdoc'
96
+
97
+ signature = @TD.signature c
98
+
99
+ assert_nil signature
100
+ end
101
+
102
+ def test_class_signature_two_space
103
+ c = comment <<-COMMENT
104
+ Signature
105
+
106
+
107
+ method_<here>(args)
108
+
109
+ here - something
110
+ COMMENT
111
+ c.format = 'tomdoc'
112
+
113
+ signature = @TD.signature c
114
+
115
+ assert_equal "method_<here>(args)\n", signature
116
+
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'))))
123
+ expected.file = @top_level
124
+
125
+ assert_equal expected, c.parse
126
+ end
127
+
128
+ def test_parse_paragraph
129
+ text = "Public: Do some stuff\n"
130
+
131
+ expected =
132
+ @RM::Document.new(
133
+ @RM::Paragraph.new('Do some stuff'))
134
+
135
+ assert_equal expected, @TD.parse(text)
136
+ end
137
+
138
+ def test_parse_arguments
139
+ text = <<-TEXT
140
+ Create new Arg object.
141
+
142
+ name - name of argument
143
+ description - arguments description
144
+ TEXT
145
+
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'))))
158
+
159
+ assert_equal expected, @TD.parse(text)
160
+ end
161
+
162
+ def test_parse_arguments_multiline
163
+ text = <<-TEXT
164
+ Do some stuff
165
+
166
+ foo - A comment goes here
167
+ and is more than one line
168
+ TEXT
169
+
170
+ 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'))))
180
+
181
+ assert_equal expected, @TD.parse(text)
182
+ end
183
+
184
+ def test_parse_arguments_nested
185
+ text = <<-TEXT
186
+ Do some stuff
187
+
188
+ foo - A comment goes here
189
+ :bar - bar documentation
190
+ TEXT
191
+
192
+ 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'))))))
206
+
207
+ assert_equal expected, @TD.parse(text)
208
+ end
209
+
210
+ def test_parse_examples
211
+ text = <<-TEXT
212
+ Do some stuff
213
+
214
+ Examples
215
+
216
+ 1 + 1
217
+ TEXT
218
+
219
+ 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"))
226
+
227
+ document = @TD.parse(text)
228
+ assert_equal expected, document
229
+ assert document.parts.last.ruby?
230
+ end
231
+
232
+ def test_parse_examples_signature
233
+ text = <<-TEXT
234
+ Do some stuff
235
+
236
+ Examples
237
+
238
+ 1 + 1
239
+
240
+ Signature
241
+
242
+ foo(args)
243
+ TEXT
244
+
245
+ 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"))
255
+
256
+ document = @TD.parse(text)
257
+ assert_equal expected, document
258
+ assert document.parts[4].ruby?
259
+ refute document.parts.last.ruby?
260
+ end
261
+
262
+ def test_parse_returns
263
+ text = <<-TEXT
264
+ Do some stuff
265
+
266
+ Returns a thing
267
+ TEXT
268
+
269
+ expected =
270
+ @RM::Document.new(
271
+ @RM::Paragraph.new('Do some stuff'),
272
+ @RM::BlankLine.new,
273
+ @RM::Paragraph.new('Returns a thing'))
274
+
275
+ assert_equal expected, @TD.parse(text)
276
+ end
277
+
278
+ def test_parse_returns_multiline
279
+ text = <<-TEXT
280
+ Do some stuff
281
+
282
+ Returns a thing
283
+ that is multiline
284
+ TEXT
285
+
286
+ expected =
287
+ @RM::Document.new(
288
+ @RM::Paragraph.new('Do some stuff'),
289
+ @RM::BlankLine.new,
290
+ @RM::Paragraph.new('Returns a thing', 'that is multiline'))
291
+
292
+ assert_equal expected, @TD.parse(text)
293
+ end
294
+
295
+ def test_parse_signature
296
+ text = <<-TEXT
297
+ Do some stuff
298
+
299
+ Signature
300
+
301
+ some_method(args)
302
+ TEXT
303
+
304
+ expected =
305
+ @RM::Document.new(
306
+ @RM::Paragraph.new('Do some stuff'),
307
+ @RM::BlankLine.new,
308
+ @RM::Heading.new(3, 'Signature'),
309
+ @RM::BlankLine.new,
310
+ @RM::Verbatim.new("some_method(args)\n"))
311
+
312
+ assert_equal expected, @TD.parse(text)
313
+ end
314
+
315
+ def test_tokenize_paragraph
316
+ @td.tokenize "Public: Do some stuff\n"
317
+
318
+ expected = [
319
+ [:TEXT, "Do some stuff", 0, 0],
320
+ [:NEWLINE, "\n", 13, 0],
321
+ ]
322
+
323
+ assert_equal expected, @td.tokens
324
+ end
325
+
326
+ def test_tokenize_arguments
327
+ @td.tokenize <<-TEXT
328
+ Create new Arg object.
329
+
330
+ name - name of argument
331
+ description - arguments description
332
+ TEXT
333
+
334
+ expected = [
335
+ [:TEXT, "Create new Arg object.", 0, 0],
336
+ [:NEWLINE, "\n", 22, 0],
337
+ [:NEWLINE, "\n", 0, 1],
338
+ [:NOTE, "name", 0, 2],
339
+ [:TEXT, "name of argument", 14, 2],
340
+ [:NEWLINE, "\n", 30, 2],
341
+ [:NOTE, "description", 0, 3],
342
+ [:TEXT, "arguments description", 14, 3],
343
+ [:NEWLINE, "\n", 35, 3],
344
+ ]
345
+
346
+ assert_equal expected, @td.tokens
347
+ end
348
+
349
+ def test_tokenize_arguments_multiline
350
+ @td.tokenize <<-TEXT
351
+ Do some stuff
352
+
353
+ foo - A comment goes here
354
+ and is more than one line
355
+ TEXT
356
+
357
+ expected = [
358
+ [:TEXT, "Do some stuff", 0, 0],
359
+ [:NEWLINE, "\n", 13, 0],
360
+ [:NEWLINE, "\n", 0, 1],
361
+ [:NOTE, "foo", 0, 2],
362
+ [:TEXT, "A comment goes here", 6, 2],
363
+ [:NEWLINE, "\n", 25, 2],
364
+ [:TEXT, "and is more than one line", 2, 3],
365
+ [:NEWLINE, "\n", 27, 3],
366
+ ]
367
+
368
+ assert_equal expected, @td.tokens
369
+ end
370
+
371
+ def test_tokenize_arguments_nested
372
+ @td.tokenize <<-TEXT
373
+ Do some stuff
374
+
375
+ foo - A comment goes here
376
+ :bar - bar documentation
377
+ TEXT
378
+
379
+ expected = [
380
+ [:TEXT, "Do some stuff", 0, 0],
381
+ [:NEWLINE, "\n", 13, 0],
382
+ [:NEWLINE, "\n", 0, 1],
383
+ [:NOTE, "foo", 0, 2],
384
+ [:TEXT, "A comment goes here", 6, 2],
385
+ [:NEWLINE, "\n", 25, 2],
386
+ [:NOTE, ":bar", 6, 3],
387
+ [:TEXT, "bar documentation", 13, 3],
388
+ [:NEWLINE, "\n", 30, 3],
389
+ ]
390
+
391
+ assert_equal expected, @td.tokens
392
+ end
393
+
394
+ def test_tokenize_examples
395
+ @td.tokenize <<-TEXT
396
+ Do some stuff
397
+
398
+ Examples
399
+
400
+ 1 + 1
401
+ TEXT
402
+
403
+ expected = [
404
+ [:TEXT, "Do some stuff", 0, 0],
405
+ [:NEWLINE, "\n", 13, 0],
406
+ [:NEWLINE, "\n", 0, 1],
407
+ [:HEADER, 3, 0, 2],
408
+ [:TEXT, "Examples", 0, 2],
409
+ [:NEWLINE, "\n", 8, 2],
410
+ [:NEWLINE, "\n", 0, 3],
411
+ [:TEXT, "1 + 1", 2, 4],
412
+ [:NEWLINE, "\n", 7, 4],
413
+ ]
414
+
415
+ assert_equal expected, @td.tokens
416
+ end
417
+
418
+ def test_tokenize_returns
419
+ @td.tokenize <<-TEXT
420
+ Do some stuff
421
+
422
+ Returns a thing
423
+ TEXT
424
+
425
+ expected = [
426
+ [:TEXT, "Do some stuff", 0, 0],
427
+ [:NEWLINE, "\n", 13, 0],
428
+ [:NEWLINE, "\n", 0, 1],
429
+ [:TEXT, "Returns a thing", 0, 2],
430
+ [:NEWLINE, "\n", 15, 2],
431
+ ]
432
+
433
+ assert_equal expected, @td.tokens
434
+ end
435
+
436
+ def test_tokenize_returns_multiline
437
+ @td.tokenize <<-TEXT
438
+ Do some stuff
439
+
440
+ Returns a thing
441
+ that is multiline
442
+ TEXT
443
+
444
+ expected = [
445
+ [:TEXT, "Do some stuff", 0, 0],
446
+ [:NEWLINE, "\n", 13, 0],
447
+ [:NEWLINE, "\n", 0, 1],
448
+ [:TEXT, "Returns a thing", 0, 2],
449
+ [:NEWLINE, "\n", 15, 2],
450
+ [:TEXT, "that is multiline", 2, 3],
451
+ [:NEWLINE, "\n", 19, 3],
452
+ ]
453
+
454
+ assert_equal expected, @td.tokens
455
+ end
456
+
457
+ end
458
+