From 681a1900490b82171c4a0cf1cc65a1e1bcdadc4c Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Sun, 2 Mar 2025 21:52:36 +0000 Subject: [PATCH 1/3] Remove unused class_dir attribute In all generators it only returns nil. --- lib/rdoc/code_object/class_module.rb | 2 +- lib/rdoc/generator/darkfish.rb | 8 -------- lib/rdoc/generator/json_index.rb | 9 +-------- lib/rdoc/generator/pot.rb | 5 ----- test/rdoc/support/test_case.rb | 1 - test/rdoc/test_rdoc_generator_json_index.rb | 4 ---- test/rdoc/xref_test_case.rb | 1 - 7 files changed, 2 insertions(+), 28 deletions(-) diff --git a/lib/rdoc/code_object/class_module.rb b/lib/rdoc/code_object/class_module.rb index 9e6909ac7d..5089af3040 100644 --- a/lib/rdoc/code_object/class_module.rb +++ b/lib/rdoc/code_object/class_module.rb @@ -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(nil) end ## diff --git a/lib/rdoc/generator/darkfish.rb b/lib/rdoc/generator/darkfish.rb index 45795eb78e..ef61dbffa9 100644 --- a/lib/rdoc/generator/darkfish.rb +++ b/lib/rdoc/generator/darkfish.rb @@ -188,14 +188,6 @@ def debug_msg *msg # 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 diff --git a/lib/rdoc/generator/json_index.rb b/lib/rdoc/generator/json_index.rb index c454910d5c..9abda58e5d 100644 --- a/lib/rdoc/generator/json_index.rb +++ b/lib/rdoc/generator/json_index.rb @@ -87,7 +87,7 @@ class RDoc::Generator::JsonIndex ## # Creates a new generator. +parent_generator+ is used to determine the - # class_dir and file_dir of links in the output index. + # file_dir of links in the output index. # # +options+ are the same options passed to the parent generator. @@ -265,13 +265,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 diff --git a/lib/rdoc/generator/pot.rb b/lib/rdoc/generator/pot.rb index b0b7c07179..6ceca16640 100644 --- a/lib/rdoc/generator/pot.rb +++ b/lib/rdoc/generator/pot.rb @@ -81,11 +81,6 @@ def generate end end - # :nodoc: - def class_dir - nil - end - private def extract_messages extractor = MessageExtractor.new(@store) diff --git a/test/rdoc/support/test_case.rb b/test/rdoc/support/test_case.rb index de5885ee02..d1c3c24651 100644 --- a/test/rdoc/support/test_case.rb +++ b/test/rdoc/support/test_case.rb @@ -54,7 +54,6 @@ def setup @rdoc.options = RDoc::Options.new g = Object.new - def g.class_dir() end def g.file_dir() end @rdoc.generator = g diff --git a/test/rdoc/test_rdoc_generator_json_index.rb b/test/rdoc/test_rdoc_generator_json_index.rb index 71b5cd969a..c9dbe71f6b 100644 --- a/test/rdoc/test_rdoc_generator_json_index.rb +++ b/test/rdoc/test_rdoc_generator_json_index.rb @@ -80,10 +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 diff --git a/test/rdoc/xref_test_case.rb b/test/rdoc/xref_test_case.rb index 9c0b7129aa..6003b6dc93 100644 --- a/test/rdoc/xref_test_case.rb +++ b/test/rdoc/xref_test_case.rb @@ -30,7 +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 From d1ba4cae901b2ce79d89ac4da69e4c87a1bac38e Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Sun, 2 Mar 2025 21:58:21 +0000 Subject: [PATCH 2/3] Remove unused file_dir attribute Similar to the class_dir attribute, the file_dir attribute never returns anything but nil. --- lib/rdoc/code_object/top_level.rb | 2 +- lib/rdoc/generator/darkfish.rb | 8 -------- lib/rdoc/generator/json_index.rb | 11 +---------- test/rdoc/support/test_case.rb | 4 +--- test/rdoc/test_rdoc_generator_json_index.rb | 4 ---- test/rdoc/xref_test_case.rb | 1 - 6 files changed, 3 insertions(+), 27 deletions(-) diff --git a/lib/rdoc/code_object/top_level.rb b/lib/rdoc/code_object/top_level.rb index 57091ba08b..f7292fc9fc 100644 --- a/lib/rdoc/code_object/top_level.rb +++ b/lib/rdoc/code_object/top_level.rb @@ -246,7 +246,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(nil) end def pretty_print q # :nodoc: diff --git a/lib/rdoc/generator/darkfish.rb b/lib/rdoc/generator/darkfish.rb index ef61dbffa9..e4e20831f3 100644 --- a/lib/rdoc/generator/darkfish.rb +++ b/lib/rdoc/generator/darkfish.rb @@ -184,14 +184,6 @@ def debug_msg *msg $stderr.puts(*msg) 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. diff --git a/lib/rdoc/generator/json_index.rb b/lib/rdoc/generator/json_index.rb index 9abda58e5d..6404cbb312 100644 --- a/lib/rdoc/generator/json_index.rb +++ b/lib/rdoc/generator/json_index.rb @@ -86,9 +86,7 @@ class RDoc::Generator::JsonIndex attr_reader :index # :nodoc: ## - # Creates a new generator. +parent_generator+ is used to determine the - # 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 @@ -265,13 +263,6 @@ def index_pages end end - ## - # The directory files are written to - - def file_dir - @parent_generator.file_dir - end - def reset files, classes # :nodoc: @files = files @classes = classes diff --git a/test/rdoc/support/test_case.rb b/test/rdoc/support/test_case.rb index d1c3c24651..fcdc514424 100644 --- a/test/rdoc/support/test_case.rb +++ b/test/rdoc/support/test_case.rb @@ -53,9 +53,7 @@ def setup @rdoc.store = @store @rdoc.options = RDoc::Options.new - g = Object.new - def g.file_dir() end - @rdoc.generator = g + @rdoc.generator = Object.new RDoc::Markup::PreProcess.reset end diff --git a/test/rdoc/test_rdoc_generator_json_index.rb b/test/rdoc/test_rdoc_generator_json_index.rb index c9dbe71f6b..8a50deab89 100644 --- a/test/rdoc/test_rdoc_generator_json_index.rb +++ b/test/rdoc/test_rdoc_generator_json_index.rb @@ -80,10 +80,6 @@ def test_build_index assert_equal expected, index end - def test_file_dir - assert_equal @darkfish.file_dir, @g.file_dir - end - def test_generate @g.generate diff --git a/test/rdoc/xref_test_case.rb b/test/rdoc/xref_test_case.rb index 6003b6dc93..2daba10232 100644 --- a/test/rdoc/xref_test_case.rb +++ b/test/rdoc/xref_test_case.rb @@ -30,7 +30,6 @@ def setup @top_levels.push @example_md generator = Object.new - def generator.file_dir() nil end @rdoc.options = @options @rdoc.generator = generator From 3feff8cad8d750580ae83a5f8e7000d31708b989 Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Sun, 2 Mar 2025 22:01:53 +0000 Subject: [PATCH 3/3] Remove unused prefix argument from http_url methods Since their prefix argument is always nil, we can stop passing it and simplify the methods accordingly. --- lib/rdoc/code_object/class_module.rb | 2 +- lib/rdoc/code_object/context.rb | 4 ++-- lib/rdoc/code_object/top_level.rb | 8 +++----- test/rdoc/test_rdoc_top_level.rb | 4 ++-- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/rdoc/code_object/class_module.rb b/lib/rdoc/code_object/class_module.rb index 5089af3040..c2ad779b7a 100644 --- a/lib/rdoc/code_object/class_module.rb +++ b/lib/rdoc/code_object/class_module.rb @@ -634,7 +634,7 @@ def parse comment_location # Path to this class or module for use with HTML generator output. def path - http_url(nil) + http_url end ## diff --git a/lib/rdoc/code_object/context.rb b/lib/rdoc/code_object/context.rb index c688d562c3..061eb47ad3 100644 --- a/lib/rdoc/code_object/context.rb +++ b/lib/rdoc/code_object/context.rb @@ -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 =~ /<