From ad17c3a9867b76596ef2f9af02568488c181535a Mon Sep 17 00:00:00 2001 From: Ulysse Buonomo Date: Thu, 1 Jul 2021 00:18:15 +0200 Subject: [PATCH 1/3] Relative loading for easier development This patch makes sure we only load relative code. Hence when coding or testing rdoc, we'll be sure to always be using the correct code. Discussion started at https://github.com/ruby/rdoc/pull/817. Signed-off-by: Ulysse Buonomo --- bin/console | 2 +- exe/rdoc | 1 - lib/rdoc.rb | 92 +++++++++---------- lib/rdoc/code_objects.rb | 3 +- lib/rdoc/context.rb | 2 +- lib/rdoc/generator.rb | 10 +- lib/rdoc/i18n.rb | 2 +- lib/rdoc/markup.rb | 67 +++++++------- lib/rdoc/parser.rb | 4 +- lib/rdoc/rd.rb | 7 +- lib/rdoc/rdoc.rb | 2 +- lib/rdoc/ri.rb | 9 +- lib/rdoc/ri/driver.rb | 2 +- lib/rdoc/rubygems_hook.rb | 2 +- lib/rdoc/servlet.rb | 2 +- lib/rdoc/stats.rb | 7 +- lib/rdoc/task.rb | 2 +- lib/rdoc/version.rb | 2 + test/rdoc/helper.rb | 6 +- test/rdoc/support/test_case.rb | 2 +- test/rdoc/test_rdoc_alias.rb | 3 +- test/rdoc/test_rdoc_any_method.rb | 2 +- test/rdoc/test_rdoc_class_module.rb | 3 +- test/rdoc/test_rdoc_code_object.rb | 2 +- test/rdoc/test_rdoc_constant.rb | 2 +- test/rdoc/test_rdoc_context.rb | 2 +- test/rdoc/test_rdoc_cross_reference.rb | 3 +- test/rdoc/test_rdoc_extend.rb | 3 +- test/rdoc/test_rdoc_include.rb | 3 +- test/rdoc/test_rdoc_markdown.rb | 5 +- test/rdoc/test_rdoc_markdown_test.rb | 4 +- .../rdoc/test_rdoc_markup_to_html_crossref.rb | 3 +- test/rdoc/test_rdoc_method_attr.rb | 3 +- test/rdoc/test_rdoc_normal_class.rb | 3 +- test/rdoc/test_rdoc_normal_module.rb | 3 +- test/rdoc/test_rdoc_require.rb | 3 +- test/rdoc/test_rdoc_ri_driver.rb | 4 +- test/rdoc/test_rdoc_rubygems_hook.rb | 10 +- test/rdoc/test_rdoc_store.rb | 2 +- test/rdoc/test_rdoc_task.rb | 1 - test/rdoc/test_rdoc_top_level.rb | 3 +- 41 files changed, 138 insertions(+), 155 deletions(-) diff --git a/bin/console b/bin/console index c5ee285473..23dfacec2a 100755 --- a/bin/console +++ b/bin/console @@ -1,7 +1,7 @@ #!/usr/bin/env ruby require "bundler/setup" -require "rdoc" +require_relative "../lib/rdoc" require "irb" IRB.start diff --git a/exe/rdoc b/exe/rdoc index aaa23292df..95b6eea277 100755 --- a/exe/rdoc +++ b/exe/rdoc @@ -41,4 +41,3 @@ rescue Exception => e exit 1 end - diff --git a/lib/rdoc.rb b/lib/rdoc.rb index 2d3f8c1122..b62c22576d 100644 --- a/lib/rdoc.rb +++ b/lib/rdoc.rb @@ -62,7 +62,7 @@ module RDoc class Error < RuntimeError; end - require 'rdoc/version' + require_relative 'rdoc/version' ## # Method visibilities @@ -141,61 +141,61 @@ def self.home end end - autoload :RDoc, 'rdoc/rdoc' + autoload :RDoc, "#{__dir__}/rdoc/rdoc" - autoload :CrossReference, 'rdoc/cross_reference' - autoload :ERBIO, 'rdoc/erbio' - autoload :ERBPartial, 'rdoc/erb_partial' - autoload :Encoding, 'rdoc/encoding' - autoload :Generator, 'rdoc/generator' - autoload :Options, 'rdoc/options' - autoload :Parser, 'rdoc/parser' - autoload :Servlet, 'rdoc/servlet' - autoload :RI, 'rdoc/ri' - autoload :Stats, 'rdoc/stats' - autoload :Store, 'rdoc/store' - autoload :Task, 'rdoc/task' - autoload :Text, 'rdoc/text' + autoload :CrossReference, "#{__dir__}/rdoc/cross_reference" + autoload :ERBIO, "#{__dir__}/rdoc/erbio" + autoload :ERBPartial, "#{__dir__}/rdoc/erb_partial" + autoload :Encoding, "#{__dir__}/rdoc/encoding" + autoload :Generator, "#{__dir__}/rdoc/generator" + autoload :Options, "#{__dir__}/rdoc/options" + autoload :Parser, "#{__dir__}/rdoc/parser" + autoload :Servlet, "#{__dir__}/rdoc/servlet" + autoload :RI, "#{__dir__}/rdoc/ri" + autoload :Stats, "#{__dir__}/rdoc/stats" + autoload :Store, "#{__dir__}/rdoc/store" + autoload :Task, "#{__dir__}/rdoc/task" + autoload :Text, "#{__dir__}/rdoc/text" - autoload :Markdown, 'rdoc/markdown' - autoload :Markup, 'rdoc/markup' - autoload :RD, 'rdoc/rd' - autoload :TomDoc, 'rdoc/tom_doc' + autoload :Markdown, "#{__dir__}/rdoc/markdown" + autoload :Markup, "#{__dir__}/rdoc/markup" + autoload :RD, "#{__dir__}/rdoc/rd" + autoload :TomDoc, "#{__dir__}/rdoc/tom_doc" - autoload :KNOWN_CLASSES, 'rdoc/known_classes' + autoload :KNOWN_CLASSES, "#{__dir__}/rdoc/known_classes" - autoload :TokenStream, 'rdoc/token_stream' + autoload :TokenStream, "#{__dir__}/rdoc/token_stream" - autoload :Comment, 'rdoc/comment' + autoload :Comment, "#{__dir__}/rdoc/comment" - require 'rdoc/i18n' + require_relative 'rdoc/i18n' # code objects # # We represent the various high-level code constructs that appear in Ruby # programs: classes, modules, methods, and so on. - autoload :CodeObject, 'rdoc/code_object' - - autoload :Context, 'rdoc/context' - autoload :TopLevel, 'rdoc/top_level' - - autoload :AnonClass, 'rdoc/anon_class' - autoload :ClassModule, 'rdoc/class_module' - autoload :NormalClass, 'rdoc/normal_class' - autoload :NormalModule, 'rdoc/normal_module' - autoload :SingleClass, 'rdoc/single_class' - - autoload :Alias, 'rdoc/alias' - autoload :AnyMethod, 'rdoc/any_method' - autoload :MethodAttr, 'rdoc/method_attr' - autoload :GhostMethod, 'rdoc/ghost_method' - autoload :MetaMethod, 'rdoc/meta_method' - autoload :Attr, 'rdoc/attr' - - autoload :Constant, 'rdoc/constant' - autoload :Mixin, 'rdoc/mixin' - autoload :Include, 'rdoc/include' - autoload :Extend, 'rdoc/extend' - autoload :Require, 'rdoc/require' + autoload :CodeObject, "#{__dir__}/rdoc/code_object" + + autoload :Context, "#{__dir__}/rdoc/context" + autoload :TopLevel, "#{__dir__}/rdoc/top_level" + + autoload :AnonClass, "#{__dir__}/rdoc/anon_class" + autoload :ClassModule, "#{__dir__}/rdoc/class_module" + autoload :NormalClass, "#{__dir__}/rdoc/normal_class" + autoload :NormalModule, "#{__dir__}/rdoc/normal_module" + autoload :SingleClass, "#{__dir__}/rdoc/single_class" + + autoload :Alias, "#{__dir__}/rdoc/alias" + autoload :AnyMethod, "#{__dir__}/rdoc/any_method" + autoload :MethodAttr, "#{__dir__}/rdoc/method_attr" + autoload :GhostMethod, "#{__dir__}/rdoc/ghost_method" + autoload :MetaMethod, "#{__dir__}/rdoc/meta_method" + autoload :Attr, "#{__dir__}/rdoc/attr" + + autoload :Constant, "#{__dir__}/rdoc/constant" + autoload :Mixin, "#{__dir__}/rdoc/mixin" + autoload :Include, "#{__dir__}/rdoc/include" + autoload :Extend, "#{__dir__}/rdoc/extend" + autoload :Require, "#{__dir__}/rdoc/require" end diff --git a/lib/rdoc/code_objects.rb b/lib/rdoc/code_objects.rb index 434a25ac7f..d5f2f920ad 100644 --- a/lib/rdoc/code_objects.rb +++ b/lib/rdoc/code_objects.rb @@ -2,5 +2,4 @@ # This file was used to load all the RDoc::CodeObject subclasses at once. Now # autoload handles this. -require 'rdoc' - +require_relative '../rdoc' diff --git a/lib/rdoc/context.rb b/lib/rdoc/context.rb index b3caa53aa1..8e15697034 100644 --- a/lib/rdoc/context.rb +++ b/lib/rdoc/context.rb @@ -1261,6 +1261,6 @@ def upgrade_to_class mod, class_type, enclosing klass end - autoload :Section, 'rdoc/context/section' + autoload :Section, "#{__dir__}/context/section" end diff --git a/lib/rdoc/generator.rb b/lib/rdoc/generator.rb index 340dcbf7ae..a769cf8ac0 100644 --- a/lib/rdoc/generator.rb +++ b/lib/rdoc/generator.rb @@ -41,11 +41,11 @@ module RDoc::Generator - autoload :Markup, 'rdoc/generator/markup' + autoload :Markup, "#{__dir__}/generator/markup" - autoload :Darkfish, 'rdoc/generator/darkfish' - autoload :JsonIndex, 'rdoc/generator/json_index' - autoload :RI, 'rdoc/generator/ri' - autoload :POT, 'rdoc/generator/pot' + autoload :Darkfish, "#{__dir__}/generator/darkfish" + autoload :JsonIndex, "#{__dir__}/generator/json_index" + autoload :RI, "#{__dir__}/generator/ri" + autoload :POT, "#{__dir__}/generator/pot" end diff --git a/lib/rdoc/i18n.rb b/lib/rdoc/i18n.rb index a32fd848a0..f209a9a6f6 100644 --- a/lib/rdoc/i18n.rb +++ b/lib/rdoc/i18n.rb @@ -4,7 +4,7 @@ module RDoc::I18n - autoload :Locale, 'rdoc/i18n/locale' + autoload :Locale, "#{__dir__}/i18n/locale" require_relative 'i18n/text' end diff --git a/lib/rdoc/markup.rb b/lib/rdoc/markup.rb index 92aed757cf..804d24fd2f 100644 --- a/lib/rdoc/markup.rb +++ b/lib/rdoc/markup.rb @@ -822,46 +822,45 @@ def convert input, formatter document.accept formatter end - autoload :Parser, 'rdoc/markup/parser' - autoload :PreProcess, 'rdoc/markup/pre_process' + autoload :Parser, "#{__dir__}/markup/parser" + autoload :PreProcess, "#{__dir__}/markup/pre_process" # Inline markup classes - autoload :AttrChanger, 'rdoc/markup/attr_changer' - autoload :AttrSpan, 'rdoc/markup/attr_span' - autoload :Attributes, 'rdoc/markup/attributes' - autoload :AttributeManager, 'rdoc/markup/attribute_manager' - autoload :RegexpHandling, 'rdoc/markup/regexp_handling' + autoload :AttrChanger, "#{__dir__}/markup/attr_changer" + autoload :AttrSpan, "#{__dir__}/markup/attr_span" + autoload :Attributes, "#{__dir__}/markup/attributes" + autoload :AttributeManager, "#{__dir__}/markup/attribute_manager" + autoload :RegexpHandling, "#{__dir__}/markup/regexp_handling" # RDoc::Markup AST - autoload :BlankLine, 'rdoc/markup/blank_line' - autoload :BlockQuote, 'rdoc/markup/block_quote' - autoload :Document, 'rdoc/markup/document' - autoload :HardBreak, 'rdoc/markup/hard_break' - autoload :Heading, 'rdoc/markup/heading' - autoload :Include, 'rdoc/markup/include' - autoload :IndentedParagraph, 'rdoc/markup/indented_paragraph' - autoload :List, 'rdoc/markup/list' - autoload :ListItem, 'rdoc/markup/list_item' - autoload :Paragraph, 'rdoc/markup/paragraph' - autoload :Table, 'rdoc/markup/table' - autoload :Raw, 'rdoc/markup/raw' - autoload :Rule, 'rdoc/markup/rule' - autoload :Verbatim, 'rdoc/markup/verbatim' + autoload :BlankLine, "#{__dir__}/markup/blank_line" + autoload :BlockQuote, "#{__dir__}/markup/block_quote" + autoload :Document, "#{__dir__}/markup/document" + autoload :HardBreak, "#{__dir__}/markup/hard_break" + autoload :Heading, "#{__dir__}/markup/heading" + autoload :Include, "#{__dir__}/markup/include" + autoload :IndentedParagraph, "#{__dir__}/markup/indented_paragraph" + autoload :List, "#{__dir__}/markup/list" + autoload :ListItem, "#{__dir__}/markup/list_item" + autoload :Paragraph, "#{__dir__}/markup/paragraph" + autoload :Table, "#{__dir__}/markup/table" + autoload :Raw, "#{__dir__}/markup/raw" + autoload :Rule, "#{__dir__}/markup/rule" + autoload :Verbatim, "#{__dir__}/markup/verbatim" # Formatters - autoload :Formatter, 'rdoc/markup/formatter' + autoload :Formatter, "#{__dir__}/markup/formatter" - autoload :ToAnsi, 'rdoc/markup/to_ansi' - autoload :ToBs, 'rdoc/markup/to_bs' - autoload :ToHtml, 'rdoc/markup/to_html' - autoload :ToHtmlCrossref, 'rdoc/markup/to_html_crossref' - autoload :ToHtmlSnippet, 'rdoc/markup/to_html_snippet' - autoload :ToLabel, 'rdoc/markup/to_label' - autoload :ToMarkdown, 'rdoc/markup/to_markdown' - autoload :ToRdoc, 'rdoc/markup/to_rdoc' - autoload :ToTableOfContents, 'rdoc/markup/to_table_of_contents' - autoload :ToTest, 'rdoc/markup/to_test' - autoload :ToTtOnly, 'rdoc/markup/to_tt_only' + autoload :ToAnsi, "#{__dir__}/markup/to_ansi" + autoload :ToBs, "#{__dir__}/markup/to_bs" + autoload :ToHtml, "#{__dir__}/markup/to_html" + autoload :ToHtmlCrossref, "#{__dir__}/markup/to_html_crossref" + autoload :ToHtmlSnippet, "#{__dir__}/markup/to_html_snippet" + autoload :ToLabel, "#{__dir__}/markup/to_label" + autoload :ToMarkdown, "#{__dir__}/markup/to_markdown" + autoload :ToRdoc, "#{__dir__}/markup/to_rdoc" + autoload :ToTableOfContents, "#{__dir__}/markup/to_table_of_contents" + autoload :ToTest, "#{__dir__}/markup/to_test" + autoload :ToTtOnly, "#{__dir__}/markup/to_tt_only" end - diff --git a/lib/rdoc/parser.rb b/lib/rdoc/parser.rb index 425bc48632..7006265b63 100644 --- a/lib/rdoc/parser.rb +++ b/lib/rdoc/parser.rb @@ -263,8 +263,8 @@ def initialize top_level, file_name, content, options, stats @preprocess.options = @options end - autoload :RubyTools, 'rdoc/parser/ruby_tools' - autoload :Text, 'rdoc/parser/text' + autoload :RubyTools, "#{__dir__}/parser/ruby_tools" + autoload :Text, "#{__dir__}/parser/text" end diff --git a/lib/rdoc/rd.rb b/lib/rdoc/rd.rb index 0d3d3cea85..8c2366a3ca 100644 --- a/lib/rdoc/rd.rb +++ b/lib/rdoc/rd.rb @@ -92,9 +92,8 @@ def self.parse rd document end - autoload :BlockParser, 'rdoc/rd/block_parser' - autoload :InlineParser, 'rdoc/rd/inline_parser' - autoload :Inline, 'rdoc/rd/inline' + autoload :BlockParser, "#{__dir__}/rd/block_parser" + autoload :InlineParser, "#{__dir__}/rd/inline_parser" + autoload :Inline, "#{__dir__}/rd/inline" end - diff --git a/lib/rdoc/rdoc.rb b/lib/rdoc/rdoc.rb index 3a3defacb6..e23c1d7327 100644 --- a/lib/rdoc/rdoc.rb +++ b/lib/rdoc/rdoc.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc' +require_relative '../rdoc' require 'find' require 'fileutils' diff --git a/lib/rdoc/ri.rb b/lib/rdoc/ri.rb index c798c1fc49..0af05f729f 100644 --- a/lib/rdoc/ri.rb +++ b/lib/rdoc/ri.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc' +require_relative '../rdoc' ## # Namespace for the ri command line tool's implementation. @@ -13,9 +13,8 @@ module RDoc::RI class Error < RDoc::Error; end - autoload :Driver, 'rdoc/ri/driver' - autoload :Paths, 'rdoc/ri/paths' - autoload :Store, 'rdoc/ri/store' + autoload :Driver, "#{__dir__}/ri/driver" + autoload :Paths, "#{__dir__}/ri/paths" + autoload :Store, "#{__dir__}/ri/store" end - diff --git a/lib/rdoc/ri/driver.rb b/lib/rdoc/ri/driver.rb index ce2615dc5f..30942204cb 100644 --- a/lib/rdoc/ri/driver.rb +++ b/lib/rdoc/ri/driver.rb @@ -12,7 +12,7 @@ rescue LoadError end -require 'rdoc' +require_relative '../../rdoc' ## # For RubyGems backwards compatibility diff --git a/lib/rdoc/rubygems_hook.rb b/lib/rdoc/rubygems_hook.rb index 3781ff9858..3160072e53 100644 --- a/lib/rdoc/rubygems_hook.rb +++ b/lib/rdoc/rubygems_hook.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'rubygems/user_interaction' require 'fileutils' -require 'rdoc' +require_relative '../rdoc' ## # Gem::RDoc provides methods to generate RDoc and ri data for installed gems diff --git a/lib/rdoc/servlet.rb b/lib/rdoc/servlet.rb index 0ab1eaf19d..d05368766a 100644 --- a/lib/rdoc/servlet.rb +++ b/lib/rdoc/servlet.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc' +require_relative '../rdoc' require 'erb' require 'time' require 'json' diff --git a/lib/rdoc/stats.rb b/lib/rdoc/stats.rb index bd6c0ef23a..4817c9c729 100644 --- a/lib/rdoc/stats.rb +++ b/lib/rdoc/stats.rb @@ -454,9 +454,8 @@ def undoc_params method [params.length, undoc] end - autoload :Quiet, 'rdoc/stats/quiet' - autoload :Normal, 'rdoc/stats/normal' - autoload :Verbose, 'rdoc/stats/verbose' + autoload :Quiet, "#{__dir__}/stats/quiet" + autoload :Normal, "#{__dir__}/stats/normal" + autoload :Verbose, "#{__dir__}/stats/verbose" end - diff --git a/lib/rdoc/task.rb b/lib/rdoc/task.rb index 0bedaa50b0..b52d7b292d 100644 --- a/lib/rdoc/task.rb +++ b/lib/rdoc/task.rb @@ -32,7 +32,7 @@ rescue Gem::LoadError end unless defined?(Rake) -require 'rdoc' +require_relative '../rdoc' require 'rake' require 'rake/tasklib' diff --git a/lib/rdoc/version.rb b/lib/rdoc/version.rb index f6e18f7d4d..eeb92a7897 100644 --- a/lib/rdoc/version.rb +++ b/lib/rdoc/version.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module RDoc ## diff --git a/test/rdoc/helper.rb b/test/rdoc/helper.rb index 2ba26c296b..7985433060 100644 --- a/test/rdoc/helper.rb +++ b/test/rdoc/helper.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative './support/test_case' -require_relative './support/formatter_test_case' -require_relative './support/text_formatter_test_case' +require_relative 'support/test_case' +require_relative 'support/formatter_test_case' +require_relative 'support/text_formatter_test_case' diff --git a/test/rdoc/support/test_case.rb b/test/rdoc/support/test_case.rb index 6d397625e8..95f946c80d 100644 --- a/test/rdoc/support/test_case.rb +++ b/test/rdoc/support/test_case.rb @@ -26,7 +26,7 @@ require 'tmpdir' require 'stringio' -require 'rdoc' +require_relative '../../../lib/rdoc' ## # RDoc::TestCase is an abstract TestCase to provide common setup and teardown diff --git a/test/rdoc/test_rdoc_alias.rb b/test/rdoc/test_rdoc_alias.rb index 89ae2d5a56..3c096a49b4 100644 --- a/test/rdoc/test_rdoc_alias.rb +++ b/test/rdoc/test_rdoc_alias.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require File.expand_path '../xref_test_case', __FILE__ +require_relative 'xref_test_case' class TestRDocAlias < XrefTestCase @@ -11,4 +11,3 @@ def test_to_s end end - diff --git a/test/rdoc/test_rdoc_any_method.rb b/test/rdoc/test_rdoc_any_method.rb index 615789dfb3..2f30932ee6 100644 --- a/test/rdoc/test_rdoc_any_method.rb +++ b/test/rdoc/test_rdoc_any_method.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require File.expand_path '../xref_test_case', __FILE__ +require_relative 'xref_test_case' class TestRDocAnyMethod < XrefTestCase diff --git a/test/rdoc/test_rdoc_class_module.rb b/test/rdoc/test_rdoc_class_module.rb index 4dcc5d15ab..b2d1b0b007 100644 --- a/test/rdoc/test_rdoc_class_module.rb +++ b/test/rdoc/test_rdoc_class_module.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require File.expand_path '../xref_test_case', __FILE__ +require_relative 'xref_test_case' class TestRDocClassModule < XrefTestCase @@ -1501,4 +1501,3 @@ def test_update_extends_with_colons end end - diff --git a/test/rdoc/test_rdoc_code_object.rb b/test/rdoc/test_rdoc_code_object.rb index fad182722a..24e228cce1 100644 --- a/test/rdoc/test_rdoc_code_object.rb +++ b/test/rdoc/test_rdoc_code_object.rb @@ -1,7 +1,7 @@ # coding: US-ASCII # frozen_string_literal: true -require File.expand_path '../xref_test_case', __FILE__ +require_relative 'xref_test_case' class TestRDocCodeObject < XrefTestCase diff --git a/test/rdoc/test_rdoc_constant.rb b/test/rdoc/test_rdoc_constant.rb index 79dcdad57e..32ffe3f84d 100644 --- a/test/rdoc/test_rdoc_constant.rb +++ b/test/rdoc/test_rdoc_constant.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require File.expand_path '../xref_test_case', __FILE__ +require_relative 'xref_test_case' class TestRDocConstant < XrefTestCase diff --git a/test/rdoc/test_rdoc_context.rb b/test/rdoc/test_rdoc_context.rb index ecdb3cbd67..355dac41e0 100644 --- a/test/rdoc/test_rdoc_context.rb +++ b/test/rdoc/test_rdoc_context.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require File.expand_path '../xref_test_case', __FILE__ +require_relative 'xref_test_case' class TestRDocContext < XrefTestCase diff --git a/test/rdoc/test_rdoc_cross_reference.rb b/test/rdoc/test_rdoc_cross_reference.rb index 183de0930d..de78fb8c51 100644 --- a/test/rdoc/test_rdoc_cross_reference.rb +++ b/test/rdoc/test_rdoc_cross_reference.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require File.expand_path '../xref_test_case', __FILE__ +require_relative 'xref_test_case' class TestRDocCrossReference < XrefTestCase @@ -204,4 +204,3 @@ def test_resolve_no_ref end end - diff --git a/test/rdoc/test_rdoc_extend.rb b/test/rdoc/test_rdoc_extend.rb index f4c8425864..00baeb5c96 100644 --- a/test/rdoc/test_rdoc_extend.rb +++ b/test/rdoc/test_rdoc_extend.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require File.expand_path '../xref_test_case', __FILE__ +require_relative 'xref_test_case' class TestRDocExtend < XrefTestCase @@ -92,4 +92,3 @@ def test_module_extended end end - diff --git a/test/rdoc/test_rdoc_include.rb b/test/rdoc/test_rdoc_include.rb index 67d3dfd88e..51afb0925f 100644 --- a/test/rdoc/test_rdoc_include.rb +++ b/test/rdoc/test_rdoc_include.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require File.expand_path '../xref_test_case', __FILE__ +require_relative 'xref_test_case' class TestRDocInclude < XrefTestCase @@ -106,4 +106,3 @@ def test_store_equals end end - diff --git a/test/rdoc/test_rdoc_markdown.rb b/test/rdoc/test_rdoc_markdown.rb index ad53e9473c..c223c44c12 100644 --- a/test/rdoc/test_rdoc_markdown.rb +++ b/test/rdoc/test_rdoc_markdown.rb @@ -2,8 +2,8 @@ # frozen_string_literal: true require_relative 'helper' -require 'rdoc/markup/block_quote' -require 'rdoc/markdown' +require_relative '../../lib/rdoc/markup/block_quote' +require_relative '../../lib/rdoc/markdown' class TestRDocMarkdown < RDoc::TestCase @@ -1068,4 +1068,3 @@ def parse text end end - diff --git a/test/rdoc/test_rdoc_markdown_test.rb b/test/rdoc/test_rdoc_markdown_test.rb index 0ecd000136..d4f894c924 100644 --- a/test/rdoc/test_rdoc_markdown_test.rb +++ b/test/rdoc/test_rdoc_markdown_test.rb @@ -2,8 +2,8 @@ require_relative 'helper' require 'pp' -require 'rdoc' -require 'rdoc/markdown' +require_relative '../../lib/rdoc' +require_relative '../../lib/rdoc/markdown' class TestRDocMarkdownTest < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_markup_to_html_crossref.rb b/test/rdoc/test_rdoc_markup_to_html_crossref.rb index f6fabfb7db..1c778a4fad 100644 --- a/test/rdoc/test_rdoc_markup_to_html_crossref.rb +++ b/test/rdoc/test_rdoc_markup_to_html_crossref.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require File.expand_path '../xref_test_case', __FILE__ +require_relative 'xref_test_case' class TestRDocMarkupToHtmlCrossref < XrefTestCase @@ -260,4 +260,3 @@ def tidy reference end end - diff --git a/test/rdoc/test_rdoc_method_attr.rb b/test/rdoc/test_rdoc_method_attr.rb index 68a9d6cc21..d607619a60 100644 --- a/test/rdoc/test_rdoc_method_attr.rb +++ b/test/rdoc/test_rdoc_method_attr.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require File.expand_path '../xref_test_case', __FILE__ +require_relative 'xref_test_case' class TestRDocMethodAttr < XrefTestCase @@ -191,4 +191,3 @@ def test_to_s end end - diff --git a/test/rdoc/test_rdoc_normal_class.rb b/test/rdoc/test_rdoc_normal_class.rb index 874eaaa88c..1b3a33a91f 100644 --- a/test/rdoc/test_rdoc_normal_class.rb +++ b/test/rdoc/test_rdoc_normal_class.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require File.expand_path '../xref_test_case', __FILE__ +require_relative 'xref_test_case' class TestRDocNormalClass < XrefTestCase @@ -45,4 +45,3 @@ def test_definition end end - diff --git a/test/rdoc/test_rdoc_normal_module.rb b/test/rdoc/test_rdoc_normal_module.rb index 68e776c41f..cccee5c44c 100644 --- a/test/rdoc/test_rdoc_normal_module.rb +++ b/test/rdoc/test_rdoc_normal_module.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require File.expand_path '../xref_test_case', __FILE__ +require_relative 'xref_test_case' class TestRDocNormalModule < XrefTestCase @@ -40,4 +40,3 @@ def test_module_eh end end - diff --git a/test/rdoc/test_rdoc_require.rb b/test/rdoc/test_rdoc_require.rb index 46c225299a..4cc53e6c6c 100644 --- a/test/rdoc/test_rdoc_require.rb +++ b/test/rdoc/test_rdoc_require.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require File.expand_path '../xref_test_case', __FILE__ +require_relative 'xref_test_case' class TestRDocRequire < XrefTestCase @@ -23,4 +23,3 @@ def test_initialize end end - diff --git a/test/rdoc/test_rdoc_ri_driver.rb b/test/rdoc/test_rdoc_ri_driver.rb index 87e4ebd2b1..5f3468c368 100644 --- a/test/rdoc/test_rdoc_ri_driver.rb +++ b/test/rdoc/test_rdoc_ri_driver.rb @@ -32,8 +32,8 @@ def setup end def teardown - ENV['RI'] = @orig_ri - FileUtils.rm_rf @tmpdir + defined?(@orig_ri) and ENV['RI'] = @orig_ri + defined?(@tmpdir) and FileUtils.rm_rf @tmpdir super end diff --git a/test/rdoc/test_rdoc_rubygems_hook.rb b/test/rdoc/test_rdoc_rubygems_hook.rb index c38e18c4f9..a40e3b5ab5 100644 --- a/test/rdoc/test_rdoc_rubygems_hook.rb +++ b/test/rdoc/test_rdoc_rubygems_hook.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -require "rubygems" -require "fileutils" -require "tmpdir" -require 'rdoc/rubygems_hook' -require "test/unit" +require 'rubygems' +require 'fileutils' +require 'tmpdir' +require_relative '../../lib/rdoc/rubygems_hook' +require 'test/unit' class TestRDocRubygemsHook < Test::Unit::TestCase def setup diff --git a/test/rdoc/test_rdoc_store.rb b/test/rdoc/test_rdoc_store.rb index 82340e6b7a..d1396076b6 100644 --- a/test/rdoc/test_rdoc_store.rb +++ b/test/rdoc/test_rdoc_store.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require File.expand_path '../xref_test_case', __FILE__ +require_relative 'xref_test_case' class TestRDocStore < XrefTestCase diff --git a/test/rdoc/test_rdoc_task.rb b/test/rdoc/test_rdoc_task.rb index 77f2af33a3..23add7d5fe 100644 --- a/test/rdoc/test_rdoc_task.rb +++ b/test/rdoc/test_rdoc_task.rb @@ -171,4 +171,3 @@ def test_title_option end end if defined?(Rake::Task) - diff --git a/test/rdoc/test_rdoc_top_level.rb b/test/rdoc/test_rdoc_top_level.rb index a954fde981..357463545d 100644 --- a/test/rdoc/test_rdoc_top_level.rb +++ b/test/rdoc/test_rdoc_top_level.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require File.expand_path '../xref_test_case', __FILE__ +require_relative 'xref_test_case' class TestRDocTopLevel < XrefTestCase @@ -288,4 +288,3 @@ def test_text_eh_no_parser end end - From 28e5d640638dc798590d68c891b7dd3d27124a4c Mon Sep 17 00:00:00 2001 From: Ulysse Buonomo Date: Thu, 1 Jul 2021 01:16:29 +0200 Subject: [PATCH 2/3] fixup! Relative loading for easier development Remove Rakefile lib folder to make sure we test that usage of relative paths Signed-off-by: Ulysse Buonomo --- Rakefile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Rakefile b/Rakefile index fb00a270bc..7f7604db51 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,6 @@ -$:.unshift File.expand_path 'lib' -require 'rdoc/task' +# frozen_string_literal: true + +require_relative 'lib/rdoc/task' require 'bundler/gem_tasks' require 'rake/testtask' @@ -34,14 +35,14 @@ task ghpages: :rdoc do end Rake::TestTask.new(:normal_test) do |t| - t.libs << "test/rdoc" + t.libs = [] t.verbose = true t.deps = :generate t.test_files = FileList["test/**/test_*.rb"].exclude("test/rdoc/test_rdoc_rubygems_hook.rb") end Rake::TestTask.new(:rubygems_test) do |t| - t.libs << "test/rdoc" + t.libs = [] t.verbose = true t.deps = :generate t.pattern = "test/rdoc/test_rdoc_rubygems_hook.rb" From 33e2a5f201009449d5bf30a0f370b72cec8df8a5 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 12 Sep 2021 19:18:42 +0900 Subject: [PATCH 3/3] Relative loading in markdown.kpeg --- lib/rdoc/markdown.kpeg | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/rdoc/markdown.kpeg b/lib/rdoc/markdown.kpeg index 84073ebe65..07844388fa 100644 --- a/lib/rdoc/markdown.kpeg +++ b/lib/rdoc/markdown.kpeg @@ -187,11 +187,11 @@ %% { - require 'rdoc' - require 'rdoc/markup/to_joined_paragraph' - require 'rdoc/markdown/entities' + require_relative '../rdoc' + require_relative 'markup/to_joined_paragraph' + require_relative 'markdown/entities' - require 'rdoc/markdown/literals' + require_relative 'markdown/literals' ## # Supported extensions