rdoc 2.0.0 → 2.1.0

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 (52) hide show
  1. data.tar.gz.sig +1 -0
  2. data/History.txt +30 -0
  3. data/Manifest.txt +18 -6
  4. data/Rakefile +52 -0
  5. data/lib/rdoc.rb +69 -69
  6. data/lib/rdoc/code_objects.rb +331 -112
  7. data/lib/rdoc/generator.rb +172 -144
  8. data/lib/rdoc/generator/html.rb +45 -18
  9. data/lib/rdoc/generator/html/frameless.rb +795 -0
  10. data/lib/rdoc/generator/html/hefss.rb +11 -11
  11. data/lib/rdoc/generator/html/html.rb +81 -87
  12. data/lib/rdoc/generator/html/kilmer.rb +10 -10
  13. data/lib/rdoc/generator/html/one_page_html.rb +9 -9
  14. data/lib/rdoc/generator/ri.rb +5 -8
  15. data/lib/rdoc/generator/texinfo.rb +84 -0
  16. data/lib/rdoc/generator/texinfo/class.texinfo.erb +44 -0
  17. data/lib/rdoc/generator/texinfo/file.texinfo.erb +6 -0
  18. data/lib/rdoc/generator/texinfo/method.texinfo.erb +6 -0
  19. data/lib/rdoc/generator/texinfo/texinfo.erb +28 -0
  20. data/lib/rdoc/known_classes.rb +69 -0
  21. data/lib/rdoc/markup.rb +3 -3
  22. data/lib/rdoc/markup/attribute_manager.rb +0 -9
  23. data/lib/rdoc/markup/fragments.rb +1 -1
  24. data/lib/rdoc/markup/preprocess.rb +10 -6
  25. data/lib/rdoc/markup/to_html.rb +55 -8
  26. data/lib/rdoc/markup/to_html_crossref.rb +21 -5
  27. data/lib/rdoc/markup/to_texinfo.rb +69 -0
  28. data/lib/rdoc/options.rb +37 -14
  29. data/lib/rdoc/parser.rb +109 -0
  30. data/lib/rdoc/parser/c.rb +656 -0
  31. data/lib/rdoc/parser/f95.rb +1835 -0
  32. data/lib/rdoc/{parsers/parse_rb.rb → parser/ruby.rb} +1436 -1191
  33. data/lib/rdoc/parser/simple.rb +38 -0
  34. data/lib/rdoc/rdoc.rb +48 -32
  35. data/lib/rdoc/ri.rb +5 -1
  36. data/lib/rdoc/ri/descriptions.rb +8 -5
  37. data/lib/rdoc/ri/driver.rb +148 -49
  38. data/lib/rdoc/stats.rb +94 -4
  39. data/test/test_rdoc_info_formatting.rb +175 -0
  40. data/test/test_rdoc_info_sections.rb +136 -0
  41. data/test/test_rdoc_markup_to_html.rb +30 -0
  42. data/test/test_rdoc_markup_to_html_crossref.rb +18 -0
  43. data/test/{test_rdoc_c_parser.rb → test_rdoc_parser_c.rb} +8 -11
  44. data/test/test_rdoc_parser_ruby.rb +539 -0
  45. data/test/test_rdoc_ri_default_display.rb +17 -16
  46. data/test/test_rdoc_ri_driver.rb +92 -0
  47. metadata +54 -12
  48. metadata.gz.sig +0 -0
  49. data/lib/rdoc/parsers/parse_c.rb +0 -775
  50. data/lib/rdoc/parsers/parse_f95.rb +0 -1841
  51. data/lib/rdoc/parsers/parse_simple.rb +0 -40
  52. data/lib/rdoc/parsers/parserfactory.rb +0 -99
@@ -0,0 +1,18 @@
1
+ require 'test/unit'
2
+ require 'rdoc/generator'
3
+ require 'rdoc/markup/to_html_crossref'
4
+
5
+ class TestRdocMarkupToHtmlCrossref < Test::Unit::TestCase
6
+
7
+ def setup
8
+ @xref = RDoc::Markup::ToHtmlCrossref.new 'from_path', nil, nil
9
+ end
10
+
11
+ def test_handle_special_CROSSREF_no_underscore
12
+ out = @xref.convert 'foo'
13
+
14
+ assert_equal "<p>\nfoo\n</p>\n", out
15
+ end
16
+
17
+ end
18
+
@@ -1,15 +1,16 @@
1
1
  require 'stringio'
2
2
  require 'tempfile'
3
3
  require 'test/unit'
4
- require 'rdoc/parsers/parse_c'
4
+ require 'rdoc/options'
5
+ require 'rdoc/parser/c'
5
6
 
6
- class RDoc::C_Parser
7
+ class RDoc::Parser::C
7
8
  attr_accessor :classes
8
9
 
9
10
  public :do_classes, :do_constants
10
11
  end
11
12
 
12
- class TestRdocC_Parser < Test::Unit::TestCase
13
+ class TestRdocParserC < Test::Unit::TestCase
13
14
 
14
15
  def setup
15
16
  @tempfile = Tempfile.new self.class.name
@@ -17,14 +18,12 @@ class TestRdocC_Parser < Test::Unit::TestCase
17
18
 
18
19
  @top_level = RDoc::TopLevel.new filename
19
20
  @fn = filename
20
- @options = RDoc::Options.new Hash.new
21
- @stats = RDoc::Stats.new
22
-
23
- @progress = StringIO.new
21
+ @options = RDoc::Options.new
22
+ @stats = RDoc::Stats.new 0
24
23
  end
25
24
 
26
25
  def teardown
27
- @tempfile.unlink
26
+ @tempfile.close
28
27
  end
29
28
 
30
29
  def test_do_classes_boot_class
@@ -252,9 +251,7 @@ Init_Foo(void) {
252
251
  end
253
252
 
254
253
  def util_parser(content)
255
- parser = RDoc::C_Parser.new @top_level, @fn, content, @options, @stats
256
- parser.progress = @progress
257
- parser
254
+ RDoc::Parser::C.new @top_level, @fn, content, @options, @stats
258
255
  end
259
256
 
260
257
  end
@@ -0,0 +1,539 @@
1
+ require 'stringio'
2
+ require 'tempfile'
3
+ require 'test/unit'
4
+
5
+ require 'rdoc/options'
6
+ require 'rdoc/parser/ruby'
7
+ require 'rdoc/stats'
8
+
9
+ class TestRdocParserRuby < Test::Unit::TestCase
10
+
11
+ def setup
12
+ @tempfile = Tempfile.new self.class.name
13
+ @filename = @tempfile.path
14
+
15
+ util_toplevel
16
+ @options = RDoc::Options.new
17
+ @options.quiet = true
18
+ @stats = RDoc::Stats.new 0
19
+ end
20
+
21
+ def teardown
22
+ @tempfile.unlink
23
+ end
24
+
25
+ def test_look_for_directives_in_commented
26
+ util_parser ""
27
+
28
+ comment = "# how to make a section:\n# # :section: new section\n"
29
+
30
+ @parser.look_for_directives_in @top_level, comment
31
+
32
+ section = @top_level.current_section
33
+ assert_equal nil, section.title
34
+ assert_equal nil, section.comment
35
+
36
+ assert_equal "# how to make a section:\n# # :section: new section\n",
37
+ comment
38
+ end
39
+
40
+ def test_look_for_directives_in_enddoc
41
+ util_parser ""
42
+
43
+ assert_throws :enddoc do
44
+ @parser.look_for_directives_in @top_level, "# :enddoc:\n"
45
+ end
46
+ end
47
+
48
+ def test_look_for_directives_in_main
49
+ util_parser ""
50
+
51
+ @parser.look_for_directives_in @top_level, "# :main: new main page\n"
52
+
53
+ assert_equal 'new main page', @options.main_page
54
+ end
55
+
56
+ def test_look_for_directives_in_method
57
+ util_parser ""
58
+
59
+ comment = "# :method: my_method\n"
60
+
61
+ @parser.look_for_directives_in @top_level, comment
62
+
63
+ assert_equal "# :method: my_method\n", comment
64
+
65
+ comment = "# :singleton-method: my_method\n"
66
+
67
+ @parser.look_for_directives_in @top_level, comment
68
+
69
+ assert_equal "# :singleton-method: my_method\n", comment
70
+ end
71
+
72
+ def test_look_for_directives_in_startdoc
73
+ util_parser ""
74
+
75
+ @top_level.stop_doc
76
+ assert !@top_level.document_self
77
+ assert !@top_level.document_children
78
+ assert !@top_level.force_documentation
79
+
80
+ @parser.look_for_directives_in @top_level, "# :startdoc:\n"
81
+
82
+ assert @top_level.document_self
83
+ assert @top_level.document_children
84
+ assert @top_level.force_documentation
85
+ end
86
+
87
+ def test_look_for_directives_in_stopdoc
88
+ util_parser ""
89
+
90
+ assert @top_level.document_self
91
+ assert @top_level.document_children
92
+
93
+ @parser.look_for_directives_in @top_level, "# :stopdoc:\n"
94
+
95
+ assert !@top_level.document_self
96
+ assert !@top_level.document_children
97
+ end
98
+
99
+ def test_look_for_directives_in_section
100
+ util_parser ""
101
+
102
+ comment = "# :section: new section\n# woo stuff\n"
103
+
104
+ @parser.look_for_directives_in @top_level, comment
105
+
106
+ section = @top_level.current_section
107
+ assert_equal 'new section', section.title
108
+ assert_equal "# woo stuff\n", section.comment
109
+
110
+ assert_equal '', comment
111
+ end
112
+
113
+ def test_look_for_directives_in_title
114
+ util_parser ""
115
+
116
+ @parser.look_for_directives_in @top_level, "# :title: new title\n"
117
+
118
+ assert_equal 'new title', @options.title
119
+ end
120
+
121
+ def test_look_for_directives_in_unhandled
122
+ util_parser ""
123
+
124
+ comment = "# :unhandled: \n# :title: hi\n"
125
+
126
+ @parser.look_for_directives_in @top_level, comment
127
+
128
+ assert_equal "# :unhandled: \n", comment
129
+
130
+ assert_equal 'hi', @options.title
131
+ end
132
+
133
+ def test_parse_class
134
+ comment = "##\n# my method\n"
135
+
136
+ util_parser 'class Foo; end'
137
+
138
+ tk = @parser.get_tk
139
+
140
+ @parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, comment
141
+
142
+ foo = @top_level.classes.first
143
+ assert_equal 'Foo', foo.full_name
144
+ assert_equal comment, foo.comment
145
+ end
146
+
147
+ def test_parse_class_nested_superclass
148
+ foo = RDoc::NormalModule.new 'Foo'
149
+ foo.parent = @top_level
150
+
151
+ util_parser "class Bar < Super\nend"
152
+
153
+ tk = @parser.get_tk
154
+
155
+ @parser.parse_class foo, RDoc::Parser::Ruby::NORMAL, tk, ''
156
+
157
+ bar = foo.classes.first
158
+ assert_equal 'Super', bar.superclass
159
+ end
160
+
161
+ def test_parse_comment
162
+ content = <<-EOF
163
+ class Foo
164
+ ##
165
+ # :method: my_method
166
+ # my method comment
167
+
168
+ end
169
+ EOF
170
+ klass = RDoc::NormalClass.new 'Foo'
171
+ klass.parent = @top_level
172
+
173
+ comment = "##\n# :method: foo\n# my method\n"
174
+
175
+ util_parser "\n"
176
+
177
+ tk = @parser.get_tk
178
+
179
+ @parser.parse_comment klass, tk, comment
180
+
181
+ foo = klass.method_list.first
182
+ assert_equal 'foo', foo.name
183
+ assert_equal comment, foo.comment
184
+
185
+ assert_equal [], foo.aliases
186
+ assert_equal nil, foo.block_params
187
+ assert_equal nil, foo.call_seq
188
+ assert_equal nil, foo.is_alias_for
189
+ assert_equal nil, foo.viewer
190
+ assert_equal true, foo.document_children
191
+ assert_equal true, foo.document_self
192
+ assert_equal '', foo.params
193
+ assert_equal false, foo.done_documenting
194
+ assert_equal false, foo.dont_rename_initialize
195
+ assert_equal false, foo.force_documentation
196
+ assert_equal klass, foo.parent
197
+ assert_equal false, foo.singleton
198
+ assert_equal :public, foo.visibility
199
+ assert_equal "\n", foo.text
200
+ assert_equal klass.current_section, foo.section
201
+
202
+ stream = [
203
+ tk(:COMMENT, 1, 1, nil, "# File #{@top_level.file_absolute_name}, line 1"),
204
+ RDoc::Parser::Ruby::NEWLINE_TOKEN,
205
+ tk(:SPACE, 1, 1, nil, ''),
206
+ ]
207
+
208
+ assert_equal stream, foo.token_stream
209
+ end
210
+
211
+ def test_parse_meta_method
212
+ klass = RDoc::NormalClass.new 'Foo'
213
+ klass.parent = @top_level
214
+
215
+ comment = "##\n# my method\n"
216
+
217
+ util_parser "add_my_method :foo, :bar\nadd_my_method :baz"
218
+
219
+ tk = @parser.get_tk
220
+
221
+ @parser.parse_meta_method klass, RDoc::Parser::Ruby::NORMAL, tk, comment
222
+
223
+ foo = klass.method_list.first
224
+ assert_equal 'foo', foo.name
225
+ assert_equal comment, foo.comment
226
+
227
+ assert_equal [], foo.aliases
228
+ assert_equal nil, foo.block_params
229
+ assert_equal nil, foo.call_seq
230
+ assert_equal true, foo.document_children
231
+ assert_equal true, foo.document_self
232
+ assert_equal false, foo.done_documenting
233
+ assert_equal false, foo.dont_rename_initialize
234
+ assert_equal false, foo.force_documentation
235
+ assert_equal nil, foo.is_alias_for
236
+ assert_equal '', foo.params
237
+ assert_equal klass, foo.parent
238
+ assert_equal false, foo.singleton
239
+ assert_equal 'add_my_method :foo', foo.text
240
+ assert_equal nil, foo.viewer
241
+ assert_equal :public, foo.visibility
242
+ assert_equal klass.current_section, foo.section
243
+
244
+ stream = [
245
+ tk(:COMMENT, 1, 1, nil, "# File #{@top_level.file_absolute_name}, line 1"),
246
+ RDoc::Parser::Ruby::NEWLINE_TOKEN,
247
+ tk(:SPACE, 1, 1, nil, ''),
248
+ tk(:IDENTIFIER, 1, 0, 'add_my_method', 'add_my_method'),
249
+ tk(:SPACE, 1, 13, nil, ' '),
250
+ tk(:SYMBOL, 1, 14, nil, ':foo'),
251
+ tk(:COMMA, 1, 18, nil, ','),
252
+ tk(:SPACE, 1, 19, nil, ' '),
253
+ tk(:SYMBOL, 1, 20, nil, ':bar'),
254
+ tk(:NL, 1, 24, nil, "\n"),
255
+ ]
256
+
257
+ assert_equal stream, foo.token_stream
258
+ end
259
+
260
+ def test_parse_meta_method_name
261
+ klass = RDoc::NormalClass.new 'Foo'
262
+ klass.parent = @top_level
263
+
264
+ comment = "##\n# :method: woo_hoo!\n# my method\n"
265
+
266
+ util_parser "add_my_method :foo, :bar\nadd_my_method :baz"
267
+
268
+ tk = @parser.get_tk
269
+
270
+ @parser.parse_meta_method klass, RDoc::Parser::Ruby::NORMAL, tk, comment
271
+
272
+ foo = klass.method_list.first
273
+ assert_equal 'woo_hoo!', foo.name
274
+ assert_equal "##\n# my method\n", foo.comment
275
+ end
276
+
277
+ def test_parse_meta_method_singleton
278
+ klass = RDoc::NormalClass.new 'Foo'
279
+ klass.parent = @top_level
280
+
281
+ comment = "##\n# :singleton-method:\n# my method\n"
282
+
283
+ util_parser "add_my_method :foo, :bar\nadd_my_method :baz"
284
+
285
+ tk = @parser.get_tk
286
+
287
+ @parser.parse_meta_method klass, RDoc::Parser::Ruby::NORMAL, tk, comment
288
+
289
+ foo = klass.method_list.first
290
+ assert_equal 'foo', foo.name
291
+ assert_equal true, foo.singleton, 'singleton method'
292
+ assert_equal "##\n# my method\n", foo.comment
293
+ end
294
+
295
+ def test_parse_meta_method_singleton_name
296
+ klass = RDoc::NormalClass.new 'Foo'
297
+ klass.parent = @top_level
298
+
299
+ comment = "##\n# :singleton-method: woo_hoo!\n# my method\n"
300
+
301
+ util_parser "add_my_method :foo, :bar\nadd_my_method :baz"
302
+
303
+ tk = @parser.get_tk
304
+
305
+ @parser.parse_meta_method klass, RDoc::Parser::Ruby::NORMAL, tk, comment
306
+
307
+ foo = klass.method_list.first
308
+ assert_equal 'woo_hoo!', foo.name
309
+ assert_equal true, foo.singleton, 'singleton method'
310
+ assert_equal "##\n# my method\n", foo.comment
311
+ end
312
+
313
+ def test_parse_meta_method_string_name
314
+ klass = RDoc::NormalClass.new 'Foo'
315
+ comment = "##\n# my method\n"
316
+
317
+ util_parser "add_my_method 'foo'"
318
+
319
+ tk = @parser.get_tk
320
+
321
+ @parser.parse_meta_method klass, RDoc::Parser::Ruby::NORMAL, tk, comment
322
+
323
+ foo = klass.method_list.first
324
+ assert_equal 'foo', foo.name
325
+ assert_equal comment, foo.comment
326
+ end
327
+
328
+ def test_parse_method
329
+ klass = RDoc::NormalClass.new 'Foo'
330
+ klass.parent = @top_level
331
+
332
+ comment = "##\n# my method\n"
333
+
334
+ util_parser "def foo() :bar end"
335
+
336
+ tk = @parser.get_tk
337
+
338
+ @parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, comment
339
+
340
+ foo = klass.method_list.first
341
+ assert_equal 'foo', foo.name
342
+ assert_equal comment, foo.comment
343
+
344
+ assert_equal [], foo.aliases
345
+ assert_equal nil, foo.block_params
346
+ assert_equal nil, foo.call_seq
347
+ assert_equal nil, foo.is_alias_for
348
+ assert_equal nil, foo.viewer
349
+ assert_equal true, foo.document_children
350
+ assert_equal true, foo.document_self
351
+ assert_equal '()', foo.params
352
+ assert_equal false, foo.done_documenting
353
+ assert_equal false, foo.dont_rename_initialize
354
+ assert_equal false, foo.force_documentation
355
+ assert_equal klass, foo.parent
356
+ assert_equal false, foo.singleton
357
+ assert_equal :public, foo.visibility
358
+ assert_equal 'def foo', foo.text
359
+ assert_equal klass.current_section, foo.section
360
+
361
+ stream = [
362
+ tk(:COMMENT, 1, 1, nil, "# File #{@top_level.file_absolute_name}, line 1"),
363
+ RDoc::Parser::Ruby::NEWLINE_TOKEN,
364
+ tk(:SPACE, 1, 1, nil, ''),
365
+ tk(:DEF, 1, 0, 'def', 'def'),
366
+ tk(:SPACE, 1, 3, nil, ' '),
367
+ tk(:IDENTIFIER, 1, 4, 'foo', 'foo'),
368
+ tk(:LPAREN, 1, 7, nil, '('),
369
+ tk(:RPAREN, 1, 8, nil, ')'),
370
+ tk(:SPACE, 1, 9, nil, ' '),
371
+ tk(:COLON, 1, 10, nil, ':'),
372
+ tk(:IDENTIFIER, 1, 11, 'bar', 'bar'),
373
+ tk(:SPACE, 1, 14, nil, ' '),
374
+ tk(:END, 1, 15, 'end', 'end'),
375
+ ]
376
+
377
+ assert_equal stream, foo.token_stream
378
+ end
379
+
380
+ def test_parse_statements_class_nested
381
+ comment = "##\n# my method\n"
382
+
383
+ util_parser "module Foo\n#{comment}class Bar\nend\nend"
384
+
385
+ @parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL, nil, ''
386
+
387
+ foo = @top_level.modules.first
388
+ assert_equal 'Foo', foo.full_name, 'module Foo'
389
+
390
+ bar = foo.classes.first
391
+ assert_equal 'Foo::Bar', bar.full_name, 'class Foo::Bar'
392
+ assert_equal comment, bar.comment
393
+ end
394
+
395
+ def test_parse_statements_identifier_meta_method
396
+ content = <<-EOF
397
+ class Foo
398
+ ##
399
+ # this is my method
400
+ add_my_method :foo
401
+ end
402
+ EOF
403
+
404
+ util_parser content
405
+
406
+ @parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL, nil, ''
407
+
408
+ foo = @top_level.classes.first.method_list.first
409
+ assert_equal 'foo', foo.name
410
+ end
411
+
412
+ def test_parse_statements_identifier_alias_method
413
+ content = "class Foo def foo() end; alias_method :foo2, :foo end"
414
+
415
+ util_parser content
416
+
417
+ @parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL, nil, ''
418
+
419
+ foo2 = @top_level.classes.first.method_list.last
420
+ assert_equal 'foo2', foo2.name
421
+ assert_equal 'foo', foo2.is_alias_for.name
422
+ end
423
+
424
+ def test_parse_statements_identifier_attr
425
+ content = "class Foo; attr :foo; end"
426
+
427
+ util_parser content
428
+
429
+ @parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL, nil, ''
430
+
431
+ foo = @top_level.classes.first.attributes.first
432
+ assert_equal 'foo', foo.name
433
+ assert_equal 'R', foo.rw
434
+ end
435
+
436
+ def test_parse_statements_identifier_attr_accessor
437
+ content = "class Foo; attr_accessor :foo; end"
438
+
439
+ util_parser content
440
+
441
+ @parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL, nil, ''
442
+
443
+ foo = @top_level.classes.first.attributes.first
444
+ assert_equal 'foo', foo.name
445
+ assert_equal 'RW', foo.rw
446
+ end
447
+
448
+ def test_parse_statements_identifier_extra_accessors
449
+ @options.extra_accessors = /^my_accessor$/
450
+
451
+ content = "class Foo; my_accessor :foo; end"
452
+
453
+ util_parser content
454
+
455
+ @parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL, nil, ''
456
+
457
+ foo = @top_level.classes.first.attributes.first
458
+ assert_equal 'foo', foo.name
459
+ assert_equal '?', foo.rw
460
+ end
461
+
462
+ def test_parse_statements_identifier_include
463
+ content = "class Foo; include Bar; end"
464
+
465
+ util_parser content
466
+
467
+ @parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL, nil, ''
468
+
469
+ foo = @top_level.classes.first
470
+ assert_equal 'Foo', foo.name
471
+ assert_equal 1, foo.includes.length
472
+ end
473
+
474
+ def test_parse_statements_identifier_module_function
475
+ content = "module Foo def foo() end; module_function :foo; end"
476
+
477
+ util_parser content
478
+
479
+ @parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL, nil, ''
480
+
481
+ foo, s_foo = @top_level.modules.first.method_list
482
+ assert_equal 'foo', foo.name, 'instance method name'
483
+ assert_equal :private, foo.visibility, 'instance method visibility'
484
+ assert_equal false, foo.singleton, 'instance method singleton'
485
+
486
+ assert_equal 'foo', s_foo.name, 'module function name'
487
+ assert_equal :public, s_foo.visibility, 'module function visibility'
488
+ assert_equal true, s_foo.singleton, 'module function singleton'
489
+ end
490
+
491
+ def test_parse_statements_identifier_private
492
+ content = "class Foo private; def foo() end end"
493
+
494
+ util_parser content
495
+
496
+ @parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL, nil, ''
497
+
498
+ foo = @top_level.classes.first.method_list.first
499
+ assert_equal 'foo', foo.name
500
+ assert_equal :private, foo.visibility
501
+ end
502
+
503
+ def test_parse_statements_identifier_require
504
+ content = "require 'bar'"
505
+
506
+ util_parser content
507
+
508
+ @parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL, nil, ''
509
+
510
+ assert_equal 1, @top_level.requires.length
511
+ end
512
+
513
+ def tk(klass, line, char, name, text)
514
+ klass = RDoc::RubyToken.const_get "Tk#{klass.to_s.upcase}"
515
+
516
+ token = if klass.instance_method(:initialize).arity == 2 then
517
+ raise ArgumentError, "name not used for #{klass}" unless name.nil?
518
+ klass.new line, char
519
+ else
520
+ klass.new line, char, name
521
+ end
522
+
523
+ token.set_text text
524
+
525
+ token
526
+ end
527
+
528
+ def util_parser(content)
529
+ @parser = RDoc::Parser::Ruby.new @top_level, @filename, content, @options,
530
+ @stats
531
+ end
532
+
533
+ def util_toplevel
534
+ RDoc::TopLevel.reset
535
+ @top_level = RDoc::TopLevel.new @filename
536
+ end
537
+
538
+ end
539
+