Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused class_dir and file_dir attributes from generators #1304

Merged
merged 3 commits into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rdoc/code_object/class_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ def parse comment_location
# Path to this class or module for use with HTML generator output.

def path
http_url @store.rdoc.generator.class_dir
http_url
end

##
Expand Down
4 changes: 2 additions & 2 deletions lib/rdoc/code_object/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -973,10 +973,10 @@ def fully_documented?
##
# URL for this with a +prefix+

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

File.join(*path.compact) + '.html'
end
Expand Down
8 changes: 3 additions & 5 deletions lib/rdoc/code_object/top_level.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,8 @@ def hash
##
# URL for this with a +prefix+

def http_url(prefix)
path = [prefix, @relative_name.tr('.', '_')]

File.join(*path.compact) + '.html'
def http_url
@relative_name.tr('.', '_') + '.html'
end

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

def path
http_url @store.rdoc.generator.file_dir
http_url
end

def pretty_print q # :nodoc:
Expand Down
16 changes: 0 additions & 16 deletions lib/rdoc/generator/darkfish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,22 +184,6 @@ def debug_msg *msg
$stderr.puts(*msg)
end

##
# Directory where generated class HTML files live relative to the output
# dir.

def class_dir
nil
end

##
# Directory where generated class HTML files live relative to the output
# dir.

def file_dir
nil
end

##
# Create the directories the generated docs will live in if they don't
# already exist.
Expand Down
18 changes: 1 addition & 17 deletions lib/rdoc/generator/json_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ class RDoc::Generator::JsonIndex
attr_reader :index # :nodoc:

##
# Creates a new generator. +parent_generator+ is used to determine the
# class_dir and file_dir of links in the output index.
#
# Creates a new generator.
# +options+ are the same options passed to the parent generator.

def initialize parent_generator, options
Expand Down Expand Up @@ -265,20 +263,6 @@ def index_pages
end
end

##
# The directory classes are written to

def class_dir
@parent_generator.class_dir
end

##
# The directory files are written to

def file_dir
@parent_generator.file_dir
end

def reset files, classes # :nodoc:
@files = files
@classes = classes
Expand Down
5 changes: 0 additions & 5 deletions lib/rdoc/generator/pot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,6 @@ def generate
end
end

# :nodoc:
def class_dir
nil
end

private
def extract_messages
extractor = MessageExtractor.new(@store)
Expand Down
5 changes: 1 addition & 4 deletions test/rdoc/support/test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ def setup
@rdoc.store = @store
@rdoc.options = RDoc::Options.new

g = Object.new
def g.class_dir() end
def g.file_dir() end
@rdoc.generator = g
@rdoc.generator = Object.new

RDoc::Markup::PreProcess.reset
end
Expand Down
8 changes: 0 additions & 8 deletions test/rdoc/test_rdoc_generator_json_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,6 @@ def test_build_index
assert_equal expected, index
end

def test_class_dir
assert_equal @darkfish.class_dir, @g.class_dir
end

def test_file_dir
assert_equal @darkfish.file_dir, @g.file_dir
end

def test_generate
@g.generate

Expand Down
4 changes: 2 additions & 2 deletions test/rdoc/test_rdoc_top_level.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ def test_hash
end

def test_http_url
assert_equal 'prefix/path/top_level_rb.html', @top_level.http_url('prefix')
assert_equal 'path/top_level_rb.html', @top_level.http_url

other_level = @store.add_file 'path.other/level.rb'
assert_equal 'prefix/path_other/level_rb.html', other_level.http_url('prefix')
assert_equal 'path_other/level_rb.html', other_level.http_url
end

def test_last_modified
Expand Down
2 changes: 0 additions & 2 deletions test/rdoc/xref_test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ def setup
@top_levels.push @example_md

generator = Object.new
def generator.class_dir() nil end
def generator.file_dir() nil end
@rdoc.options = @options
@rdoc.generator = generator

Expand Down
Loading