rdoc 3.7 → 3.8
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.
- data.tar.gz.sig +0 -0
- data/History.txt +9 -0
- data/lib/rdoc.rb +1 -1
- data/lib/rdoc/class_module.rb +34 -9
- data/lib/rdoc/known_classes.rb +2 -0
- data/lib/rdoc/parser/c.rb +0 -2
- data/lib/rdoc/parser/ruby.rb +18 -26
- data/lib/rdoc/ri/store.rb +1 -5
- data/lib/rdoc/top_level.rb +4 -0
- data/test/test_rdoc_class_module.rb +38 -0
- data/test/test_rdoc_parser_ruby.rb +289 -3
- data/test/test_rdoc_ri_store.rb +27 -0
- data/test/test_rdoc_top_level.rb +81 -0
- metadata +4 -4
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
=== 3.8 / ??
|
2
|
+
|
3
|
+
* Minor enhancements
|
4
|
+
* RDoc::Parser::C can now discover methods on ENV and ARGF.
|
5
|
+
* RDoc::Parser::C now knows about rb_cSocket and rb_mDL.
|
6
|
+
* Bug fixes
|
7
|
+
* Updating Object in an ri data store with new data now removes methods,
|
8
|
+
includes, constants and aliases.
|
9
|
+
|
1
10
|
=== 3.7 / 2011-06-27
|
2
11
|
|
3
12
|
* Minor enhancements
|
data/lib/rdoc.rb
CHANGED
data/lib/rdoc/class_module.rb
CHANGED
@@ -115,7 +115,7 @@ class RDoc::ClassModule < RDoc::Context
|
|
115
115
|
# across multiple runs.
|
116
116
|
|
117
117
|
def add_comment comment, location
|
118
|
-
return if comment.empty?
|
118
|
+
return if comment.empty? or not document_self
|
119
119
|
|
120
120
|
original = comment
|
121
121
|
|
@@ -328,7 +328,10 @@ class RDoc::ClassModule < RDoc::Context
|
|
328
328
|
@comment = @comment_location = document
|
329
329
|
end
|
330
330
|
|
331
|
-
|
331
|
+
cm = class_module
|
332
|
+
other_files = cm.in_files
|
333
|
+
|
334
|
+
merge_collections attributes, cm.attributes, other_files do |add, attr|
|
332
335
|
if add then
|
333
336
|
add_attribute attr
|
334
337
|
else
|
@@ -337,7 +340,7 @@ class RDoc::ClassModule < RDoc::Context
|
|
337
340
|
end
|
338
341
|
end
|
339
342
|
|
340
|
-
merge_collections constants,
|
343
|
+
merge_collections constants, cm.constants, other_files do |add, const|
|
341
344
|
if add then
|
342
345
|
add_constant const
|
343
346
|
else
|
@@ -346,7 +349,7 @@ class RDoc::ClassModule < RDoc::Context
|
|
346
349
|
end
|
347
350
|
end
|
348
351
|
|
349
|
-
merge_collections includes,
|
352
|
+
merge_collections includes, cm.includes, other_files do |add, incl|
|
350
353
|
if add then
|
351
354
|
add_include incl
|
352
355
|
else
|
@@ -354,7 +357,7 @@ class RDoc::ClassModule < RDoc::Context
|
|
354
357
|
end
|
355
358
|
end
|
356
359
|
|
357
|
-
merge_collections method_list,
|
360
|
+
merge_collections method_list, cm.method_list, other_files do |add, meth|
|
358
361
|
if add then
|
359
362
|
add_method meth
|
360
363
|
else
|
@@ -367,15 +370,37 @@ class RDoc::ClassModule < RDoc::Context
|
|
367
370
|
end
|
368
371
|
|
369
372
|
##
|
370
|
-
# Merges collection +mine+ with +other+ preferring other.
|
371
|
-
|
372
|
-
|
373
|
+
# Merges collection +mine+ with +other+ preferring other. +other_files+ is
|
374
|
+
# used to help determine which items should be deleted.
|
375
|
+
#
|
376
|
+
# Yields whether the item should be added or removed (true or false) and the
|
377
|
+
# item to be added or removed.
|
378
|
+
#
|
379
|
+
# merge_collections things, other.things, other.in_files do |add, thing|
|
380
|
+
# if add then
|
381
|
+
# # add the thing
|
382
|
+
# else
|
383
|
+
# # remove the thing
|
384
|
+
# end
|
385
|
+
# end
|
386
|
+
|
387
|
+
def merge_collections mine, other, other_files, &block # :nodoc:
|
373
388
|
my_things = mine. group_by { |thing| thing.file }
|
374
389
|
other_things = other.group_by { |thing| thing.file }
|
375
390
|
|
391
|
+
my_things.delete_if do |file, things|
|
392
|
+
next false unless other_files.include? file
|
393
|
+
|
394
|
+
things.each do |thing|
|
395
|
+
yield false, thing
|
396
|
+
end
|
397
|
+
|
398
|
+
true
|
399
|
+
end
|
400
|
+
|
376
401
|
other_things.each do |file, things|
|
377
402
|
my_things[file].each { |thing| yield false, thing } if
|
378
|
-
my_things.include?
|
403
|
+
my_things.include?(file)
|
379
404
|
|
380
405
|
things.each do |thing|
|
381
406
|
yield true, thing
|
data/lib/rdoc/known_classes.rb
CHANGED
@@ -26,6 +26,7 @@ module RDoc
|
|
26
26
|
"rb_cRange" => "Range",
|
27
27
|
"rb_cRegexp" => "Regexp",
|
28
28
|
"rb_cRubyVM" => "RubyVM",
|
29
|
+
"rb_cSocket" => "Socket",
|
29
30
|
"rb_cString" => "String",
|
30
31
|
"rb_cStruct" => "Struct",
|
31
32
|
"rb_cSymbol" => "Symbol",
|
@@ -58,6 +59,7 @@ module RDoc
|
|
58
59
|
"rb_eZeroDivError" => "ZeroDivError",
|
59
60
|
|
60
61
|
"rb_mComparable" => "Comparable",
|
62
|
+
"rb_mDL" => "DL",
|
61
63
|
"rb_mEnumerable" => "Enumerable",
|
62
64
|
"rb_mErrno" => "Errno",
|
63
65
|
"rb_mFileTest" => "FileTest",
|
data/lib/rdoc/parser/c.rb
CHANGED
@@ -340,8 +340,6 @@ class RDoc::Parser::C < RDoc::Parser
|
|
340
340
|
# Ignore top-object and weird struct.c dynamic stuff
|
341
341
|
next if var_name == "ruby_top_self"
|
342
342
|
next if var_name == "nstr"
|
343
|
-
next if var_name == "envtbl"
|
344
|
-
next if var_name == "argf" # it'd be nice to handle this one
|
345
343
|
|
346
344
|
var_name = "rb_cObject" if var_name == "rb_mKernel"
|
347
345
|
handle_method(type, var_name, meth_name, function, param_count,
|
data/lib/rdoc/parser/ruby.rb
CHANGED
@@ -478,7 +478,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
478
478
|
|
479
479
|
read_documentation_modifiers att, RDoc::ATTR_MODIFIERS
|
480
480
|
|
481
|
-
context.add_attribute att
|
481
|
+
context.add_attribute att
|
482
482
|
|
483
483
|
@stats.add_attribute att
|
484
484
|
else
|
@@ -499,6 +499,8 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
499
499
|
|
500
500
|
tmp = RDoc::CodeObject.new
|
501
501
|
read_documentation_modifiers tmp, RDoc::ATTR_MODIFIERS
|
502
|
+
# TODO In most other places we let the context keep track of document_self
|
503
|
+
# and add found items appropriately but here we do not. I'm not sure why.
|
502
504
|
return unless tmp.document_self
|
503
505
|
|
504
506
|
case tk.name
|
@@ -557,7 +559,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
557
559
|
al.line = line_no
|
558
560
|
|
559
561
|
read_documentation_modifiers al, RDoc::ATTR_MODIFIERS
|
560
|
-
context.add_alias al
|
562
|
+
context.add_alias al
|
561
563
|
@stats.add_alias al
|
562
564
|
|
563
565
|
al
|
@@ -633,7 +635,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
633
635
|
cls.offset = offset
|
634
636
|
cls.line = line_no
|
635
637
|
|
636
|
-
cls.add_comment comment, @top_level
|
638
|
+
cls.add_comment comment, @top_level
|
637
639
|
|
638
640
|
@top_level.add_to_classes_or_modules cls
|
639
641
|
@stats.add_class cls
|
@@ -657,7 +659,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
657
659
|
|
658
660
|
# notify :nodoc: all if not a constant-named class/module
|
659
661
|
# (and remove any comment)
|
660
|
-
unless name =~ /\A(::)?[A-Z]/
|
662
|
+
unless name =~ /\A(::)?[A-Z]/ then
|
661
663
|
other.document_self = nil
|
662
664
|
other.document_children = false
|
663
665
|
other.clear_comment
|
@@ -758,7 +760,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
758
760
|
read_documentation_modifiers con, RDoc::CONSTANT_MODIFIERS
|
759
761
|
|
760
762
|
@stats.add_constant con
|
761
|
-
container.add_constant con
|
763
|
+
container.add_constant con
|
762
764
|
true
|
763
765
|
end
|
764
766
|
|
@@ -797,7 +799,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
797
799
|
|
798
800
|
return unless meth.name
|
799
801
|
|
800
|
-
container.add_method meth
|
802
|
+
container.add_method meth
|
801
803
|
|
802
804
|
meth.comment = comment
|
803
805
|
|
@@ -818,7 +820,6 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
818
820
|
att.line = line_no
|
819
821
|
|
820
822
|
container.add_attribute att
|
821
|
-
|
822
823
|
@stats.add_attribute att
|
823
824
|
end
|
824
825
|
|
@@ -882,7 +883,6 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
882
883
|
|
883
884
|
tmp = RDoc::CodeObject.new
|
884
885
|
read_documentation_modifiers tmp, RDoc::ATTR_MODIFIERS
|
885
|
-
return unless tmp.document_self
|
886
886
|
|
887
887
|
if comment.sub!(/^# +:?(attr(_reader|_writer|_accessor)?): *(\S*).*?\n/i, '') then
|
888
888
|
rw = case $1
|
@@ -969,7 +969,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
969
969
|
|
970
970
|
extract_call_seq comment, meth
|
971
971
|
|
972
|
-
container.add_method meth
|
972
|
+
container.add_method meth
|
973
973
|
|
974
974
|
last_tk = tk
|
975
975
|
|
@@ -1238,7 +1238,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
1238
1238
|
mod.record_location @top_level
|
1239
1239
|
|
1240
1240
|
read_documentation_modifiers mod, RDoc::CLASS_MODIFIERS
|
1241
|
-
mod.add_comment comment, @top_level
|
1241
|
+
mod.add_comment comment, @top_level
|
1242
1242
|
parse_statements(mod)
|
1243
1243
|
|
1244
1244
|
@top_level.add_to_classes_or_modules mod
|
@@ -1341,23 +1341,15 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
1341
1341
|
end
|
1342
1342
|
|
1343
1343
|
when TkDEF then
|
1344
|
-
|
1345
|
-
parse_method container, single, tk, comment
|
1346
|
-
else
|
1347
|
-
nest += 1
|
1348
|
-
end
|
1344
|
+
parse_method container, single, tk, comment
|
1349
1345
|
|
1350
1346
|
when TkCONSTANT then
|
1351
|
-
|
1352
|
-
|
1353
|
-
try_parse_comment = true
|
1354
|
-
end
|
1347
|
+
unless parse_constant container, tk, comment then
|
1348
|
+
try_parse_comment = true
|
1355
1349
|
end
|
1356
1350
|
|
1357
1351
|
when TkALIAS then
|
1358
|
-
|
1359
|
-
parse_alias container, single, tk, comment
|
1360
|
-
end
|
1352
|
+
parse_alias container, single, tk, comment unless current_method
|
1361
1353
|
|
1362
1354
|
when TkYIELD then
|
1363
1355
|
if current_method.nil? then
|
@@ -1395,12 +1387,11 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
1395
1387
|
when /^attr_(reader|writer|accessor)$/ then
|
1396
1388
|
parse_attr_accessor container, single, tk, comment
|
1397
1389
|
when 'alias_method' then
|
1398
|
-
parse_alias container, single, tk, comment
|
1399
|
-
container.document_self
|
1390
|
+
parse_alias container, single, tk, comment
|
1400
1391
|
when 'require', 'include' then
|
1401
1392
|
# ignore
|
1402
1393
|
else
|
1403
|
-
if
|
1394
|
+
if comment =~ /\A#\#$/ then
|
1404
1395
|
case comment
|
1405
1396
|
when /^# +:?attr(_reader|_writer|_accessor)?:/ then
|
1406
1397
|
parse_meta_attr container, single, tk, comment
|
@@ -1523,11 +1514,12 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
1523
1514
|
end
|
1524
1515
|
|
1525
1516
|
##
|
1526
|
-
# Parses statements
|
1517
|
+
# Parses statements in the top-level +container+
|
1527
1518
|
|
1528
1519
|
def parse_top_level_statements(container)
|
1529
1520
|
comment = collect_first_comment
|
1530
1521
|
look_for_directives_in(container, comment)
|
1522
|
+
# HACK move if to RDoc::Context#comment=
|
1531
1523
|
container.comment = comment if container.document_self unless comment.empty?
|
1532
1524
|
parse_statements container, NORMAL, nil, comment
|
1533
1525
|
end
|
data/lib/rdoc/ri/store.rb
CHANGED
@@ -268,11 +268,7 @@ class RDoc::RI::Store
|
|
268
268
|
path = class_file full_name
|
269
269
|
|
270
270
|
begin
|
271
|
-
disk_klass =
|
272
|
-
|
273
|
-
open path, 'rb' do |io|
|
274
|
-
disk_klass = Marshal.load io.read
|
275
|
-
end
|
271
|
+
disk_klass = load_class full_name
|
276
272
|
|
277
273
|
klass = disk_klass.merge klass
|
278
274
|
rescue Errno::ENOENT
|
data/lib/rdoc/top_level.rb
CHANGED
@@ -322,6 +322,7 @@ class RDoc::TopLevel < RDoc::Context
|
|
322
322
|
# Adds +an_alias+ to +Object+ instead of +self+.
|
323
323
|
|
324
324
|
def add_alias(an_alias)
|
325
|
+
object_class.record_location self
|
325
326
|
return an_alias unless @document_self
|
326
327
|
object_class.add_alias an_alias
|
327
328
|
end
|
@@ -330,6 +331,7 @@ class RDoc::TopLevel < RDoc::Context
|
|
330
331
|
# Adds +constant+ to +Object+ instead of +self+.
|
331
332
|
|
332
333
|
def add_constant(constant)
|
334
|
+
object_class.record_location self
|
333
335
|
return constant unless @document_self
|
334
336
|
object_class.add_constant constant
|
335
337
|
end
|
@@ -338,6 +340,7 @@ class RDoc::TopLevel < RDoc::Context
|
|
338
340
|
# Adds +include+ to +Object+ instead of +self+.
|
339
341
|
|
340
342
|
def add_include(include)
|
343
|
+
object_class.record_location self
|
341
344
|
return include unless @document_self
|
342
345
|
object_class.add_include include
|
343
346
|
end
|
@@ -346,6 +349,7 @@ class RDoc::TopLevel < RDoc::Context
|
|
346
349
|
# Adds +method+ to +Object+ instead of +self+.
|
347
350
|
|
348
351
|
def add_method(method)
|
352
|
+
object_class.record_location self
|
349
353
|
return method unless @document_self
|
350
354
|
object_class.add_method method
|
351
355
|
end
|
@@ -40,6 +40,17 @@ class TestRDocClassModule < XrefTestCase
|
|
40
40
|
assert_equal "comment 1\n---\ncomment 2\n---\n* comment 3", cm.comment
|
41
41
|
end
|
42
42
|
|
43
|
+
def test_add_comment_stopdoc
|
44
|
+
tl = RDoc::TopLevel.new 'file.rb'
|
45
|
+
|
46
|
+
cm = RDoc::ClassModule.new 'Klass'
|
47
|
+
cm.stop_doc
|
48
|
+
|
49
|
+
cm.add_comment '# comment 1', tl
|
50
|
+
|
51
|
+
assert_empty cm.comment
|
52
|
+
end
|
53
|
+
|
43
54
|
def test_ancestors
|
44
55
|
assert_equal [@parent], @child.ancestors
|
45
56
|
end
|
@@ -258,6 +269,33 @@ class TestRDocClassModule < XrefTestCase
|
|
258
269
|
assert_equal expected, cm1.attributes.sort
|
259
270
|
end
|
260
271
|
|
272
|
+
def test_merge_collections_drop
|
273
|
+
tl = RDoc::TopLevel.new 'file'
|
274
|
+
|
275
|
+
cm1 = RDoc::ClassModule.new 'C'
|
276
|
+
cm1.record_location tl
|
277
|
+
|
278
|
+
const = cm1.add_constant RDoc::Constant.new('CONST', nil, nil)
|
279
|
+
const.record_location tl
|
280
|
+
|
281
|
+
cm2 = RDoc::ClassModule.new 'C'
|
282
|
+
cm2.record_location tl
|
283
|
+
|
284
|
+
added = []
|
285
|
+
removed = []
|
286
|
+
|
287
|
+
cm1.merge_collections cm1.constants, cm2.constants, cm2.in_files do |add, c|
|
288
|
+
if add then
|
289
|
+
added << c
|
290
|
+
else
|
291
|
+
removed << c
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
assert_empty added
|
296
|
+
assert_equal [const], removed
|
297
|
+
end
|
298
|
+
|
261
299
|
def test_merge_comment
|
262
300
|
tl1 = RDoc::TopLevel.new 'one.rb'
|
263
301
|
tl2 = RDoc::TopLevel.new 'two.rb'
|
@@ -437,6 +437,21 @@ class C; end
|
|
437
437
|
assert alas.singleton
|
438
438
|
end
|
439
439
|
|
440
|
+
def test_parse_alias_stopdoc
|
441
|
+
klass = RDoc::NormalClass.new 'Foo'
|
442
|
+
klass.parent = @top_level
|
443
|
+
klass.stop_doc
|
444
|
+
|
445
|
+
util_parser "alias :next= :bar"
|
446
|
+
|
447
|
+
tk = @parser.get_tk
|
448
|
+
|
449
|
+
@parser.parse_alias klass, RDoc::Parser::Ruby::NORMAL, tk, 'comment'
|
450
|
+
|
451
|
+
assert_empty klass.aliases
|
452
|
+
assert_empty klass.unmatched_alias_lists
|
453
|
+
end
|
454
|
+
|
440
455
|
def test_parse_alias_meta
|
441
456
|
klass = RDoc::NormalClass.new 'Foo'
|
442
457
|
klass.parent = @top_level
|
@@ -472,6 +487,22 @@ class C; end
|
|
472
487
|
assert_equal 1, foo.line
|
473
488
|
end
|
474
489
|
|
490
|
+
def test_parse_attr_stopdoc
|
491
|
+
klass = RDoc::NormalClass.new 'Foo'
|
492
|
+
klass.parent = @top_level
|
493
|
+
klass.stop_doc
|
494
|
+
|
495
|
+
comment = "##\n# my attr\n"
|
496
|
+
|
497
|
+
util_parser "attr :foo, :bar"
|
498
|
+
|
499
|
+
tk = @parser.get_tk
|
500
|
+
|
501
|
+
@parser.parse_attr klass, RDoc::Parser::Ruby::NORMAL, tk, comment
|
502
|
+
|
503
|
+
assert_empty klass.attributes
|
504
|
+
end
|
505
|
+
|
475
506
|
def test_parse_attr_accessor
|
476
507
|
klass = RDoc::NormalClass.new 'Foo'
|
477
508
|
klass.parent = @top_level
|
@@ -515,6 +546,22 @@ class C; end
|
|
515
546
|
assert_equal 0, klass.attributes.length
|
516
547
|
end
|
517
548
|
|
549
|
+
def test_parse_attr_accessor_stopdoc
|
550
|
+
klass = RDoc::NormalClass.new 'Foo'
|
551
|
+
klass.parent = @top_level
|
552
|
+
klass.stop_doc
|
553
|
+
|
554
|
+
comment = "##\n# my attr\n"
|
555
|
+
|
556
|
+
util_parser "attr_accessor :foo, :bar"
|
557
|
+
|
558
|
+
tk = @parser.get_tk
|
559
|
+
|
560
|
+
@parser.parse_attr_accessor klass, RDoc::Parser::Ruby::NORMAL, tk, comment
|
561
|
+
|
562
|
+
assert_empty klass.attributes
|
563
|
+
end
|
564
|
+
|
518
565
|
def test_parse_attr_accessor_writer
|
519
566
|
klass = RDoc::NormalClass.new 'Foo'
|
520
567
|
klass.parent = @top_level
|
@@ -620,6 +667,22 @@ class C; end
|
|
620
667
|
assert_equal @top_level, foo.file
|
621
668
|
end
|
622
669
|
|
670
|
+
def test_parse_meta_attr_stopdoc
|
671
|
+
klass = RDoc::NormalClass.new 'Foo'
|
672
|
+
klass.parent = @top_level
|
673
|
+
klass.stop_doc
|
674
|
+
|
675
|
+
comment = "##\n# :attr: \n# my method\n"
|
676
|
+
|
677
|
+
util_parser "add_my_method :foo, :bar"
|
678
|
+
|
679
|
+
tk = @parser.get_tk
|
680
|
+
|
681
|
+
@parser.parse_meta_attr klass, RDoc::Parser::Ruby::NORMAL, tk, comment
|
682
|
+
|
683
|
+
assert_empty klass.attributes
|
684
|
+
end
|
685
|
+
|
623
686
|
def test_parse_meta_attr_writer
|
624
687
|
klass = RDoc::NormalClass.new 'Foo'
|
625
688
|
klass.parent = @top_level
|
@@ -640,7 +703,7 @@ class C; end
|
|
640
703
|
end
|
641
704
|
|
642
705
|
def test_parse_class
|
643
|
-
comment = "##\n# my
|
706
|
+
comment = "##\n# my class\n"
|
644
707
|
|
645
708
|
util_parser "class Foo\nend"
|
646
709
|
|
@@ -650,7 +713,7 @@ class C; end
|
|
650
713
|
|
651
714
|
foo = @top_level.classes.first
|
652
715
|
assert_equal 'Foo', foo.full_name
|
653
|
-
assert_equal 'my
|
716
|
+
assert_equal 'my class', foo.comment
|
654
717
|
assert_equal [@top_level], foo.in_files
|
655
718
|
assert_equal 0, foo.offset
|
656
719
|
assert_equal 1, foo.line
|
@@ -706,6 +769,42 @@ end
|
|
706
769
|
assert_equal 2, foo.method_list.length
|
707
770
|
end
|
708
771
|
|
772
|
+
def test_parse_class_nodoc
|
773
|
+
comment = "##\n# my class\n"
|
774
|
+
|
775
|
+
util_parser "class Foo # :nodoc:\nend"
|
776
|
+
|
777
|
+
tk = @parser.get_tk
|
778
|
+
|
779
|
+
@parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, comment
|
780
|
+
|
781
|
+
foo = @top_level.classes.first
|
782
|
+
assert_equal 'Foo', foo.full_name
|
783
|
+
assert_empty foo.comment
|
784
|
+
assert_equal [@top_level], foo.in_files
|
785
|
+
assert_equal 0, foo.offset
|
786
|
+
assert_equal 1, foo.line
|
787
|
+
end
|
788
|
+
|
789
|
+
def test_parse_class_stopdoc
|
790
|
+
@top_level.stop_doc
|
791
|
+
|
792
|
+
comment = "##\n# my class\n"
|
793
|
+
|
794
|
+
util_parser "class Foo\nend"
|
795
|
+
|
796
|
+
tk = @parser.get_tk
|
797
|
+
|
798
|
+
@parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, comment
|
799
|
+
|
800
|
+
foo = @top_level.classes.first
|
801
|
+
assert_equal 'Foo', foo.full_name
|
802
|
+
assert_equal 'my class', foo.comment
|
803
|
+
assert_equal [@top_level], foo.in_files
|
804
|
+
assert_equal 0, foo.offset
|
805
|
+
assert_equal 1, foo.line
|
806
|
+
end
|
807
|
+
|
709
808
|
def test_parse_multi_ghost_methods
|
710
809
|
util_parser <<-'CLASS'
|
711
810
|
class Foo
|
@@ -785,6 +884,38 @@ end
|
|
785
884
|
assert_equal 'my module', foo.comment
|
786
885
|
end
|
787
886
|
|
887
|
+
def test_parse_module_nodoc
|
888
|
+
@top_level.stop_doc
|
889
|
+
|
890
|
+
comment = "##\n# my module\n"
|
891
|
+
|
892
|
+
util_parser "module Foo # :nodoc:\nend"
|
893
|
+
|
894
|
+
tk = @parser.get_tk
|
895
|
+
|
896
|
+
@parser.parse_module @top_level, RDoc::Parser::Ruby::NORMAL, tk, comment
|
897
|
+
|
898
|
+
foo = @top_level.modules.first
|
899
|
+
assert_equal 'Foo', foo.full_name
|
900
|
+
assert_empty foo.comment
|
901
|
+
end
|
902
|
+
|
903
|
+
def test_parse_module_stopdoc
|
904
|
+
@top_level.stop_doc
|
905
|
+
|
906
|
+
comment = "##\n# my module\n"
|
907
|
+
|
908
|
+
util_parser "module Foo\nend"
|
909
|
+
|
910
|
+
tk = @parser.get_tk
|
911
|
+
|
912
|
+
@parser.parse_module @top_level, RDoc::Parser::Ruby::NORMAL, tk, comment
|
913
|
+
|
914
|
+
foo = @top_level.modules.first
|
915
|
+
assert_equal 'Foo', foo.full_name
|
916
|
+
assert_equal 'my module', foo.comment
|
917
|
+
end
|
918
|
+
|
788
919
|
def test_parse_class_colon3
|
789
920
|
code = <<-CODE
|
790
921
|
class A
|
@@ -976,6 +1107,22 @@ EOF
|
|
976
1107
|
assert_equal klass.current_section, foo.section
|
977
1108
|
end
|
978
1109
|
|
1110
|
+
def test_parse_comment_attr_stopdoc
|
1111
|
+
klass = RDoc::NormalClass.new 'Foo'
|
1112
|
+
klass.parent = @top_level
|
1113
|
+
klass.stop_doc
|
1114
|
+
|
1115
|
+
comment = "##\n# :attr: foo\n# my attr\n"
|
1116
|
+
|
1117
|
+
util_parser "\n"
|
1118
|
+
|
1119
|
+
tk = @parser.get_tk
|
1120
|
+
|
1121
|
+
@parser.parse_comment klass, tk, comment
|
1122
|
+
|
1123
|
+
assert_empty klass.attributes
|
1124
|
+
end
|
1125
|
+
|
979
1126
|
def test_parse_comment_method
|
980
1127
|
klass = RDoc::NormalClass.new 'Foo'
|
981
1128
|
klass.parent = @top_level
|
@@ -1021,6 +1168,22 @@ EOF
|
|
1021
1168
|
assert_equal stream, foo.token_stream
|
1022
1169
|
end
|
1023
1170
|
|
1171
|
+
def test_parse_comment_method_stopdoc
|
1172
|
+
klass = RDoc::NormalClass.new 'Foo'
|
1173
|
+
klass.parent = @top_level
|
1174
|
+
klass.stop_doc
|
1175
|
+
|
1176
|
+
comment = "##\n# :method: foo\n# my method\n"
|
1177
|
+
|
1178
|
+
util_parser "\n"
|
1179
|
+
|
1180
|
+
tk = @parser.get_tk
|
1181
|
+
|
1182
|
+
@parser.parse_comment klass, tk, comment
|
1183
|
+
|
1184
|
+
assert_empty klass.method_list
|
1185
|
+
end
|
1186
|
+
|
1024
1187
|
def test_parse_constant
|
1025
1188
|
util_top_level
|
1026
1189
|
|
@@ -1084,6 +1247,21 @@ EOF
|
|
1084
1247
|
assert_equal top_bar, bar.find_module_named('A')
|
1085
1248
|
end
|
1086
1249
|
|
1250
|
+
def test_parse_constant_stopdoc
|
1251
|
+
util_top_level
|
1252
|
+
|
1253
|
+
klass = @top_level.add_class RDoc::NormalClass, 'Foo'
|
1254
|
+
klass.stop_doc
|
1255
|
+
|
1256
|
+
util_parser "A = v"
|
1257
|
+
|
1258
|
+
tk = @parser.get_tk
|
1259
|
+
|
1260
|
+
@parser.parse_constant klass, tk, ''
|
1261
|
+
|
1262
|
+
assert_empty klass.constants
|
1263
|
+
end
|
1264
|
+
|
1087
1265
|
def test_parse_include
|
1088
1266
|
klass = RDoc::NormalClass.new 'C'
|
1089
1267
|
klass.parent = @top_level
|
@@ -1249,6 +1427,22 @@ end
|
|
1249
1427
|
assert_equal @top_level, foo.file
|
1250
1428
|
end
|
1251
1429
|
|
1430
|
+
def test_parse_meta_method_stopdoc
|
1431
|
+
klass = RDoc::NormalClass.new 'Foo'
|
1432
|
+
klass.parent = @top_level
|
1433
|
+
klass.stop_doc
|
1434
|
+
|
1435
|
+
comment = "##\n# my method\n"
|
1436
|
+
|
1437
|
+
util_parser "add_my_method :foo, :bar\nadd_my_method :baz"
|
1438
|
+
|
1439
|
+
tk = @parser.get_tk
|
1440
|
+
|
1441
|
+
@parser.parse_meta_method klass, RDoc::Parser::Ruby::NORMAL, tk, comment
|
1442
|
+
|
1443
|
+
assert_empty klass.method_list
|
1444
|
+
end
|
1445
|
+
|
1252
1446
|
def test_parse_meta_method_unknown
|
1253
1447
|
klass = RDoc::NormalClass.new 'Foo'
|
1254
1448
|
comment = "##\n# my method\n"
|
@@ -1464,6 +1658,22 @@ end
|
|
1464
1658
|
assert_equal '(arg1, arg2, arg3)', foo.params
|
1465
1659
|
end
|
1466
1660
|
|
1661
|
+
def test_parse_method_stopdoc
|
1662
|
+
klass = RDoc::NormalClass.new 'Foo'
|
1663
|
+
klass.parent = @top_level
|
1664
|
+
klass.stop_doc
|
1665
|
+
|
1666
|
+
comment = "##\n# my method\n"
|
1667
|
+
|
1668
|
+
util_parser "def foo() :bar end"
|
1669
|
+
|
1670
|
+
tk = @parser.get_tk
|
1671
|
+
|
1672
|
+
@parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, comment
|
1673
|
+
|
1674
|
+
assert_empty klass.method_list
|
1675
|
+
end
|
1676
|
+
|
1467
1677
|
def test_parse_method_toplevel
|
1468
1678
|
klass = @top_level
|
1469
1679
|
|
@@ -1879,6 +2089,69 @@ end
|
|
1879
2089
|
assert_equal 1, @top_level.requires.length
|
1880
2090
|
end
|
1881
2091
|
|
2092
|
+
def test_parse_statements_stopdoc_TkALIAS
|
2093
|
+
util_top_level
|
2094
|
+
|
2095
|
+
klass = @top_level.add_class RDoc::NormalClass, 'Foo'
|
2096
|
+
|
2097
|
+
util_parser "\n# :stopdoc:\nalias old new"
|
2098
|
+
|
2099
|
+
@parser.parse_statements klass, RDoc::Parser::Ruby::NORMAL, nil
|
2100
|
+
|
2101
|
+
assert_empty klass.aliases
|
2102
|
+
assert_empty klass.unmatched_alias_lists
|
2103
|
+
end
|
2104
|
+
|
2105
|
+
def test_parse_statements_stopdoc_TkIDENTIFIER_alias_method
|
2106
|
+
util_top_level
|
2107
|
+
|
2108
|
+
klass = @top_level.add_class RDoc::NormalClass, 'Foo'
|
2109
|
+
|
2110
|
+
util_parser "\n# :stopdoc:\nalias_method :old :new"
|
2111
|
+
|
2112
|
+
@parser.parse_statements klass, RDoc::Parser::Ruby::NORMAL, nil
|
2113
|
+
|
2114
|
+
assert_empty klass.aliases
|
2115
|
+
assert_empty klass.unmatched_alias_lists
|
2116
|
+
end
|
2117
|
+
|
2118
|
+
def test_parse_statements_stopdoc_TkIDENTIFIER_metaprogrammed
|
2119
|
+
util_top_level
|
2120
|
+
|
2121
|
+
klass = @top_level.add_class RDoc::NormalClass, 'Foo'
|
2122
|
+
|
2123
|
+
util_parser "\n# :stopdoc:\n# attr :meta"
|
2124
|
+
|
2125
|
+
@parser.parse_statements klass, RDoc::Parser::Ruby::NORMAL, nil
|
2126
|
+
|
2127
|
+
assert_empty klass.method_list
|
2128
|
+
assert_empty klass.attributes
|
2129
|
+
end
|
2130
|
+
|
2131
|
+
def test_parse_statements_stopdoc_TkCONSTANT
|
2132
|
+
util_top_level
|
2133
|
+
|
2134
|
+
klass = @top_level.add_class RDoc::NormalClass, 'Foo'
|
2135
|
+
|
2136
|
+
util_parser "\n# :stopdoc:\nA = v"
|
2137
|
+
|
2138
|
+
@parser.parse_statements klass, RDoc::Parser::Ruby::NORMAL, nil
|
2139
|
+
|
2140
|
+
assert_empty klass.constants
|
2141
|
+
end
|
2142
|
+
|
2143
|
+
def test_parse_statements_stopdoc_TkDEF
|
2144
|
+
util_top_level
|
2145
|
+
|
2146
|
+
klass = @top_level.add_class RDoc::NormalClass, 'Foo'
|
2147
|
+
|
2148
|
+
util_parser "\n# :stopdoc:\ndef m\n end"
|
2149
|
+
|
2150
|
+
@parser.parse_statements klass, RDoc::Parser::Ruby::NORMAL, nil
|
2151
|
+
|
2152
|
+
assert_empty klass.method_list
|
2153
|
+
end
|
2154
|
+
|
1882
2155
|
def test_parse_statements_while_begin
|
1883
2156
|
util_parser <<-RUBY
|
1884
2157
|
class A
|
@@ -1924,7 +2197,7 @@ end
|
|
1924
2197
|
assert_equal nil, @parser.parse_symbol_in_arg
|
1925
2198
|
end
|
1926
2199
|
|
1927
|
-
def
|
2200
|
+
def test_parse_statements_alias_method
|
1928
2201
|
content = <<-CONTENT
|
1929
2202
|
class A
|
1930
2203
|
alias_method :a, :[] unless c
|
@@ -1939,6 +2212,19 @@ end
|
|
1939
2212
|
util_parser content
|
1940
2213
|
|
1941
2214
|
@parser.parse_statements @top_level
|
2215
|
+
|
2216
|
+
# HACK where are the assertions?
|
2217
|
+
end
|
2218
|
+
|
2219
|
+
def test_parse_top_level_statements_stopdoc
|
2220
|
+
@top_level.stop_doc
|
2221
|
+
content = "# this is the top-level comment"
|
2222
|
+
|
2223
|
+
util_parser content
|
2224
|
+
|
2225
|
+
@parser.parse_top_level_statements @top_level
|
2226
|
+
|
2227
|
+
assert_empty @top_level.comment
|
1942
2228
|
end
|
1943
2229
|
|
1944
2230
|
def test_parse_yield_in_braces_with_parens
|
data/test/test_rdoc_ri_store.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'minitest/autorun'
|
3
|
+
require 'rdoc/rdoc'
|
3
4
|
require 'rdoc/ri'
|
4
5
|
require 'rdoc/markup'
|
5
6
|
require 'tmpdir'
|
@@ -392,6 +393,32 @@ class TestRDocRIStore < MiniTest::Unit::TestCase
|
|
392
393
|
assert_equal document, s.load_class('Object').comment
|
393
394
|
end
|
394
395
|
|
396
|
+
# This is a functional test
|
397
|
+
def test_save_class_merge_constant
|
398
|
+
tl = RDoc::TopLevel.new 'file.rb'
|
399
|
+
klass = RDoc::NormalClass.new 'C'
|
400
|
+
klass.add_comment 'comment', tl
|
401
|
+
|
402
|
+
const = klass.add_constant RDoc::Constant.new('CONST', nil, nil)
|
403
|
+
const.record_location tl
|
404
|
+
|
405
|
+
@s.save_class klass
|
406
|
+
|
407
|
+
RDoc::RDoc.reset
|
408
|
+
|
409
|
+
klass2 = RDoc::NormalClass.new 'C'
|
410
|
+
klass2.record_location tl
|
411
|
+
|
412
|
+
s = RDoc::RI::Store.new @tmpdir
|
413
|
+
s.save_class klass2
|
414
|
+
|
415
|
+
s = RDoc::RI::Store.new @tmpdir
|
416
|
+
|
417
|
+
result = s.load_class 'C'
|
418
|
+
|
419
|
+
assert_empty result.constants
|
420
|
+
end
|
421
|
+
|
395
422
|
def test_save_class_methods
|
396
423
|
@s.save_class @klass
|
397
424
|
|
data/test/test_rdoc_top_level.rb
CHANGED
@@ -98,6 +98,87 @@ class TestRDocTopLevel < XrefTestCase
|
|
98
98
|
assert_empty RDoc::TopLevel.files
|
99
99
|
end
|
100
100
|
|
101
|
+
def test_add_alias
|
102
|
+
a = RDoc::Alias.new nil, 'old', 'new', nil
|
103
|
+
@top_level.add_alias a
|
104
|
+
|
105
|
+
object = RDoc::TopLevel.find_class_named 'Object'
|
106
|
+
expected = { '#old' => [a] }
|
107
|
+
assert_equal expected, object.unmatched_alias_lists
|
108
|
+
assert_includes object.in_files, @top_level
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_add_alias_nodoc
|
112
|
+
@top_level.document_self = false
|
113
|
+
|
114
|
+
a = RDoc::Alias.new nil, 'old', 'new', nil
|
115
|
+
@top_level.add_alias a
|
116
|
+
|
117
|
+
object = RDoc::TopLevel.find_class_named('Object')
|
118
|
+
assert_empty object.unmatched_alias_lists
|
119
|
+
assert_includes object.in_files, @top_level
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_add_constant
|
123
|
+
const = RDoc::Constant.new 'C', nil, nil
|
124
|
+
@top_level.add_constant const
|
125
|
+
|
126
|
+
object = RDoc::TopLevel.find_class_named 'Object'
|
127
|
+
assert_equal [const], object.constants
|
128
|
+
assert_includes object.in_files, @top_level
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_add_constant_nodoc
|
132
|
+
@top_level.document_self = false
|
133
|
+
|
134
|
+
const = RDoc::Constant.new 'C', nil, nil
|
135
|
+
@top_level.add_constant const
|
136
|
+
|
137
|
+
object = RDoc::TopLevel.find_class_named 'Object'
|
138
|
+
assert_empty object.constants
|
139
|
+
assert_includes object.in_files, @top_level
|
140
|
+
end
|
141
|
+
|
142
|
+
def test_add_include
|
143
|
+
include = RDoc::Include.new 'C', nil
|
144
|
+
@top_level.add_include include
|
145
|
+
|
146
|
+
object = RDoc::TopLevel.find_class_named 'Object'
|
147
|
+
assert_equal [include], object.includes
|
148
|
+
assert_includes object.in_files, @top_level
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_add_include_nodoc
|
152
|
+
@top_level.document_self = false
|
153
|
+
|
154
|
+
include = RDoc::Include.new 'C', nil
|
155
|
+
@top_level.add_include include
|
156
|
+
|
157
|
+
object = RDoc::TopLevel.find_class_named('Object')
|
158
|
+
assert_empty object.includes
|
159
|
+
assert_includes object.in_files, @top_level
|
160
|
+
end
|
161
|
+
|
162
|
+
def test_add_method
|
163
|
+
method = RDoc::AnyMethod.new nil, 'm'
|
164
|
+
@top_level.add_method method
|
165
|
+
|
166
|
+
object = RDoc::TopLevel.find_class_named 'Object'
|
167
|
+
assert_equal [method], object.method_list
|
168
|
+
assert_includes object.in_files, @top_level
|
169
|
+
end
|
170
|
+
|
171
|
+
def test_add_method_stopdoc
|
172
|
+
@top_level.document_self = false
|
173
|
+
|
174
|
+
method = RDoc::AnyMethod.new nil, 'm'
|
175
|
+
@top_level.add_method method
|
176
|
+
|
177
|
+
object = RDoc::TopLevel.find_class_named('Object')
|
178
|
+
assert_empty object.method_list
|
179
|
+
assert_includes object.in_files, @top_level
|
180
|
+
end
|
181
|
+
|
101
182
|
def test_base_name
|
102
183
|
assert_equal 'top_level.rb', @top_level.base_name
|
103
184
|
end
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: "3.
|
8
|
+
- 8
|
9
|
+
version: "3.8"
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Eric Hodel
|
@@ -38,7 +38,7 @@ cert_chain:
|
|
38
38
|
x52qPcexcYZR7w==
|
39
39
|
-----END CERTIFICATE-----
|
40
40
|
|
41
|
-
date: 2011-06-
|
41
|
+
date: 2011-06-29 00:00:00 Z
|
42
42
|
dependencies:
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: minitest
|
metadata.gz.sig
CHANGED
Binary file
|