Skip to content

Commit 694987b

Browse files
authored
Remove unused class_dir and file_dir attributes from generators (#1304)
These generator methods are either not defined, or return a fixed `nil` value. Therefore, we can remove them and simplify some downstream logics accordingly.
1 parent 20d71f1 commit 694987b

File tree

10 files changed

+10
-62
lines changed

10 files changed

+10
-62
lines changed

lib/rdoc/code_object/class_module.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ def parse comment_location
634634
# Path to this class or module for use with HTML generator output.
635635

636636
def path
637-
http_url @store.rdoc.generator.class_dir
637+
http_url
638638
end
639639

640640
##

lib/rdoc/code_object/context.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -973,10 +973,10 @@ def fully_documented?
973973
##
974974
# URL for this with a +prefix+
975975

976-
def http_url(prefix)
976+
def http_url
977977
path = name_for_path
978978
path = path.gsub(/<<\s*(\w*)/, 'from-\1') if path =~ /<</
979-
path = [prefix] + path.split('::')
979+
path = path.split('::')
980980

981981
File.join(*path.compact) + '.html'
982982
end

lib/rdoc/code_object/top_level.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,8 @@ def hash
173173
##
174174
# URL for this with a +prefix+
175175

176-
def http_url(prefix)
177-
path = [prefix, @relative_name.tr('.', '_')]
178-
179-
File.join(*path.compact) + '.html'
176+
def http_url
177+
@relative_name.tr('.', '_') + '.html'
180178
end
181179

182180
def inspect # :nodoc:
@@ -246,7 +244,7 @@ def page_name
246244
# Path to this file for use with HTML generator output.
247245

248246
def path
249-
http_url @store.rdoc.generator.file_dir
247+
http_url
250248
end
251249

252250
def pretty_print q # :nodoc:

lib/rdoc/generator/darkfish.rb

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -184,22 +184,6 @@ def debug_msg *msg
184184
$stderr.puts(*msg)
185185
end
186186

187-
##
188-
# Directory where generated class HTML files live relative to the output
189-
# dir.
190-
191-
def class_dir
192-
nil
193-
end
194-
195-
##
196-
# Directory where generated class HTML files live relative to the output
197-
# dir.
198-
199-
def file_dir
200-
nil
201-
end
202-
203187
##
204188
# Create the directories the generated docs will live in if they don't
205189
# already exist.

lib/rdoc/generator/json_index.rb

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ class RDoc::Generator::JsonIndex
8686
attr_reader :index # :nodoc:
8787

8888
##
89-
# Creates a new generator. +parent_generator+ is used to determine the
90-
# class_dir and file_dir of links in the output index.
91-
#
89+
# Creates a new generator.
9290
# +options+ are the same options passed to the parent generator.
9391

9492
def initialize parent_generator, options
@@ -265,20 +263,6 @@ def index_pages
265263
end
266264
end
267265

268-
##
269-
# The directory classes are written to
270-
271-
def class_dir
272-
@parent_generator.class_dir
273-
end
274-
275-
##
276-
# The directory files are written to
277-
278-
def file_dir
279-
@parent_generator.file_dir
280-
end
281-
282266
def reset files, classes # :nodoc:
283267
@files = files
284268
@classes = classes

lib/rdoc/generator/pot.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,6 @@ def generate
8181
end
8282
end
8383

84-
# :nodoc:
85-
def class_dir
86-
nil
87-
end
88-
8984
private
9085
def extract_messages
9186
extractor = MessageExtractor.new(@store)

test/rdoc/support/test_case.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,7 @@ def setup
5353
@rdoc.store = @store
5454
@rdoc.options = RDoc::Options.new
5555

56-
g = Object.new
57-
def g.class_dir() end
58-
def g.file_dir() end
59-
@rdoc.generator = g
56+
@rdoc.generator = Object.new
6057

6158
RDoc::Markup::PreProcess.reset
6259
end

test/rdoc/test_rdoc_generator_json_index.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,6 @@ def test_build_index
8080
assert_equal expected, index
8181
end
8282

83-
def test_class_dir
84-
assert_equal @darkfish.class_dir, @g.class_dir
85-
end
86-
87-
def test_file_dir
88-
assert_equal @darkfish.file_dir, @g.file_dir
89-
end
90-
9183
def test_generate
9284
@g.generate
9385

test/rdoc/test_rdoc_top_level.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,10 @@ def test_hash
156156
end
157157

158158
def test_http_url
159-
assert_equal 'prefix/path/top_level_rb.html', @top_level.http_url('prefix')
159+
assert_equal 'path/top_level_rb.html', @top_level.http_url
160160

161161
other_level = @store.add_file 'path.other/level.rb'
162-
assert_equal 'prefix/path_other/level_rb.html', other_level.http_url('prefix')
162+
assert_equal 'path_other/level_rb.html', other_level.http_url
163163
end
164164

165165
def test_last_modified

test/rdoc/xref_test_case.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ def setup
3030
@top_levels.push @example_md
3131

3232
generator = Object.new
33-
def generator.class_dir() nil end
34-
def generator.file_dir() nil end
3533
@rdoc.options = @options
3634
@rdoc.generator = generator
3735

0 commit comments

Comments
 (0)