Skip to content

Commit 2d579c0

Browse files
committed
* lib/rdoc/generator/darkfish.rb: Fixed debug message. RDoc bug #174
by Thomas Leitner. * lib/rdoc/store.rb: Fixed deletion of ri attribute data when a class was loaded then saved. RDoc bug #171 by Thomas Leitner. * test/rdoc/test_rdoc_store.rb: Test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38930 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent f1ef3d6 commit 2d579c0

File tree

4 files changed

+59
-9
lines changed

4 files changed

+59
-9
lines changed

ChangeLog

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
Fri Jan 25 09:14:43 2013 Eric Hodel <[email protected]>
2+
3+
* lib/rdoc/generator/darkfish.rb: Fixed debug message. RDoc bug #174
4+
by Thomas Leitner.
5+
6+
* lib/rdoc/store.rb: Fixed deletion of ri attribute data when a class
7+
was loaded then saved. RDoc bug #171 by Thomas Leitner.
8+
* test/rdoc/test_rdoc_store.rb: Test for above.
9+
110
Thu Jan 24 19:55:25 2013 Shota Fukumori <[email protected]>
211

312
* NEWS (yaml): Write about bundled libyaml.

lib/rdoc/generator/darkfish.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ def generate_servlet_not_found path
453453
template_file = @template_dir + 'servlet_not_found.rhtml'
454454
return unless template_file.exist?
455455

456-
debug_msg "Rendering the servlet root page..."
456+
debug_msg "Rendering the servlet 404 Not Found page..."
457457

458458
rel_prefix = rel_prefix = ''
459459
search_index_rel_prefix = rel_prefix

lib/rdoc/store.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -819,13 +819,13 @@ def save_class klass
819819
@cache[:ancestors][full_name] ||= []
820820
@cache[:ancestors][full_name].concat ancestors
821821

822-
attributes = klass.attributes.map do |attribute|
822+
attribute_definitions = klass.attributes.map do |attribute|
823823
"#{attribute.definition} #{attribute.name}"
824824
end
825825

826-
unless attributes.empty? then
826+
unless attribute_definitions.empty? then
827827
@cache[:attributes][full_name] ||= []
828-
@cache[:attributes][full_name].concat attributes
828+
@cache[:attributes][full_name].concat attribute_definitions
829829
end
830830

831831
to_delete = []
@@ -839,13 +839,15 @@ def save_class klass
839839

840840
class_methods = class_methods. map { |method| method.name }
841841
instance_methods = instance_methods.map { |method| method.name }
842+
attribute_names = klass.attributes.map { |attr| attr.name }
842843

843844
old = @cache[:class_methods][full_name] - class_methods
844845
to_delete.concat old.map { |method|
845846
method_file full_name, "#{full_name}::#{method}"
846847
}
847848

848-
old = @cache[:instance_methods][full_name] - instance_methods
849+
old = @cache[:instance_methods][full_name] -
850+
instance_methods - attribute_names
849851
to_delete.concat old.map { |method|
850852
method_file full_name, "#{full_name}##{method}"
851853
}

test/rdoc/test_rdoc_store.rb

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,7 @@ def test_save_class_delete
778778
@s.save_method @klass, @meth
779779
@s.save_method @klass, @meth_bang
780780
@s.save_method @klass, @cmeth
781+
@s.save_method @klass, @attr
781782
@s.save_cache
782783

783784
klass = RDoc::NormalClass.new 'Object'
@@ -799,11 +800,15 @@ def test_save_class_delete
799800

800801
assert_cache({ 'Object' => %w[replace] }, {},
801802
{ 'Object' => %w[attr_accessor\ attr] }, %w[Object],
802-
'Object' => OBJECT_ANCESTORS)
803+
'Object' => OBJECT_ANCESTORS)
803804

804-
refute File.exist? @s.method_file(@klass.full_name, @meth.full_name)
805-
refute File.exist? @s.method_file(@klass.full_name, @meth_bang.full_name)
806-
refute File.exist? @s.method_file(@klass.full_name, @cmeth.full_name)
805+
# assert these files were deleted
806+
refute_file @s.method_file(@klass.full_name, @meth.full_name)
807+
refute_file @s.method_file(@klass.full_name, @meth_bang.full_name)
808+
refute_file @s.method_file(@klass.full_name, @cmeth.full_name)
809+
810+
# assert these files were not deleted
811+
assert_file @s.method_file(@klass.full_name, @attr.full_name)
807812
end
808813

809814
def test_save_class_dry_run
@@ -815,6 +820,40 @@ def test_save_class_dry_run
815820
refute_file File.join(@tmpdir, 'Object', 'cdesc-Object.ri')
816821
end
817822

823+
def test_save_class_loaded
824+
@s.save
825+
826+
assert_directory File.join(@tmpdir, 'Object')
827+
assert_file File.join(@tmpdir, 'Object', 'cdesc-Object.ri')
828+
829+
assert_file @s.method_file(@klass.full_name, @attr.full_name)
830+
assert_file @s.method_file(@klass.full_name, @cmeth.full_name)
831+
assert_file @s.method_file(@klass.full_name, @meth.full_name)
832+
assert_file @s.method_file(@klass.full_name, @meth_bang.full_name)
833+
834+
s = RDoc::Store.new @s.path
835+
s.load_cache
836+
837+
loaded = s.load_class 'Object'
838+
839+
assert_equal @klass, loaded
840+
841+
s.save_class loaded
842+
843+
s = RDoc::Store.new @s.path
844+
s.load_cache
845+
846+
reloaded = s.load_class 'Object'
847+
848+
assert_equal @klass, reloaded
849+
850+
# assert these files were not deleted. Bug #171
851+
assert_file s.method_file(@klass.full_name, @attr.full_name)
852+
assert_file s.method_file(@klass.full_name, @cmeth.full_name)
853+
assert_file s.method_file(@klass.full_name, @meth.full_name)
854+
assert_file s.method_file(@klass.full_name, @meth_bang.full_name)
855+
end
856+
818857
def test_save_class_merge
819858
@s.save_class @klass
820859

0 commit comments

Comments
 (0)