ruby-changes:26879
From: drbrain <ko1@a...>
Date: Fri, 25 Jan 2013 09:21:42 +0900 (JST)
Subject: [ruby-changes:26879] drbrain:r38930 (trunk): * lib/rdoc/generator/darkfish.rb: Fixed debug message. RDoc bug #174
drbrain 2013-01-25 09:15:08 +0900 (Fri, 25 Jan 2013) New Revision: 38930 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38930 Log: * 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. Modified files: trunk/ChangeLog trunk/lib/rdoc/generator/darkfish.rb trunk/lib/rdoc/store.rb trunk/test/rdoc/test_rdoc_store.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 38929) +++ ChangeLog (revision 38930) @@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Jan 25 09:14:43 2013 Eric Hodel <drbrain@s...> + + * 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. + Thu Jan 24 19:55:25 2013 Shota Fukumori <her@s...> * NEWS (yaml): Write about bundled libyaml. Index: lib/rdoc/generator/darkfish.rb =================================================================== --- lib/rdoc/generator/darkfish.rb (revision 38929) +++ lib/rdoc/generator/darkfish.rb (revision 38930) @@ -453,7 +453,7 @@ class RDoc::Generator::Darkfish https://github.com/ruby/ruby/blob/trunk/lib/rdoc/generator/darkfish.rb#L453 template_file = @template_dir + 'servlet_not_found.rhtml' return unless template_file.exist? - debug_msg "Rendering the servlet root page..." + debug_msg "Rendering the servlet 404 Not Found page..." rel_prefix = rel_prefix = '' search_index_rel_prefix = rel_prefix Index: lib/rdoc/store.rb =================================================================== --- lib/rdoc/store.rb (revision 38929) +++ lib/rdoc/store.rb (revision 38930) @@ -819,13 +819,13 @@ class RDoc::Store https://github.com/ruby/ruby/blob/trunk/lib/rdoc/store.rb#L819 @cache[:ancestors][full_name] ||= [] @cache[:ancestors][full_name].concat ancestors - attributes = klass.attributes.map do |attribute| + attribute_definitions = klass.attributes.map do |attribute| "#{attribute.definition} #{attribute.name}" end - unless attributes.empty? then + unless attribute_definitions.empty? then @cache[:attributes][full_name] ||= [] - @cache[:attributes][full_name].concat attributes + @cache[:attributes][full_name].concat attribute_definitions end to_delete = [] @@ -839,13 +839,15 @@ class RDoc::Store https://github.com/ruby/ruby/blob/trunk/lib/rdoc/store.rb#L839 class_methods = class_methods. map { |method| method.name } instance_methods = instance_methods.map { |method| method.name } + attribute_names = klass.attributes.map { |attr| attr.name } old = @cache[:class_methods][full_name] - class_methods to_delete.concat old.map { |method| method_file full_name, "#{full_name}::#{method}" } - old = @cache[:instance_methods][full_name] - instance_methods + old = @cache[:instance_methods][full_name] - + instance_methods - attribute_names to_delete.concat old.map { |method| method_file full_name, "#{full_name}##{method}" } Index: test/rdoc/test_rdoc_store.rb =================================================================== --- test/rdoc/test_rdoc_store.rb (revision 38929) +++ test/rdoc/test_rdoc_store.rb (revision 38930) @@ -778,6 +778,7 @@ class TestRDocStore < XrefTestCase https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_store.rb#L778 @s.save_method @klass, @meth @s.save_method @klass, @meth_bang @s.save_method @klass, @cmeth + @s.save_method @klass, @attr @s.save_cache klass = RDoc::NormalClass.new 'Object' @@ -799,11 +800,15 @@ class TestRDocStore < XrefTestCase https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_store.rb#L800 assert_cache({ 'Object' => %w[replace] }, {}, { 'Object' => %w[attr_accessor\ attr] }, %w[Object], - 'Object' => OBJECT_ANCESTORS) + 'Object' => OBJECT_ANCESTORS) - refute File.exist? @s.method_file(@klass.full_name, @meth.full_name) - refute File.exist? @s.method_file(@klass.full_name, @meth_bang.full_name) - refute File.exist? @s.method_file(@klass.full_name, @cmeth.full_name) + # assert these files were deleted + refute_file @s.method_file(@klass.full_name, @meth.full_name) + refute_file @s.method_file(@klass.full_name, @meth_bang.full_name) + refute_file @s.method_file(@klass.full_name, @cmeth.full_name) + + # assert these files were not deleted + assert_file @s.method_file(@klass.full_name, @attr.full_name) end def test_save_class_dry_run @@ -815,6 +820,40 @@ class TestRDocStore < XrefTestCase https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_store.rb#L820 refute_file File.join(@tmpdir, 'Object', 'cdesc-Object.ri') end + def test_save_class_loaded + @s.save + + assert_directory File.join(@tmpdir, 'Object') + assert_file File.join(@tmpdir, 'Object', 'cdesc-Object.ri') + + assert_file @s.method_file(@klass.full_name, @attr.full_name) + assert_file @s.method_file(@klass.full_name, @cmeth.full_name) + assert_file @s.method_file(@klass.full_name, @meth.full_name) + assert_file @s.method_file(@klass.full_name, @meth_bang.full_name) + + s = RDoc::Store.new @s.path + s.load_cache + + loaded = s.load_class 'Object' + + assert_equal @klass, loaded + + s.save_class loaded + + s = RDoc::Store.new @s.path + s.load_cache + + reloaded = s.load_class 'Object' + + assert_equal @klass, reloaded + + # assert these files were not deleted. Bug #171 + assert_file s.method_file(@klass.full_name, @attr.full_name) + assert_file s.method_file(@klass.full_name, @cmeth.full_name) + assert_file s.method_file(@klass.full_name, @meth.full_name) + assert_file s.method_file(@klass.full_name, @meth_bang.full_name) + end + def test_save_class_merge @s.save_class @klass -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/