From eedf2e77ba1b42b05b16b93c1bf9533f1cb6115a Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Sun, 16 Mar 2025 00:02:14 +0000 Subject: [PATCH 01/10] Remove unused CodeObject#each_parent --- lib/rdoc/code_object.rb | 14 -------------- test/rdoc/test_rdoc_code_object.rb | 10 ---------- 2 files changed, 24 deletions(-) diff --git a/lib/rdoc/code_object.rb b/lib/rdoc/code_object.rb index 37dcadd3d7..9090ec374e 100644 --- a/lib/rdoc/code_object.rb +++ b/lib/rdoc/code_object.rb @@ -217,20 +217,6 @@ def done_documenting=(value) @document_children = @document_self end - ## - # Yields each parent of this CodeObject. See also - # RDoc::ClassModule#each_ancestor - - def each_parent - code_object = self - - while code_object = code_object.parent do - yield code_object - end - - self - end - ## # File name where this CodeObject was found. # diff --git a/test/rdoc/test_rdoc_code_object.rb b/test/rdoc/test_rdoc_code_object.rb index 6d0cbc5cd4..df7d893923 100644 --- a/test/rdoc/test_rdoc_code_object.rb +++ b/test/rdoc/test_rdoc_code_object.rb @@ -201,16 +201,6 @@ def test_done_documenting refute @co.done_documenting end - def test_each_parent - parents = [] - - @parent_m.each_parent do |code_object| - parents << code_object - end - - assert_equal [@parent, @xref_data], parents - end - def test_file_name assert_nil @co.file_name From 103b8790478deda4c0b60e550e03cabbc48e9b60 Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Sun, 16 Mar 2025 00:03:19 +0000 Subject: [PATCH 02/10] Remove single-use CodeObject#parent_file_name --- lib/rdoc/code_object.rb | 7 ------- lib/rdoc/code_object/require.rb | 2 +- test/rdoc/test_rdoc_code_object.rb | 5 ----- 3 files changed, 1 insertion(+), 13 deletions(-) diff --git a/lib/rdoc/code_object.rb b/lib/rdoc/code_object.rb index 9090ec374e..be6e187634 100644 --- a/lib/rdoc/code_object.rb +++ b/lib/rdoc/code_object.rb @@ -313,13 +313,6 @@ def parent end end - ## - # File name of our parent - - def parent_file_name - @parent ? @parent.base_name : '(unknown)' - end - ## # Name of our parent diff --git a/lib/rdoc/code_object/require.rb b/lib/rdoc/code_object/require.rb index 05e26b84b0..f47e3b1534 100644 --- a/lib/rdoc/code_object/require.rb +++ b/lib/rdoc/code_object/require.rb @@ -24,7 +24,7 @@ def inspect # :nodoc: self.class, object_id, @name, - parent_file_name, + @parent ? @parent.base_name : '(unknown)' ] end diff --git a/test/rdoc/test_rdoc_code_object.rb b/test/rdoc/test_rdoc_code_object.rb index df7d893923..429def790b 100644 --- a/test/rdoc/test_rdoc_code_object.rb +++ b/test/rdoc/test_rdoc_code_object.rb @@ -265,11 +265,6 @@ def test_metadata assert_equal 'not_rdoc', @co.metadata['markup'] end - def test_parent_file_name - assert_equal '(unknown)', @co.parent_file_name - assert_equal 'xref_data.rb', @c1.parent_file_name - end - def test_parent_name assert_equal '(unknown)', @co.parent_name assert_equal 'xref_data.rb', @c1.parent_name From 74eba1bc8bbbc6cbe1ada736299d3bb860671e2d Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Sun, 16 Mar 2025 00:05:29 +0000 Subject: [PATCH 03/10] Remove unused CodeObject#viewer --- lib/rdoc/code_object.rb | 7 ------- lib/rdoc/code_object/class_module.rb | 1 - test/rdoc/test_rdoc_parser_ruby.rb | 4 ---- 3 files changed, 12 deletions(-) diff --git a/lib/rdoc/code_object.rb b/lib/rdoc/code_object.rb index be6e187634..1460433b1f 100644 --- a/lib/rdoc/code_object.rb +++ b/lib/rdoc/code_object.rb @@ -90,13 +90,6 @@ class RDoc::CodeObject attr_reader :store - ## - # We are the model of the code, but we know that at some point we will be - # worked on by viewers. By implementing the Viewable protocol, viewers can - # associated themselves with these objects. - - attr_accessor :viewer - ## # When mixed-in to a class, this points to the Context in which it was originally defined. diff --git a/lib/rdoc/code_object/class_module.rb b/lib/rdoc/code_object/class_module.rb index e171c86f02..0af340fa26 100644 --- a/lib/rdoc/code_object/class_module.rb +++ b/lib/rdoc/code_object/class_module.rb @@ -56,7 +56,6 @@ def self.from_module class_type, mod klass.parent = mod.parent klass.section = mod.section - klass.viewer = mod.viewer klass.attributes.concat mod.attributes klass.method_list.concat mod.method_list diff --git a/test/rdoc/test_rdoc_parser_ruby.rb b/test/rdoc/test_rdoc_parser_ruby.rb index 96dbb69f8b..b39ed59ca9 100644 --- a/test/rdoc/test_rdoc_parser_ruby.rb +++ b/test/rdoc/test_rdoc_parser_ruby.rb @@ -1277,7 +1277,6 @@ def test_parse_comment_attr assert_equal @top_level, foo.file assert_equal 1, foo.line - assert_nil foo.viewer assert_equal true, foo.document_children assert_equal true, foo.document_self assert_equal false, foo.done_documenting @@ -1344,7 +1343,6 @@ def test_parse_comment_method assert_nil foo.block_params assert_nil foo.call_seq assert_nil foo.is_alias_for - assert_nil foo.viewer assert_equal true, foo.document_children assert_equal true, foo.document_self assert_equal '', foo.params @@ -1677,7 +1675,6 @@ def test_parse_meta_method assert_equal klass, foo.parent assert_equal false, foo.singleton assert_equal 'add_my_method :foo', foo.text - assert_nil foo.viewer assert_equal :public, foo.visibility assert_equal klass.current_section, foo.section @@ -1878,7 +1875,6 @@ def test_parse_method assert_nil foo.block_params assert_nil foo.call_seq assert_nil foo.is_alias_for - assert_nil foo.viewer assert_equal true, foo.document_children assert_equal true, foo.document_self assert_equal '()', foo.params From 1c1ff67a7181412efc877d386653f5fe1b84ed8b Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Sun, 16 Mar 2025 00:07:32 +0000 Subject: [PATCH 04/10] Remove unused Alias#full_old_name --- lib/rdoc/code_object/alias.rb | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lib/rdoc/code_object/alias.rb b/lib/rdoc/code_object/alias.rb index b76f0ad7e8..bd5b3ec6b5 100644 --- a/lib/rdoc/code_object/alias.rb +++ b/lib/rdoc/code_object/alias.rb @@ -59,13 +59,6 @@ def aref "#alias-#{type}-#{html_name}" end - ## - # Full old name including namespace - - def full_old_name - @full_name || "#{parent.name}#{pretty_old_name}" - end - ## # HTML id-friendly version of +#new_name+. From c38cb93766417c868d4e98ef86ba2d72849e9a83 Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Sun, 16 Mar 2025 00:21:53 +0000 Subject: [PATCH 05/10] Remove singled-used Context#find_file_named --- lib/rdoc/code_object/context.rb | 9 +-------- test/rdoc/test_rdoc_context.rb | 5 ----- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/lib/rdoc/code_object/context.rb b/lib/rdoc/code_object/context.rb index 2d2c5f90c8..2a1045ad6b 100644 --- a/lib/rdoc/code_object/context.rb +++ b/lib/rdoc/code_object/context.rb @@ -847,13 +847,6 @@ def find_external_alias_named(name) end end - ## - # Finds a file with +name+ in this context - - def find_file_named name - @store.find_file_named name - end - ## # Finds an instance method with +name+ in this context @@ -871,7 +864,7 @@ def find_local_symbol(symbol) find_attribute_named(symbol) or find_external_alias_named(symbol) or find_module_named(symbol) or - find_file_named(symbol) + @store.find_file_named(symbol) end ## diff --git a/test/rdoc/test_rdoc_context.rb b/test/rdoc/test_rdoc_context.rb index 20bb3893e9..8d1f350647 100644 --- a/test/rdoc/test_rdoc_context.rb +++ b/test/rdoc/test_rdoc_context.rb @@ -538,11 +538,6 @@ def test_find_enclosing_module_named assert_equal @c2, @c2_c3.find_enclosing_module_named('C2') end - def test_find_file_named - assert_nil @c1.find_file_named('nonexistent.rb') - assert_equal @xref_data, @c1.find_file_named(@file_name) - end - def test_find_instance_method_named assert_nil @c1.find_instance_method_named('none') From 063f696d7e8101094c3ca5b9c0bc459f29787102 Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Sun, 16 Mar 2025 00:24:24 +0000 Subject: [PATCH 06/10] Remove unnecessary `ClassModule#each_*` iterating methods --- lib/rdoc/code_object/context.rb | 28 ------------------- lib/rdoc/generator/pot/message_extractor.rb | 4 +-- .../template/darkfish/_sidebar_extends.rhtml | 2 +- .../template/darkfish/_sidebar_includes.rhtml | 2 +- lib/rdoc/stats.rb | 4 +-- lib/rdoc/store.rb | 2 +- test/rdoc/test_rdoc_class_module.rb | 6 ++-- 7 files changed, 10 insertions(+), 38 deletions(-) diff --git a/lib/rdoc/code_object/context.rb b/lib/rdoc/code_object/context.rb index 2a1045ad6b..003e438965 100644 --- a/lib/rdoc/code_object/context.rb +++ b/lib/rdoc/code_object/context.rb @@ -713,13 +713,6 @@ def display(method_attr) # :nodoc: def each_ancestor(&_) # :nodoc: end - ## - # Iterator for attributes - - def each_attribute # :yields: attribute - @attributes.each { |a| yield a } - end - ## # Iterator for classes and modules @@ -727,27 +720,6 @@ def each_classmodule(&block) # :yields: module classes_and_modules.sort.each(&block) end - ## - # Iterator for constants - - def each_constant # :yields: constant - @constants.each {|c| yield c} - end - - ## - # Iterator for included modules - - def each_include # :yields: include - @includes.each do |i| yield i end - end - - ## - # Iterator for extension modules - - def each_extend # :yields: extend - @extends.each do |e| yield e end - end - ## # Iterator for methods diff --git a/lib/rdoc/generator/pot/message_extractor.rb b/lib/rdoc/generator/pot/message_extractor.rb index 4938858bdc..463132929f 100644 --- a/lib/rdoc/generator/pot/message_extractor.rb +++ b/lib/rdoc/generator/pot/message_extractor.rb @@ -35,11 +35,11 @@ def extract_from_klass klass end end - klass.each_constant do |constant| + klass.constants.each do |constant| extract_text(constant.comment, constant.full_name) end - klass.each_attribute do |attribute| + klass.attributes.each do |attribute| extract_text(attribute.comment, attribute.full_name) end diff --git a/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml b/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml index 7602076c96..067bd62edd 100644 --- a/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +++ b/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml @@ -3,7 +3,7 @@

Extended With Modules