Skip to content

Commit d659484

Browse files
authored
Remove dead or unnecessary methods/attributes (#1315)
2 types of targets in this PR: - Completely unused methods (outside of tests, ofc) - Single-used or unnecessary methods. Like: ```rb def each_constant # :yields: constant @constants.each {|c| yield c} end ```
1 parent 56a28a1 commit d659484

18 files changed

+12
-170
lines changed

lib/rdoc/code_object.rb

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,6 @@ class RDoc::CodeObject
9090

9191
attr_reader :store
9292

93-
##
94-
# We are the model of the code, but we know that at some point we will be
95-
# worked on by viewers. By implementing the Viewable protocol, viewers can
96-
# associated themselves with these objects.
97-
98-
attr_accessor :viewer
99-
10093
##
10194
# When mixed-in to a class, this points to the Context in which it was originally defined.
10295

@@ -217,20 +210,6 @@ def done_documenting=(value)
217210
@document_children = @document_self
218211
end
219212

220-
##
221-
# Yields each parent of this CodeObject. See also
222-
# RDoc::ClassModule#each_ancestor
223-
224-
def each_parent
225-
code_object = self
226-
227-
while code_object = code_object.parent do
228-
yield code_object
229-
end
230-
231-
self
232-
end
233-
234213
##
235214
# File name where this CodeObject was found.
236215
#
@@ -327,13 +306,6 @@ def parent
327306
end
328307
end
329308

330-
##
331-
# File name of our parent
332-
333-
def parent_file_name
334-
@parent ? @parent.base_name : '(unknown)'
335-
end
336-
337309
##
338310
# Name of our parent
339311

lib/rdoc/code_object/alias.rb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,6 @@ def aref
5959
"#alias-#{type}-#{html_name}"
6060
end
6161

62-
##
63-
# Full old name including namespace
64-
65-
def full_old_name
66-
@full_name || "#{parent.name}#{pretty_old_name}"
67-
end
68-
6962
##
7063
# HTML id-friendly version of +#new_name+.
7164

lib/rdoc/code_object/class_module.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ class RDoc::ClassModule < RDoc::Context
3434

3535
attr_accessor :comment_location
3636

37-
attr_accessor :diagram # :nodoc:
38-
3937
##
4038
# Class or module this constant is an alias for
4139

@@ -56,7 +54,6 @@ def self.from_module class_type, mod
5654

5755
klass.parent = mod.parent
5856
klass.section = mod.section
59-
klass.viewer = mod.viewer
6057

6158
klass.attributes.concat mod.attributes
6259
klass.method_list.concat mod.method_list
@@ -110,7 +107,6 @@ def self.from_module class_type, mod
110107

111108
def initialize(name, superclass = nil)
112109
@constant_aliases = []
113-
@diagram = nil
114110
@is_alias_for = nil
115111
@name = name
116112
@superclass = superclass

lib/rdoc/code_object/context.rb

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -688,13 +688,6 @@ def current_section
688688
section
689689
end
690690

691-
##
692-
# Is part of this thing was defined in +file+?
693-
694-
def defined_in?(file)
695-
@in_files.include?(file)
696-
end
697-
698691
def display(method_attr) # :nodoc:
699692
if method_attr.is_a? RDoc::Attr
700693
"#{method_attr.definition} #{method_attr.pretty_name}"
@@ -713,41 +706,13 @@ def display(method_attr) # :nodoc:
713706
def each_ancestor(&_) # :nodoc:
714707
end
715708

716-
##
717-
# Iterator for attributes
718-
719-
def each_attribute # :yields: attribute
720-
@attributes.each { |a| yield a }
721-
end
722-
723709
##
724710
# Iterator for classes and modules
725711

726712
def each_classmodule(&block) # :yields: module
727713
classes_and_modules.sort.each(&block)
728714
end
729715

730-
##
731-
# Iterator for constants
732-
733-
def each_constant # :yields: constant
734-
@constants.each {|c| yield c}
735-
end
736-
737-
##
738-
# Iterator for included modules
739-
740-
def each_include # :yields: include
741-
@includes.each do |i| yield i end
742-
end
743-
744-
##
745-
# Iterator for extension modules
746-
747-
def each_extend # :yields: extend
748-
@extends.each do |e| yield e end
749-
end
750-
751716
##
752717
# Iterator for methods
753718

@@ -847,13 +812,6 @@ def find_external_alias_named(name)
847812
end
848813
end
849814

850-
##
851-
# Finds a file with +name+ in this context
852-
853-
def find_file_named name
854-
@store.find_file_named name
855-
end
856-
857815
##
858816
# Finds an instance method with +name+ in this context
859817

@@ -871,7 +829,7 @@ def find_local_symbol(symbol)
871829
find_attribute_named(symbol) or
872830
find_external_alias_named(symbol) or
873831
find_module_named(symbol) or
874-
find_file_named(symbol)
832+
@store.find_file_named(symbol)
875833
end
876834

877835
##

lib/rdoc/code_object/method_attr.rb

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -313,19 +313,6 @@ def name_prefix
313313
@singleton ? '::' : '#'
314314
end
315315

316-
##
317-
# Name for output to HTML. For class methods the full name with a "." is
318-
# used like +SomeClass.method_name+. For instance methods the class name is
319-
# used if +context+ does not match the parent.
320-
#
321-
# This is to help prevent people from using :: to call class methods.
322-
323-
def output_name context
324-
return "#{name_prefix}#{@name}" if context == parent
325-
326-
"#{parent_name}#{@singleton ? '.' : '#'}#{@name}"
327-
end
328-
329316
##
330317
# Method/attribute name with class/instance indicator
331318

lib/rdoc/code_object/require.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def inspect # :nodoc:
2424
self.class,
2525
object_id,
2626
@name,
27-
parent_file_name,
27+
@parent ? @parent.base_name : '(unknown)'
2828
]
2929
end
3030

lib/rdoc/code_object/top_level.rb

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ class RDoc::TopLevel < RDoc::Context
66

77
MARSHAL_VERSION = 0 # :nodoc:
88

9-
##
10-
# This TopLevel's File::Stat struct
11-
12-
attr_accessor :file_stat
13-
149
##
1510
# Relative name of this file
1611

@@ -28,8 +23,6 @@ class RDoc::TopLevel < RDoc::Context
2823

2924
attr_reader :classes_or_modules
3025

31-
attr_accessor :diagram # :nodoc:
32-
3326
##
3427
# The parser class that processed this file
3528

@@ -45,8 +38,6 @@ def initialize absolute_name, relative_name = absolute_name
4538
@name = nil
4639
@absolute_name = absolute_name
4740
@relative_name = relative_name
48-
@file_stat = File.stat(absolute_name) rescue nil # HACK for testing
49-
@diagram = nil
5041
@parser = nil
5142

5243
@classes_or_modules = []
@@ -186,13 +177,6 @@ def inspect # :nodoc:
186177
]
187178
end
188179

189-
##
190-
# Time this file was last modified, if known
191-
192-
def last_modified
193-
@file_stat ? file_stat.mtime : nil
194-
end
195-
196180
##
197181
# Dumps this TopLevel for use by ri. See also #marshal_load
198182

@@ -213,8 +197,6 @@ def marshal_load array # :nodoc:
213197

214198
@parser = array[2]
215199
@comment = RDoc::Comment.from_document array[3]
216-
217-
@file_stat = nil
218200
end
219201

220202
##

lib/rdoc/generator/pot/message_extractor.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ def extract_from_klass klass
3535
end
3636
end
3737

38-
klass.each_constant do |constant|
38+
klass.constants.each do |constant|
3939
extract_text(constant.comment, constant.full_name)
4040
end
4141

42-
klass.each_attribute do |attribute|
42+
klass.attributes.each do |attribute|
4343
extract_text(attribute.comment, attribute.full_name)
4444
end
4545

lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<h3>Extended With Modules</h3>
44

55
<ul class="link-list">
6-
<%- klass.each_extend do |ext| -%>
6+
<%- klass.extends.each do |ext| -%>
77
<%- unless String === ext.module then -%>
88
<li><a class="extend" href="<%= klass.aref_to ext.module.path %>"><%= ext.module.full_name %></a>
99
<%- else -%>

lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<h3>Included Modules</h3>
44

55
<ul class="link-list">
6-
<%- klass.each_include do |inc| -%>
6+
<%- klass.includes.each do |inc| -%>
77
<%- unless String === inc.module then -%>
88
<li><a class="include" href="<%= klass.aref_to inc.module.path %>"><%= inc.module.full_name %></a>
99
<%- else -%>

0 commit comments

Comments
 (0)