rdoc 4.0.0.preview2 → 4.0.0.preview2.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 (45) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.autotest +4 -1
  5. data/History.rdoc +26 -1
  6. data/Manifest.txt +2 -0
  7. data/Rakefile +1 -1
  8. data/lib/rdoc.rb +1 -1
  9. data/lib/rdoc/class_module.rb +13 -2
  10. data/lib/rdoc/context.rb +7 -5
  11. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +7 -1
  12. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +1 -1
  13. data/lib/rdoc/markdown/entities.rb +3 -0
  14. data/lib/rdoc/markup/document.rb +8 -8
  15. data/lib/rdoc/markup/formatter.rb +6 -1
  16. data/lib/rdoc/markup/heading.rb +2 -1
  17. data/lib/rdoc/markup/to_joined_paragraph.rb +5 -2
  18. data/lib/rdoc/markup/to_table_of_contents.rb +27 -1
  19. data/lib/rdoc/options.rb +36 -1
  20. data/lib/rdoc/parser.rb +30 -1
  21. data/lib/rdoc/parser/c.rb +56 -14
  22. data/lib/rdoc/parser/changelog.rb +186 -0
  23. data/lib/rdoc/parser/ruby.rb +53 -11
  24. data/lib/rdoc/rdoc.rb +9 -0
  25. data/lib/rdoc/ri/driver.rb +5 -1
  26. data/lib/rdoc/ruby_lex.rb +1 -1
  27. data/lib/rdoc/rubygems_hook.rb +16 -10
  28. data/lib/rdoc/servlet.rb +111 -6
  29. data/lib/rdoc/store.rb +110 -19
  30. data/test/test_rdoc_class_module.rb +32 -0
  31. data/test/test_rdoc_context.rb +25 -0
  32. data/test/test_rdoc_markup_document.rb +19 -0
  33. data/test/test_rdoc_markup_to_table_of_contents.rb +31 -0
  34. data/test/test_rdoc_options.rb +38 -0
  35. data/test/test_rdoc_parser.rb +56 -0
  36. data/test/test_rdoc_parser_c.rb +129 -6
  37. data/test/test_rdoc_parser_changelog.rb +294 -0
  38. data/test/test_rdoc_parser_ruby.rb +145 -8
  39. data/test/test_rdoc_rdoc.rb +25 -5
  40. data/test/test_rdoc_ri_driver.rb +27 -0
  41. data/test/test_rdoc_ruby_lex.rb +10 -0
  42. data/test/test_rdoc_rubygems_hook.rb +49 -18
  43. data/test/test_rdoc_store.rb +148 -37
  44. metadata +26 -23
  45. metadata.gz.sig +0 -0
@@ -41,6 +41,16 @@ class TestRDocClassModule < XrefTestCase
41
41
  assert_equal 'comment', cm.comment.text
42
42
  end
43
43
 
44
+ def test_add_comment_duplicate
45
+ tl1 = @store.add_file 'one.rb'
46
+
47
+ cm = RDoc::ClassModule.new 'Klass'
48
+ cm.add_comment '# comment 1', tl1
49
+ cm.add_comment '# comment 2', tl1
50
+
51
+ assert_equal [['comment 2', tl1]], cm.comment_location
52
+ end
53
+
44
54
  def test_add_comment_stopdoc
45
55
  tl = @store.add_file 'file.rb'
46
56
 
@@ -95,6 +105,28 @@ class TestRDocClassModule < XrefTestCase
95
105
  refute @c1.document_self_or_methods
96
106
  end
97
107
 
108
+ def test_documented_eh
109
+ cm = RDoc::ClassModule.new 'C'
110
+
111
+ refute cm.documented?
112
+
113
+ cm.add_comment 'hi', @top_level
114
+
115
+ assert cm.documented?
116
+
117
+ cm.comment.replace ''
118
+
119
+ assert cm.documented?
120
+
121
+ cm.comment_location.clear
122
+
123
+ refute cm.documented?
124
+
125
+ cm.document_self = nil # notify :nodoc:
126
+
127
+ assert cm.documented?
128
+ end
129
+
98
130
  def test_each_ancestor
99
131
  assert_equal [@parent], @child.each_ancestor.to_a
100
132
  end
@@ -244,6 +244,31 @@ class TestRDocContext < XrefTestCase
244
244
  assert_equal 'first', method.comment.text
245
245
  end
246
246
 
247
+ def test_add_method_duplicate_loading
248
+ @context.store = nil
249
+
250
+ meth1 = RDoc::AnyMethod.new nil, 'name'
251
+ meth1.record_location @store.add_file 'first.rb'
252
+ meth1.visibility = nil
253
+ meth1.comment = comment 'first'
254
+
255
+ @context.add_method meth1
256
+
257
+ meth2 = RDoc::AnyMethod.new nil, 'name'
258
+ meth2.record_location @store.add_file 'second.rb'
259
+ meth2.comment = comment 'second'
260
+
261
+ _, err = verbose_capture_io do
262
+ @context.add_method meth2
263
+ end
264
+
265
+ assert_empty err
266
+
267
+ method = @context.method_list.first
268
+
269
+ assert_equal 'first', method.comment.text
270
+ end
271
+
247
272
  def test_add_module
248
273
  @c1.add_module RDoc::NormalModule, 'Mod'
249
274
 
@@ -191,5 +191,24 @@ class TestRDocMarkupDocument < RDoc::TestCase
191
191
  assert_equal expected, doc.table_of_contents
192
192
  end
193
193
 
194
+ def test_table_of_contents_omit_headings_below
195
+ document = doc(
196
+ head(1, 'A'),
197
+ para('B'),
198
+ head(2, 'C'),
199
+ para('D'),
200
+ head(1, 'E'),
201
+ para('F'))
202
+
203
+ document.omit_headings_below = 1
204
+
205
+ expected = [
206
+ head(1, 'A'),
207
+ head(1, 'E'),
208
+ ]
209
+
210
+ assert_equal expected, document.table_of_contents
211
+ end
212
+
194
213
  end
195
214
 
@@ -91,5 +91,36 @@ class TestRDocMarkupToTableOfContents < RDoc::Markup::FormatterTestCase
91
91
  alias list_verbatim empty
92
92
  alias start_accepting empty
93
93
 
94
+ def test_accept_document_omit_headings_below
95
+ document = doc
96
+ document.omit_headings_below = 2
97
+
98
+ @to.accept_document document
99
+
100
+ assert_equal 2, @to.omit_headings_below
101
+ end
102
+
103
+ def test_accept_heading_suppressed
104
+ @to.start_accepting
105
+ @to.omit_headings_below = 4
106
+
107
+ suppressed = head 5, 'Hello'
108
+
109
+ @to.accept_heading suppressed
110
+
111
+ assert_empty @to.res
112
+ end
113
+
114
+ def test_suppressed_eh
115
+ @to.omit_headings_below = nil
116
+
117
+ refute @to.suppressed? head(1, '')
118
+
119
+ @to.omit_headings_below = 1
120
+
121
+ refute @to.suppressed? head(1, '')
122
+ assert @to.suppressed? head(2, '')
123
+ end
124
+
94
125
  end
95
126
 
@@ -76,6 +76,7 @@ class TestRDocOptions < RDoc::TestCase
76
76
  'line_numbers' => false,
77
77
  'main_page' => nil,
78
78
  'markup' => 'rdoc',
79
+ 'page_dir' => nil,
79
80
  'rdoc_include' => [],
80
81
  'show_hash' => false,
81
82
  'static_path' => [],
@@ -430,6 +431,43 @@ rdoc_include:
430
431
  assert_equal 'tomdoc', @options.markup
431
432
  end
432
433
 
434
+ def test_parse_page_dir
435
+ assert_nil @options.page_dir
436
+
437
+ out, err = capture_io do
438
+ @options.parse %W[--page-dir #{Dir.tmpdir}]
439
+ end
440
+
441
+ assert_empty out
442
+ assert_empty err
443
+
444
+ expected =
445
+ Pathname(Dir.tmpdir).expand_path.relative_path_from @options.root
446
+
447
+ assert_equal expected, @options.page_dir
448
+ assert_equal [Dir.tmpdir], @options.files
449
+ end
450
+
451
+ def test_parse_page_dir_root
452
+ assert_nil @options.page_dir
453
+
454
+ Dir.mktmpdir do |dir|
455
+ abs_root = dir
456
+ abs_page_dir = File.join dir, 'pages'
457
+ FileUtils.mkdir abs_page_dir
458
+
459
+ out, err = capture_io do
460
+ @options.parse %W[--page-dir #{abs_page_dir} --root #{abs_root}]
461
+ end
462
+
463
+ assert_empty out
464
+ assert_empty err
465
+
466
+ assert_equal Pathname('pages'), @options.page_dir
467
+ assert_equal [abs_page_dir], @options.files
468
+ end
469
+ end
470
+
433
471
  def test_parse_root
434
472
  assert_equal Pathname(Dir.pwd), @options.root
435
473
 
@@ -1,3 +1,5 @@
1
+ # -*- coding: us-ascii -*-
2
+
1
3
  require 'rdoc/test_case'
2
4
 
3
5
  class TestRDocParser < RDoc::TestCase
@@ -75,6 +77,20 @@ class TestRDocParser < RDoc::TestCase
75
77
  end
76
78
  end
77
79
 
80
+ def test_can_parse_modeline
81
+ readme_ext = File.join Dir.tmpdir, "README.EXT.#{$$}"
82
+
83
+ open readme_ext, 'w' do |io|
84
+ io.puts "# README.EXT - -*- rdoc -*- created at: Mon Aug 7 16:45:54 JST 1995"
85
+ io.puts
86
+ io.puts "This document explains how to make extension libraries for Ruby."
87
+ end
88
+
89
+ assert_equal RDoc::Parser::Simple, @RP.can_parse(readme_ext)
90
+ ensure
91
+ File.unlink readme_ext
92
+ end
93
+
78
94
  ##
79
95
  # Selenium hides a .jar file using a .txt extension.
80
96
 
@@ -83,6 +99,46 @@ class TestRDocParser < RDoc::TestCase
83
99
  assert_nil @RP.can_parse(hidden_zip)
84
100
  end
85
101
 
102
+ def test_check_modeline
103
+ readme_ext = File.join Dir.tmpdir, "README.EXT.#{$$}"
104
+
105
+ open readme_ext, 'w' do |io|
106
+ io.puts "# README.EXT - -*- RDoc -*- created at: Mon Aug 7 16:45:54 JST 1995"
107
+ io.puts
108
+ io.puts "This document explains how to make extension libraries for Ruby."
109
+ end
110
+
111
+ assert_equal 'rdoc', @RP.check_modeline(readme_ext)
112
+ ensure
113
+ File.unlink readme_ext
114
+ end
115
+
116
+ def test_check_modeline_with_other
117
+ readme_ext = File.join Dir.tmpdir, "README.EXT.#{$$}"
118
+
119
+ open readme_ext, 'w' do |io|
120
+ io.puts "# README.EXT - -*- mode: RDoc; indent-tabs-mode: nil -*-"
121
+ io.puts
122
+ io.puts "This document explains how to make extension libraries for Ruby."
123
+ end
124
+
125
+ assert_equal 'rdoc', @RP.check_modeline(readme_ext)
126
+ ensure
127
+ File.unlink readme_ext
128
+ end
129
+
130
+ def test_check_modeline_no_modeline
131
+ readme_ext = File.join Dir.tmpdir, "README.EXT.#{$$}"
132
+
133
+ open readme_ext, 'w' do |io|
134
+ io.puts "This document explains how to make extension libraries for Ruby."
135
+ end
136
+
137
+ assert_nil @RP.check_modeline(readme_ext)
138
+ ensure
139
+ File.unlink readme_ext
140
+ end
141
+
86
142
  def test_class_for_binary
87
143
  rp = @RP.dup
88
144
 
@@ -40,12 +40,6 @@ assert call-seq correct
40
40
 
41
41
  =end
42
42
 
43
- class RDoc::Parser::C
44
- attr_accessor :classes
45
-
46
- public :do_classes, :do_constants
47
- end
48
-
49
43
  class TestRDocParserC < RDoc::TestCase
50
44
 
51
45
  def setup
@@ -83,6 +77,37 @@ class TestRDocParserC < RDoc::TestCase
83
77
  assert_equal c_parser, c_parser.can_parse('file.y')
84
78
  end
85
79
 
80
+ def test_initialize
81
+ some_ext = @top_level.add_class RDoc::NormalClass, 'SomeExt'
82
+ @top_level.add_class RDoc::SingleClass, 'SomeExtSingle'
83
+
84
+ @store.cache[:c_class_variables] = {
85
+ @fn => { 'cSomeExt' => 'SomeExt' }
86
+ }
87
+
88
+ @store.cache[:c_singleton_class_variables] = {
89
+ @fn => { 'cSomeExtSingle' => 'SomeExtSingle' }
90
+ }
91
+
92
+ parser = RDoc::Parser::C.new @top_level, @fn, '', @options, @stats
93
+
94
+ expected = { 'cSomeExt' => some_ext }
95
+ assert_equal expected, parser.classes
96
+
97
+ expected = { 'cSomeExtSingle' => 'SomeExtSingle' }
98
+ assert_equal expected, parser.singleton_classes
99
+
100
+ expected = {
101
+ 'cSomeExt' => 'SomeExt',
102
+ 'cSomeExtSingle' => 'SomeExtSingle',
103
+ }
104
+ known_classes = parser.known_classes.delete_if do |key, _|
105
+ RDoc::KNOWN_CLASSES.keys.include? key
106
+ end
107
+
108
+ assert_equal expected, known_classes
109
+ end
110
+
86
111
  def test_do_attr_rb_attr
87
112
  content = <<-EOF
88
113
  void Init_Blah(void) {
@@ -1317,6 +1342,81 @@ void Init_Blah(void) {
1317
1342
  assert_equal 'not_handled', @top_level.metadata['other']
1318
1343
  end
1319
1344
 
1345
+ def test_load_variable_map
1346
+ some_ext = @top_level.add_class RDoc::NormalClass, 'SomeExt'
1347
+ @top_level.add_class RDoc::NormalClass, 'OtherExt'
1348
+
1349
+ @store.cache[:c_class_variables][@fn] = { 'cSomeExt' => 'SomeExt' }
1350
+ @store.cache[:c_class_variables]['other.c'] = { 'cOtherExt' => 'OtherExt' }
1351
+
1352
+ parser = util_parser
1353
+
1354
+ map = parser.load_variable_map :c_class_variables
1355
+
1356
+ expected = { 'cSomeExt' => some_ext }
1357
+
1358
+ assert_equal expected, map
1359
+
1360
+ assert_equal 'SomeExt', parser.known_classes['cSomeExt']
1361
+ assert_nil parser.known_classes['cOtherExt']
1362
+ end
1363
+
1364
+ def test_load_variable_map_empty
1365
+ parser = util_parser
1366
+
1367
+ map = parser.load_variable_map :c_class_variables
1368
+
1369
+ assert_empty map
1370
+ end
1371
+
1372
+ def test_load_variable_map_legacy
1373
+ @store.cache[:c_class_variables] = nil
1374
+
1375
+ parser = util_parser
1376
+
1377
+ map = parser.load_variable_map :c_class_variables
1378
+
1379
+ assert_empty map
1380
+ end
1381
+
1382
+ def test_load_variable_map_singleton
1383
+ @top_level.add_class RDoc::NormalClass, 'SomeExt'
1384
+ @top_level.add_class RDoc::NormalClass, 'OtherExt'
1385
+
1386
+ @store.cache[:c_singleton_class_variables][@fn] =
1387
+ { 'cSomeExt' => 'SomeExt' }
1388
+ @store.cache[:c_singleton_class_variables]['other.c'] =
1389
+ { 'cOtherExt' => 'OtherExt' }
1390
+
1391
+ parser = util_parser
1392
+
1393
+ map = parser.load_variable_map :c_singleton_class_variables
1394
+
1395
+ expected = { 'cSomeExt' => 'SomeExt' }
1396
+
1397
+ assert_equal expected, map
1398
+
1399
+ assert_equal 'SomeExt', parser.known_classes['cSomeExt']
1400
+ assert_nil parser.known_classes['cOtherExt']
1401
+ end
1402
+
1403
+ def test_load_variable_map_trim
1404
+ a = @top_level.add_class RDoc::NormalClass, 'A'
1405
+
1406
+ @store.cache[:c_class_variables][@fn] = {
1407
+ 'cA' => 'A',
1408
+ 'cB' => 'B',
1409
+ }
1410
+
1411
+ parser = util_parser
1412
+
1413
+ map = parser.load_variable_map :c_class_variables
1414
+
1415
+ expected = { 'cA' => a }
1416
+
1417
+ assert_equal expected, map
1418
+ end
1419
+
1320
1420
  def test_define_method
1321
1421
  content = <<-EOF
1322
1422
  /*Method Comment! */
@@ -1523,6 +1623,29 @@ Init_IO(void) {
1523
1623
  parser.rb_scan_args('rb_scan_args(a, b, "*:&",)')
1524
1624
  end
1525
1625
 
1626
+ def test_scan
1627
+ parser = util_parser <<-C
1628
+ void Init(void) {
1629
+ mM = rb_define_module("M");
1630
+ cC = rb_define_class("C", rb_cObject);
1631
+ sC = rb_singleton_class(cC);
1632
+ }
1633
+ C
1634
+
1635
+ parser.scan
1636
+
1637
+ expected = {
1638
+ @fn => {
1639
+ 'mM' => 'M',
1640
+ 'cC' => 'C', }}
1641
+ assert_equal expected, @store.c_class_variables
1642
+
1643
+ expected = {
1644
+ @fn => {
1645
+ 'sC' => 'C' } }
1646
+ assert_equal expected, @store.c_singleton_class_variables
1647
+ end
1648
+
1526
1649
  def test_scan_order_dependent
1527
1650
  parser = util_parser <<-C
1528
1651
  void a(void) {
@@ -0,0 +1,294 @@
1
+ require 'rdoc/test_case'
2
+
3
+ class TestRDocParserChangeLog < RDoc::TestCase
4
+
5
+ def setup
6
+ super
7
+
8
+ @tempfile = Tempfile.new 'ChangeLog'
9
+ @top_level = @store.add_file @tempfile.path
10
+ @options = RDoc::Options.new
11
+ @stats = RDoc::Stats.new @store, 0
12
+ end
13
+
14
+ def teardown
15
+ @tempfile.close
16
+ end
17
+
18
+ def mu_pp obj
19
+ s = ''
20
+ s = PP.pp obj, s
21
+ s = s.force_encoding Encoding.default_external if defined? Encoding
22
+ s.chomp
23
+ end
24
+
25
+ def test_class_can_parse
26
+ parser = RDoc::Parser::ChangeLog
27
+
28
+ assert_equal parser, parser.can_parse('ChangeLog')
29
+
30
+ assert_equal parser, parser.can_parse(@tempfile.path)
31
+
32
+ assert_equal RDoc::Parser::Ruby, parser.can_parse('ChangeLog.rb')
33
+ end
34
+
35
+ def test_continue_entry_body
36
+ parser = util_parser
37
+
38
+ entry_body = ['a']
39
+
40
+ parser.continue_entry_body entry_body, 'b'
41
+
42
+ assert_equal ['a b'], entry_body
43
+ end
44
+
45
+ def test_continue_entry_body_empty
46
+ parser = util_parser
47
+
48
+ entry_body = []
49
+
50
+ parser.continue_entry_body entry_body, ''
51
+
52
+ assert_empty entry_body
53
+ end
54
+
55
+ def test_continue_entry_body_function
56
+ parser = util_parser
57
+
58
+ entry_body = ['file: (func1)']
59
+
60
+ parser.continue_entry_body entry_body, '(func2): blah'
61
+
62
+ assert_equal ['file: (func1, func2): blah'], entry_body
63
+ end
64
+
65
+ def test_create_document
66
+ parser = util_parser
67
+
68
+ groups = {
69
+ '2012-12-04' => [
70
+ ['Tue Dec 4 08:33:46 2012 Eric Hodel <drbrain@segment7.net>',
71
+ %w[a:one b:two]],
72
+ ['Tue Dec 4 08:32:10 2012 Eric Hodel <drbrain@segment7.net>',
73
+ %w[c:three d:four]]],
74
+ '2012-12-03' => [
75
+ ['Mon Dec 3 20:28:02 2012 Koichi Sasada <ko1@atdot.net>',
76
+ %w[e:five f:six]]],
77
+ }
78
+
79
+ expected =
80
+ doc(
81
+ head(1, File.basename(@tempfile.path)),
82
+ blank_line,
83
+ head(2, '2012-12-04'),
84
+ blank_line,
85
+ head(3, 'Tue Dec 4 08:33:46 2012 Eric Hodel <drbrain@segment7.net>'),
86
+ blank_line,
87
+ list(:NOTE, item('a', para('one')), item('b', para('two'))),
88
+ head(3, 'Tue Dec 4 08:32:10 2012 Eric Hodel <drbrain@segment7.net>'),
89
+ blank_line,
90
+ list(:NOTE, item('c', para('three')), item('d', para('four'))),
91
+ head(2, '2012-12-03'),
92
+ blank_line,
93
+ head(3, 'Mon Dec 3 20:28:02 2012 Koichi Sasada <ko1@atdot.net>'),
94
+ blank_line,
95
+ list(:NOTE, item('e', para('five')), item('f', para('six'))))
96
+
97
+ expected.file = @top_level
98
+
99
+ document = parser.create_document(groups)
100
+
101
+ assert_equal expected, document
102
+
103
+ assert_equal 2, document.omit_headings_below
104
+
105
+ headings = document.parts.select do |part|
106
+ RDoc::Markup::Heading === part and part.level == 2
107
+ end
108
+
109
+ refute headings.all? { |heading| heading.text.frozen? }
110
+ end
111
+
112
+ def test_create_entries
113
+ parser = util_parser
114
+
115
+ entries = [
116
+ ['Tue Dec 1 02:03:04 2012 Eric Hodel <drbrain@segment7.net>',
117
+ %w[a:one b:two]],
118
+ ['Tue Dec 5 06:07:08 2012 Eric Hodel <drbrain@segment7.net>',
119
+ %w[c:three d:four]],
120
+ ]
121
+
122
+ expected = [
123
+ head(3, 'Tue Dec 1 02:03:04 2012 Eric Hodel <drbrain@segment7.net>'),
124
+ blank_line,
125
+ list(:NOTE, item('a', para('one')), item('b', para('two'))),
126
+ head(3, 'Tue Dec 5 06:07:08 2012 Eric Hodel <drbrain@segment7.net>'),
127
+ blank_line,
128
+ list(:NOTE, item('c', para('three')), item('d', para('four'))),
129
+ ]
130
+
131
+ entries = parser.create_entries(entries)
132
+ assert_equal expected, entries
133
+ end
134
+
135
+ def test_create_entries_colons
136
+ parser = util_parser
137
+
138
+ entries = [
139
+ ['Wed Dec 5 12:17:11 2012 Naohisa Goto <ngotogenome@gmail.com>',
140
+ ['func.rb (DL::Function#bind): log stuff [ruby-core:50562]']],
141
+ ]
142
+
143
+ expected = [
144
+ head(3,
145
+ 'Wed Dec 5 12:17:11 2012 Naohisa Goto <ngotogenome@gmail.com>'),
146
+ blank_line,
147
+ list(:NOTE,
148
+ item('func.rb (DL::Function#bind)',
149
+ para('log stuff [ruby-core:50562]')))]
150
+
151
+ assert_equal expected, parser.create_entries(entries)
152
+ end
153
+
154
+ def test_create_items
155
+ parser = util_parser
156
+
157
+ items = [
158
+ 'README.EXT: Converted to RDoc format',
159
+ 'README.EXT.ja: ditto',
160
+ ]
161
+
162
+ expected =
163
+ list(:NOTE,
164
+ item('README.EXT',
165
+ para('Converted to RDoc format')),
166
+ item('README.EXT.ja',
167
+ para('ditto')))
168
+
169
+ assert_equal expected, parser.create_items(items)
170
+ end
171
+
172
+ def test_group_entries
173
+ parser = util_parser
174
+
175
+ entries = [
176
+ [ 'Tue Dec 4 08:33:46 2012 Eric Hodel <drbrain@segment7.net>',
177
+ %w[one two]],
178
+ [ 'Tue Dec 4 08:32:10 2012 Eric Hodel <drbrain@segment7.net>',
179
+ %w[three four]],
180
+ [ 'Mon Dec 3 20:28:02 2012 Koichi Sasada <ko1@atdot.net>',
181
+ %w[five six]]]
182
+
183
+ expected = {
184
+ '2012-12-04' => [
185
+ ['Tue Dec 4 08:33:46 2012 Eric Hodel <drbrain@segment7.net>',
186
+ %w[one two]],
187
+ ['Tue Dec 4 08:32:10 2012 Eric Hodel <drbrain@segment7.net>',
188
+ %w[three four]]],
189
+ '2012-12-03' => [
190
+ ['Mon Dec 3 20:28:02 2012 Koichi Sasada <ko1@atdot.net>',
191
+ %w[five six]]],
192
+ }
193
+
194
+ assert_equal expected, parser.group_entries(entries)
195
+ end
196
+
197
+ def test_parse_entries
198
+ parser = util_parser <<-ChangeLog
199
+ Tue Dec 4 08:33:46 2012 Eric Hodel <drbrain@segment7.net>
200
+
201
+ * README.EXT: Converted to RDoc format
202
+ * README.EXT.ja: ditto
203
+
204
+ Mon Dec 3 20:28:02 2012 Koichi Sasada <ko1@atdot.net>
205
+
206
+ * compile.c (iseq_specialized_instruction):
207
+ change condition of using `opt_send_simple'.
208
+ More method invocations can be simple.
209
+
210
+ Other note that will be ignored
211
+
212
+ ChangeLog
213
+
214
+ expected = [
215
+ [ 'Tue Dec 4 08:33:46 2012 Eric Hodel <drbrain@segment7.net>',
216
+ [ 'README.EXT: Converted to RDoc format',
217
+ 'README.EXT.ja: ditto']],
218
+ [ 'Mon Dec 3 20:28:02 2012 Koichi Sasada <ko1@atdot.net>',
219
+ [ 'compile.c (iseq_specialized_instruction): change condition of ' +
220
+ 'using `opt_send_simple\'. More method invocations can be simple.']]]
221
+
222
+ assert_equal expected, parser.parse_entries
223
+ end
224
+
225
+ def test_parse_entries_gnu
226
+ parser = util_parser <<-ChangeLog
227
+ 1998-08-17 Richard Stallman <rms@gnu.org>
228
+
229
+ * register.el (insert-register): Return nil.
230
+ (jump-to-register): Likewise.
231
+
232
+ * sort.el (sort-subr): Return nil.
233
+
234
+ * keyboard.c (menu_bar_items, tool_bar_items)
235
+ (Fexecute_extended_command): Deal with 'keymap' property.
236
+ ChangeLog
237
+
238
+ expected = [
239
+ [ '1998-08-17 Richard Stallman <rms@gnu.org>',
240
+ [ 'register.el (insert-register): Return nil.',
241
+ '(jump-to-register): Likewise.',
242
+ 'sort.el (sort-subr): Return nil.',
243
+ 'keyboard.c (menu_bar_items, tool_bar_items, ' +
244
+ 'Fexecute_extended_command): Deal with \'keymap\' property.']]]
245
+
246
+ assert_equal expected, parser.parse_entries
247
+ end
248
+
249
+ def test_scan
250
+ parser = util_parser <<-ChangeLog
251
+ Tue Dec 4 08:32:10 2012 Eric Hodel <drbrain@segment7.net>
252
+
253
+ * lib/rdoc/ri/driver.rb: Fixed ri page display for files with
254
+ extensions.
255
+ * test/rdoc/test_rdoc_ri_driver.rb: Test for above
256
+
257
+ Mon Dec 3 20:37:22 2012 Koichi Sasada <ko1@atdot.net>
258
+
259
+ * vm_exec.c: check VM_COLLECT_USAGE_DETAILS.
260
+
261
+ ChangeLog
262
+
263
+ parser.scan
264
+
265
+ expected = doc(
266
+ head(1, File.basename(@tempfile.path)),
267
+ blank_line,
268
+ head(2, '2012-12-04'),
269
+ blank_line,
270
+ head(3, 'Tue Dec 4 08:32:10 2012 Eric Hodel <drbrain@segment7.net>'),
271
+ blank_line,
272
+ list(:NOTE,
273
+ item('lib/rdoc/ri/driver.rb', para('Fixed ri page display for ' +
274
+ 'files with extensions.')),
275
+ item('test/rdoc/test_rdoc_ri_driver.rb', para('Test for above'))),
276
+ head(2, '2012-12-03'),
277
+ blank_line,
278
+ head(3, 'Mon Dec 3 20:37:22 2012 Koichi Sasada <ko1@atdot.net>'),
279
+ blank_line,
280
+ list(:NOTE,
281
+ item('vm_exec.c', para('check VM_COLLECT_USAGE_DETAILS.'))))
282
+
283
+ expected.file = @top_level
284
+
285
+ assert_equal expected, @top_level.comment
286
+ end
287
+
288
+ def util_parser content = ''
289
+ RDoc::Parser::ChangeLog.new \
290
+ @top_level, @tempfile.path, content, @options, @stats
291
+ end
292
+
293
+ end
294
+