diff --git a/lib/rdoc.rb b/lib/rdoc.rb index fef3726b33..21b037adee 100644 --- a/lib/rdoc.rb +++ b/lib/rdoc.rb @@ -65,7 +65,7 @@ module RDoc ## # RDoc version you are using - VERSION = '6.0.1' + VERSION = '6.0.3' ## # Method visibilities @@ -125,8 +125,6 @@ module RDoc autoload :RDoc, 'rdoc/rdoc' - autoload :TestCase, 'rdoc/test_case' - autoload :CrossReference, 'rdoc/cross_reference' autoload :ERBIO, 'rdoc/erbio' autoload :ERBPartial, 'rdoc/erb_partial' @@ -153,7 +151,7 @@ module RDoc autoload :Comment, 'rdoc/comment' - autoload :I18n, 'rdoc/i18n' + require 'rdoc/i18n' # code objects # diff --git a/lib/rdoc/context.rb b/lib/rdoc/context.rb index 58b1c54269..6caf0d6712 100644 --- a/lib/rdoc/context.rb +++ b/lib/rdoc/context.rb @@ -407,6 +407,7 @@ class RDoc::Context < RDoc::CodeObject mod.section = current_section # TODO declaring context? something is # wrong here... mod.parent = self + mod.full_name = nil mod.store = @store unless @done_documenting then @@ -414,6 +415,10 @@ class RDoc::Context < RDoc::CodeObject # this must be done AFTER adding mod to its parent, so that the full # name is correct: all_hash[mod.full_name] = mod + if @store.unmatched_constant_alias[mod.full_name] then + to, file = @store.unmatched_constant_alias[mod.full_name] + add_module_alias mod, mod.name, to, file + end end mod @@ -510,41 +515,53 @@ class RDoc::Context < RDoc::CodeObject add_class_or_module mod, @modules, @store.modules_hash end + ## + # Adds a module by +RDoc::NormalModule+ instance. See also #add_module. + + def add_module_by_normal_module(mod) + add_class_or_module mod, @modules, @store.modules_hash + end + ## # Adds an alias from +from+ (a class or module) to +name+ which was defined # in +file+. - def add_module_alias from, name, file + def add_module_alias from, from_name, to, file return from if @done_documenting - to_name = child_name name + to_full_name = child_name to.name # if we already know this name, don't register an alias: # see the metaprogramming in lib/active_support/basic_object.rb, # where we already know BasicObject is a class when we find # BasicObject = BlankSlate - return from if @store.find_class_or_module to_name + return from if @store.find_class_or_module to_full_name - to = from.dup - to.name = name - to.full_name = nil + unless from + @store.unmatched_constant_alias[child_name(from_name)] = [to, file] + return to + end - if to.module? then - @store.modules_hash[to_name] = to - @modules[name] = to + new_to = from.dup + new_to.name = to.name + new_to.full_name = nil + + if new_to.module? then + @store.modules_hash[to_full_name] = new_to + @modules[to.name] = new_to else - @store.classes_hash[to_name] = to - @classes[name] = to + @store.classes_hash[to_full_name] = new_to + @classes[to.name] = new_to end # Registers a constant for this alias. The constant value and comment # will be updated later, when the Ruby parser adds the constant - const = RDoc::Constant.new name, nil, to.comment + const = RDoc::Constant.new to.name, nil, new_to.comment const.record_location file const.is_alias_for = from add_constant const - to + new_to end ## @@ -863,7 +880,13 @@ class RDoc::Context < RDoc::CodeObject # Finds a method named +name+ with singleton value +singleton+. def find_method(name, singleton) - @method_list.find { |m| m.name == name && m.singleton == singleton } + @method_list.find { |m| + if m.singleton + m.name == name && m.singleton == singleton + else + m.name == name && !m.singleton && !singleton + end + } end ## diff --git a/lib/rdoc/encoding.rb b/lib/rdoc/encoding.rb index 54ecd89816..cf60badd24 100644 --- a/lib/rdoc/encoding.rb +++ b/lib/rdoc/encoding.rb @@ -7,6 +7,18 @@ module RDoc::Encoding + HEADER_REGEXP = /^ + (?: + \A\#!.*\n + | + ^\#\s+frozen[-_]string[-_]literal[=:].+\n + | + ^\#[^\n]+\b(?:en)?coding[=:]\s*(?[^\s;]+).*\n + | + <\?xml[^?]*encoding=(?["'])(?.*?)\k.*\n + )+ + /xi # :nodoc: + ## # Reads the contents of +filename+ and handles any encoding directives in # the file. @@ -18,12 +30,13 @@ module RDoc::Encoding # unknown character in the target encoding will be replaced with '?' def self.read_file filename, encoding, force_transcode = false - content = open filename, "rb" do |f| f.read end + content = File.open filename, "rb" do |f| f.read end content.gsub!("\r\n", "\n") if RUBY_PLATFORM =~ /mswin|mingw/ utf8 = content.sub!(/\A\xef\xbb\xbf/, '') - content = RDoc::Encoding.set_encoding content + enc = RDoc::Encoding.detect_encoding content + content = RDoc::Encoding.change_encoding content, enc if enc begin encoding ||= Encoding.default_external @@ -85,29 +98,22 @@ module RDoc::Encoding end ## - # Sets the encoding of +string+ based on the magic comment + # Detects the encoding of +string+ based on the magic comment - def self.set_encoding string - string = remove_frozen_string_literal string + def self.detect_encoding string + result = HEADER_REGEXP.match string + name = result && result[:name] - string =~ /\A(?:#!.*\n)?(.*\n)/ + name ? Encoding.find(name) : nil + end - first_line = $1 + ## + # Removes magic comments and shebang - name = case first_line - when /^<\?xml[^?]*encoding=(["'])(.*?)\1/ then $2 - when /\b(?:en)?coding[=:]\s*([^\s;]+)/i then $1 - else return string - end - - string = string.sub first_line, '' - - string = remove_frozen_string_literal string - - enc = Encoding.find name - string = RDoc::Encoding.change_encoding string, enc if enc - - string + def self.remove_magic_comment string + string.sub HEADER_REGEXP do |s| + s.gsub(/[^\n]/, '') + end end ## diff --git a/lib/rdoc/erbio.rb b/lib/rdoc/erbio.rb index 2ebce9519f..820a25ae01 100644 --- a/lib/rdoc/erbio.rb +++ b/lib/rdoc/erbio.rb @@ -9,7 +9,7 @@ require 'erb' # # erbio = RDoc::ERBIO.new '<%= "hello world" %>', nil, nil # -# open 'hello.txt', 'w' do |io| +# File.open 'hello.txt', 'w' do |io| # erbio.result binding # end # diff --git a/lib/rdoc/generator/json_index.rb b/lib/rdoc/generator/json_index.rb index e4cfe967c6..3a1000033d 100644 --- a/lib/rdoc/generator/json_index.rb +++ b/lib/rdoc/generator/json_index.rb @@ -147,12 +147,15 @@ class RDoc::Generator::JsonIndex JSON.dump data, io, 0 end + unless ENV['SOURCE_DATE_EPOCH'].nil? + index_file.utime index_file.atime, Time.at(ENV['SOURCE_DATE_EPOCH'].to_i).gmtime + end Dir.chdir @template_dir do Dir['**/*.js'].each do |source| dest = File.join out_dir, source - FileUtils.install source, dest, :mode => 0644, :verbose => $DEBUG_RDOC + FileUtils.install source, dest, :mode => 0644, :preserve => true, :verbose => $DEBUG_RDOC end end end diff --git a/lib/rdoc/generator/pot.rb b/lib/rdoc/generator/pot.rb index 8a1e0b4bd0..a12cba7505 100644 --- a/lib/rdoc/generator/pot.rb +++ b/lib/rdoc/generator/pot.rb @@ -91,8 +91,8 @@ class RDoc::Generator::POT extractor.extract end - autoload :MessageExtractor, 'rdoc/generator/pot/message_extractor' - autoload :PO, 'rdoc/generator/pot/po' - autoload :POEntry, 'rdoc/generator/pot/po_entry' + require 'rdoc/generator/pot/message_extractor' + require 'rdoc/generator/pot/po' + require 'rdoc/generator/pot/po_entry' end diff --git a/lib/rdoc/i18n.rb b/lib/rdoc/i18n.rb index 4cb5986155..af303858b9 100644 --- a/lib/rdoc/i18n.rb +++ b/lib/rdoc/i18n.rb @@ -5,6 +5,6 @@ module RDoc::I18n autoload :Locale, 'rdoc/i18n/locale' - autoload :Text, 'rdoc/i18n/text' + require 'rdoc/i18n/text' end diff --git a/lib/rdoc/markdown.rb b/lib/rdoc/markdown.rb index 44dd50b0f7..43c70c8de6 100644 --- a/lib/rdoc/markdown.rb +++ b/lib/rdoc/markdown.rb @@ -1,4 +1,5 @@ # coding: UTF-8 +# frozen_string_literal: true # :markup: markdown ## diff --git a/lib/rdoc/markdown/literals.rb b/lib/rdoc/markdown/literals.rb index cd4cb52335..31cd237f12 100644 --- a/lib/rdoc/markdown/literals.rb +++ b/lib/rdoc/markdown/literals.rb @@ -1,4 +1,5 @@ # coding: UTF-8 +# frozen_string_literal: true # :markup: markdown ## diff --git a/lib/rdoc/markup/pre_process.rb b/lib/rdoc/markup/pre_process.rb index 0ac7a41934..d9e0dcac14 100644 --- a/lib/rdoc/markup/pre_process.rb +++ b/lib/rdoc/markup/pre_process.rb @@ -266,6 +266,7 @@ class RDoc::Markup::PreProcess end content = RDoc::Encoding.read_file full_name, encoding, true + content = RDoc::Encoding.remove_magic_comment content # strip magic comment content = content.sub(/\A# .*coding[=:].*$/, '').lstrip diff --git a/lib/rdoc/options.rb b/lib/rdoc/options.rb index 17bbca81fe..99d7aaaec1 100644 --- a/lib/rdoc/options.rb +++ b/lib/rdoc/options.rb @@ -1217,7 +1217,7 @@ Usage: #{opt.program_name} [options] [names...] def write_options RDoc.load_yaml - open '.rdoc_options', 'w' do |io| + File.open '.rdoc_options', 'w' do |io| io.set_encoding Encoding::UTF_8 YAML.dump self, io diff --git a/lib/rdoc/parser.rb b/lib/rdoc/parser.rb index 2b826d9284..597bcd6b9d 100644 --- a/lib/rdoc/parser.rb +++ b/lib/rdoc/parser.rb @@ -139,7 +139,7 @@ class RDoc::Parser # Returns the file type from the modeline in +file_name+ def self.check_modeline file_name - line = open file_name do |io| + line = File.open file_name do |io| io.gets end diff --git a/lib/rdoc/parser/ripper_state_lex.rb b/lib/rdoc/parser/ripper_state_lex.rb index b7cec84bfc..43f7dc1e9b 100644 --- a/lib/rdoc/parser/ripper_state_lex.rb +++ b/lib/rdoc/parser/ripper_state_lex.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'ripper' class RDoc::RipperStateLex @@ -83,6 +84,15 @@ class RDoc::RipperStateLex when '&&', '||', '+=', '-=', '*=', '**=', '&=', '|=', '^=', '<<=', '>>=', '||=', '&&=' @lex_state = EXPR_BEG + when '::' + case @lex_state + when EXPR_ARG, EXPR_CMDARG + @lex_state = EXPR_DOT + when EXPR_FNAME, EXPR_DOT + @lex_state = EXPR_ARG + else + @lex_state = EXPR_BEG + end else case @lex_state when EXPR_FNAME, EXPR_DOT @@ -109,8 +119,10 @@ class RDoc::RipperStateLex else @lex_state = EXPR_BEG end - when 'begin' + when 'begin', 'case', 'when' @lex_state = EXPR_BEG + when 'return', 'break' + @lex_state = EXPR_MID else if @lex_state == EXPR_FNAME @lex_state = EXPR_END @@ -245,7 +257,7 @@ class RDoc::RipperStateLex case @lex_state when EXPR_FNAME @lex_state = EXPR_ENDFN - when EXPR_CLASS + when EXPR_CLASS, EXPR_CMDARG, EXPR_MID @lex_state = EXPR_ARG else @lex_state = EXPR_CMDARG @@ -330,8 +342,10 @@ class RDoc::RipperStateLex @heredoc_queue << retrieve_heredoc_info(tk) @inner_lex.lex_state = EXPR_END unless RIPPER_HAS_LEX_STATE when :on_nl, :on_ignored_nl, :on_comment, :on_heredoc_end then - unless @heredoc_queue.empty? + if !@heredoc_queue.empty? get_heredoc_tk(*@heredoc_queue.shift) + elsif tk[:text].nil? # :on_ignored_nl sometimes gives nil + tk[:text] = '' end when :on_words_beg then tk = get_words_tk(tk) diff --git a/lib/rdoc/parser/ruby.rb b/lib/rdoc/parser/ruby.rb index 8599f655ad..6fe4a89e46 100644 --- a/lib/rdoc/parser/ruby.rb +++ b/lib/rdoc/parser/ruby.rb @@ -177,6 +177,7 @@ class RDoc::Parser::Ruby < RDoc::Parser @size = 0 @token_listeners = nil + content = RDoc::Encoding.remove_magic_comment content @scanner = RDoc::RipperStateLex.parse(content) @content = content @scanner_point = 0 @@ -306,7 +307,7 @@ class RDoc::Parser::Ruby < RDoc::Parser container.find_module_named rhs_name end - container.add_module_alias mod, constant.name, @top_level if mod + container.add_module_alias mod, rhs_name, constant, @top_level end ## @@ -355,12 +356,15 @@ class RDoc::Parser::Ruby < RDoc::Parser given_name << name_t[:text] is_self = name_t[:kind] == :on_op && name_t[:text] == '<<' + new_modules = [] while !is_self && (tk = peek_tk) and :on_op == tk[:kind] and '::' == tk[:text] do prev_container = container container = container.find_module_named name_t[:text] container ||= if ignore_constants then - RDoc::Context.new + c = RDoc::NormalModule.new name_t[:text] + new_modules << [prev_container, c] + c else c = prev_container.add_module RDoc::NormalModule, name_t[:text] c.ignore unless prev_container.document_children @@ -385,7 +389,7 @@ class RDoc::Parser::Ruby < RDoc::Parser skip_tkspace false - return [container, name_t, given_name] + return [container, name_t, given_name, new_modules] end ## @@ -760,7 +764,7 @@ class RDoc::Parser::Ruby < RDoc::Parser line_no = tk[:line_no] declaration_context = container - container, name_t, given_name = get_class_or_module container + container, name_t, given_name, = get_class_or_module container if name_t[:kind] == :on_const cls = parse_class_regular container, declaration_context, single, @@ -877,10 +881,11 @@ class RDoc::Parser::Ruby < RDoc::Parser return unless name =~ /^\w+$/ + new_modules = [] if :on_op == peek_tk[:kind] && '::' == peek_tk[:text] then unget_tk tk - container, name_t, = get_class_or_module container, ignore_constants + container, name_t, _, new_modules = get_class_or_module container, true name = name_t[:text] end @@ -907,6 +912,14 @@ class RDoc::Parser::Ruby < RDoc::Parser end get_tk + unless ignore_constants + new_modules.each do |prev_c, new_module| + prev_c.add_module_by_normal_module new_module + new_module.ignore unless prev_c.document_children + @top_level.add_to_classes_or_modules new_module + end + end + value = '' con = RDoc::Constant.new name, value, comment @@ -2074,13 +2087,16 @@ class RDoc::Parser::Ruby < RDoc::Parser $stderr.puts @file_name return end - bytes = '' if @scanner_point >= @scanner.size now_line_no = @scanner[@scanner.size - 1][:line_no] else now_line_no = peek_tk[:line_no] end + first_tk_index = @scanner.find_index { |tk| tk[:line_no] == now_line_no } + last_tk_index = @scanner.find_index { |tk| tk[:line_no] == now_line_no + 1 } + last_tk_index = last_tk_index ? last_tk_index - 1 : @scanner.size - 1 + code = @scanner[first_tk_index..last_tk_index].map{ |t| t[:text] }.join $stderr.puts <<-EOF @@ -2089,12 +2105,9 @@ class RDoc::Parser::Ruby < RDoc::Parser EOF - unless bytes.empty? then + unless code.empty? then + $stderr.puts code $stderr.puts - now_line_no = peek_tk[:line_no] - start_index = @scanner.find_index { |tk| tk[:line_no] == now_line_no } - end_index = @scanner.find_index { |tk| tk[:line_no] == now_line_no + 1 } - 1 - $stderr.puts @scanner[start_index..end_index].join end raise e diff --git a/lib/rdoc/rd/block_parser.rb b/lib/rdoc/rd/block_parser.rb index 3f4941168f..b5634fef23 100644 --- a/lib/rdoc/rd/block_parser.rb +++ b/lib/rdoc/rd/block_parser.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # # DO NOT MODIFY!!!! # This file is automatically generated by Racc 1.4.14 @@ -207,7 +208,7 @@ def next_token # :nodoc: if @in_verbatim [:STRINGLINE, line] else - @indent_stack.push("\s" << newIndent) + @indent_stack.push("\s" + newIndent) [:ITEMLISTLINE, rest] end end @@ -219,7 +220,7 @@ def next_token # :nodoc: if @in_verbatim [:STRINGLINE, line] else - @indent_stack.push("\s" * mark.size << newIndent) + @indent_stack.push("\s" * mark.size + newIndent) [:ENUMLISTLINE, rest] end end @@ -677,54 +678,54 @@ Racc_debug_parser = false # reduce 0 omitted def _reduce_1(val, _values, result) - result = RDoc::Markup::Document.new(*val[0]) + result = RDoc::Markup::Document.new(*val[0]) result end def _reduce_2(val, _values, result) - raise ParseError, "file empty" + raise ParseError, "file empty" result end def _reduce_3(val, _values, result) - result = val[0].concat val[1] + result = val[0].concat val[1] result end def _reduce_4(val, _values, result) - result = val[0] + result = val[0] result end def _reduce_5(val, _values, result) - result = val + result = val result end def _reduce_6(val, _values, result) - result = val + result = val result end # reduce 7 omitted def _reduce_8(val, _values, result) - result = val + result = val result end def _reduce_9(val, _values, result) - result = val + result = val result end def _reduce_10(val, _values, result) - result = [RDoc::Markup::BlankLine.new] + result = [RDoc::Markup::BlankLine.new] result end def _reduce_11(val, _values, result) - result = val[0].parts + result = val[0].parts result end @@ -732,30 +733,30 @@ def _reduce_12(val, _values, result) # val[0] is like [level, title] title = @inline_parser.parse(val[0][1]) result = RDoc::Markup::Heading.new(val[0][0], title) - + result end def _reduce_13(val, _values, result) result = RDoc::Markup::Include.new val[0], @include_path - + result end def _reduce_14(val, _values, result) # val[0] is Array of String result = paragraph val[0] - + result end def _reduce_15(val, _values, result) - result << val[1].rstrip + result << val[1].rstrip result end def _reduce_16(val, _values, result) - result = [val[0].rstrip] + result = [val[0].rstrip] result end @@ -766,7 +767,7 @@ def _reduce_17(val, _values, result) # imform to lexer. @in_verbatim = false - + result end @@ -777,25 +778,25 @@ def _reduce_18(val, _values, result) # imform to lexer. @in_verbatim = false - + result end def _reduce_19(val, _values, result) result << val[1] - + result end def _reduce_20(val, _values, result) result.concat val[2] - + result end def _reduce_21(val, _values, result) result << "\n" - + result end @@ -803,7 +804,7 @@ def _reduce_22(val, _values, result) result = val # inform to lexer. @in_verbatim = true - + result end @@ -817,89 +818,89 @@ end def _reduce_27(val, _values, result) result = val[0] - + result end def _reduce_28(val, _values, result) result = val[1] - + result end def _reduce_29(val, _values, result) result = val[1].push(val[2]) - + result end def _reduce_30(val, _values, result) - result = val[0] << val[1] + result = val[0] << val[1] result end def _reduce_31(val, _values, result) - result = [val[0]] + result = [val[0]] result end def _reduce_32(val, _values, result) result = RDoc::Markup::List.new :BULLET, *val[0] - + result end def _reduce_33(val, _values, result) - result.push(val[1]) + result.push(val[1]) result end def _reduce_34(val, _values, result) - result = val + result = val result end def _reduce_35(val, _values, result) result = RDoc::Markup::ListItem.new nil, val[0], *val[1] - + result end def _reduce_36(val, _values, result) result = RDoc::Markup::List.new :NUMBER, *val[0] - + result end def _reduce_37(val, _values, result) - result.push(val[1]) + result.push(val[1]) result end def _reduce_38(val, _values, result) - result = val + result = val result end def _reduce_39(val, _values, result) result = RDoc::Markup::ListItem.new nil, val[0], *val[1] - + result end def _reduce_40(val, _values, result) result = RDoc::Markup::List.new :NOTE, *val[0] - + result end def _reduce_41(val, _values, result) - result.push(val[1]) + result.push(val[1]) result end def _reduce_42(val, _values, result) - result = val + result = val result end @@ -907,77 +908,77 @@ def _reduce_43(val, _values, result) term = @inline_parser.parse val[0].strip result = RDoc::Markup::ListItem.new term, *val[1] - + result end def _reduce_44(val, _values, result) result = RDoc::Markup::List.new :LABEL, *val[0] - + result end def _reduce_45(val, _values, result) - result.push(val[1]) + result.push(val[1]) result end def _reduce_46(val, _values, result) - result = val + result = val result end def _reduce_47(val, _values, result) result = RDoc::Markup::ListItem.new "#{val[0].strip}", *val[1] - + result end def _reduce_48(val, _values, result) result = [val[1]].concat(val[2]) - + result end def _reduce_49(val, _values, result) result = [val[1]] - + result end def _reduce_50(val, _values, result) result = val[2] - + result end def _reduce_51(val, _values, result) result = [] - + result end def _reduce_52(val, _values, result) - result.concat val[1] + result.concat val[1] result end # reduce 53 omitted def _reduce_54(val, _values, result) - result = val + result = val result end def _reduce_55(val, _values, result) - result = val + result = val result end # reduce 56 omitted def _reduce_57(val, _values, result) - result = [] + result = [] result end @@ -991,58 +992,58 @@ end def _reduce_62(val, _values, result) result = paragraph [val[0]].concat(val[1]) - + result end def _reduce_63(val, _values, result) result = paragraph [val[0]] - + result end def _reduce_64(val, _values, result) result = paragraph [val[0]].concat(val[1]) - + result end def _reduce_65(val, _values, result) result = paragraph [val[0]] - + result end def _reduce_66(val, _values, result) result = [val[0]].concat(val[1]) - + result end def _reduce_67(val, _values, result) - result.concat val[1] + result.concat val[1] result end def _reduce_68(val, _values, result) - result = val[1] + result = val[1] result end def _reduce_69(val, _values, result) - result = val + result = val result end # reduce 70 omitted def _reduce_71(val, _values, result) - result = [] + result = [] result end def _reduce_72(val, _values, result) - result = [] + result = [] result end diff --git a/lib/rdoc/rd/inline_parser.rb b/lib/rdoc/rd/inline_parser.rb index 783a5a7c7e..f0d5a1ae7e 100644 --- a/lib/rdoc/rd/inline_parser.rb +++ b/lib/rdoc/rd/inline_parser.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # # DO NOT MODIFY!!!! # This file is automatically generated by Racc 1.4.14 @@ -96,7 +97,7 @@ end def parse inline @inline = inline @src = StringScanner.new inline - @pre = "" + @pre = "".dup @yydebug = true do_parse.to_s end @@ -732,12 +733,12 @@ Racc_debug_parser = false # reduce 1 omitted def _reduce_2(val, _values, result) - result.append val[1] + result.append val[1] result end def _reduce_3(val, _values, result) - result = val[0] + result = val[0] result end @@ -762,28 +763,28 @@ end def _reduce_13(val, _values, result) content = val[1] result = inline "#{content}", content - + result end def _reduce_14(val, _values, result) content = val[1] result = inline "#{content}", content - + result end def _reduce_15(val, _values, result) content = val[1] result = inline "+#{content}+", content - + result end def _reduce_16(val, _values, result) content = val[1] result = inline "#{content}", content - + result end @@ -791,13 +792,13 @@ def _reduce_17(val, _values, result) label = val[1] @block_parser.add_label label.reference result = "#{label}" - + result end def _reduce_18(val, _values, result) result = "{#{val[1]}}[#{val[2].join}]" - + result end @@ -805,13 +806,13 @@ def _reduce_19(val, _values, result) scheme, inline = val[1] result = "{#{inline}}[#{scheme}#{inline.reference}]" - + result end def _reduce_20(val, _values, result) result = [nil, inline(val[1])] - + result end @@ -820,25 +821,25 @@ def _reduce_21(val, _values, result) 'rdoc-label:', inline("#{val[0].reference}/#{val[1].reference}") ] - + result end def _reduce_22(val, _values, result) result = ['rdoc-label:', val[0].reference] - + result end def _reduce_23(val, _values, result) result = ['rdoc-label:', "#{val[0].reference}/"] - + result end def _reduce_24(val, _values, result) result = [nil, inline(val[1])] - + result end @@ -847,92 +848,92 @@ def _reduce_25(val, _values, result) 'rdoc-label:', inline("#{val[0].reference}/#{val[1].reference}") ] - + result end def _reduce_26(val, _values, result) result = ['rdoc-label:', val[0]] - + result end def _reduce_27(val, _values, result) ref = val[0].reference result = ['rdoc-label:', inline(ref, "#{ref}/")] - + result end # reduce 28 omitted def _reduce_29(val, _values, result) - result = val[1] + result = val[1] result end def _reduce_30(val, _values, result) - result = val[1] + result = val[1] result end def _reduce_31(val, _values, result) result = inline val[0] - + result end def _reduce_32(val, _values, result) result = inline "\"#{val[1]}\"" - + result end def _reduce_33(val, _values, result) result = inline val[0] - + result end def _reduce_34(val, _values, result) result = inline "\"#{val[1]}\"" - + result end # reduce 35 omitted def _reduce_36(val, _values, result) - result = val[1] + result = val[1] result end def _reduce_37(val, _values, result) - result = inline val[1] + result = inline val[1] result end def _reduce_38(val, _values, result) result = val[0].append val[1] - + result end def _reduce_39(val, _values, result) result = val[0].append val[1] - + result end def _reduce_40(val, _values, result) result = val[0] - + result end def _reduce_41(val, _values, result) result = inline val[0] - + result end @@ -940,25 +941,25 @@ end def _reduce_43(val, _values, result) result = val[0].append val[1] - + result end def _reduce_44(val, _values, result) result = inline val[0] - + result end def _reduce_45(val, _values, result) result = val[0].append val[1] - + result end def _reduce_46(val, _values, result) result = val[0] - + result end @@ -984,24 +985,24 @@ end def _reduce_57(val, _values, result) result = val[0] - + result end def _reduce_58(val, _values, result) result = inline val[0] - + result end def _reduce_59(val, _values, result) result = inline val[0] - + result end def _reduce_60(val, _values, result) - result << val[1] + result << val[1] result end @@ -1009,7 +1010,7 @@ end def _reduce_62(val, _values, result) result << val[1] - + result end @@ -1017,7 +1018,7 @@ end def _reduce_64(val, _values, result) result << val[1] - + result end @@ -1048,7 +1049,7 @@ end # reduce 77 omitted def _reduce_78(val, _values, result) - result << val[1] + result << val[1] result end @@ -1099,13 +1100,13 @@ end def _reduce_101(val, _values, result) index = @block_parser.add_footnote val[1].rdoc result = "{*#{index}}[rdoc-label:foottext-#{index}:footmark-#{index}]" - + result end def _reduce_102(val, _values, result) result = inline "#{val[1]}", val[1] - + result end @@ -1122,7 +1123,7 @@ end # reduce 108 omitted def _reduce_109(val, _values, result) - result << val[1] + result << val[1] result end @@ -1130,24 +1131,24 @@ end def _reduce_111(val, _values, result) result = inline val[0] - + result end # reduce 112 omitted def _reduce_113(val, _values, result) - result = val[1] + result = val[1] result end def _reduce_114(val, _values, result) - result = val[1] + result = val[1] result end def _reduce_115(val, _values, result) - result = val[1] + result = val[1] result end @@ -1192,7 +1193,7 @@ end # reduce 135 omitted def _reduce_136(val, _values, result) - result << val[1] + result << val[1] result end diff --git a/lib/rdoc/rdoc.gemspec b/lib/rdoc/rdoc.gemspec index 8c92908a66..59d8fb52c3 100644 --- a/lib/rdoc/rdoc.gemspec +++ b/lib/rdoc/rdoc.gemspec @@ -1,14 +1,19 @@ begin require_relative "lib/rdoc" rescue LoadError - # for Ruby repository - require_relative "../rdoc" + begin + # for Ruby repository + require_relative "../rdoc" + rescue LoadError + # for JRuby + $LOAD_PATH.unshift File.expand_path('../lib', __FILE__) + require "rdoc" + end end Gem::Specification.new do |s| s.name = "rdoc" s.version = RDoc::VERSION - s.date = "2017-12-24" s.authors = [ "Eric Hodel", @@ -33,7 +38,7 @@ RDoc includes the +rdoc+ and +ri+ tools for generating and displaying documentat s.executables = ["rdoc", "ri"] s.require_paths = ["lib"] # for ruby core repository. It was generated by `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } - s.files = [".document", ".gitignore", ".travis.yml", "CONTRIBUTING.rdoc", "CVE-2013-0256.rdoc", "ExampleMarkdown.md", "ExampleRDoc.rdoc", "Gemfile", "History.rdoc", "LEGAL.rdoc", "LICENSE.rdoc", "README.rdoc", "RI.rdoc", "Rakefile", "TODO.rdoc", "appveyor.yml", "bin/console", "bin/setup", "exe/rdoc", "exe/ri", "lib/rdoc.rb", "lib/rdoc/alias.rb", "lib/rdoc/anon_class.rb", "lib/rdoc/any_method.rb", "lib/rdoc/attr.rb", "lib/rdoc/class_module.rb", "lib/rdoc/code_object.rb", "lib/rdoc/code_objects.rb", "lib/rdoc/comment.rb", "lib/rdoc/constant.rb", "lib/rdoc/context.rb", "lib/rdoc/context/section.rb", "lib/rdoc/cross_reference.rb", "lib/rdoc/encoding.rb", "lib/rdoc/erb_partial.rb", "lib/rdoc/erbio.rb", "lib/rdoc/extend.rb", "lib/rdoc/generator.rb", "lib/rdoc/generator/darkfish.rb", "lib/rdoc/generator/json_index.rb", "lib/rdoc/generator/markup.rb", "lib/rdoc/generator/pot.rb", "lib/rdoc/generator/pot/message_extractor.rb", "lib/rdoc/generator/pot/po.rb", "lib/rdoc/generator/pot/po_entry.rb", "lib/rdoc/generator/ri.rb", "lib/rdoc/generator/template/darkfish/.document", "lib/rdoc/generator/template/darkfish/_footer.rhtml", "lib/rdoc/generator/template/darkfish/_head.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml", "lib/rdoc/generator/template/darkfish/class.rhtml", "lib/rdoc/generator/template/darkfish/css/fonts.css", "lib/rdoc/generator/template/darkfish/css/rdoc.css", "lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf", "lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf", "lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf", "lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf", "lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf", "lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf", "lib/rdoc/generator/template/darkfish/images/add.png", "lib/rdoc/generator/template/darkfish/images/arrow_up.png", "lib/rdoc/generator/template/darkfish/images/brick.png", "lib/rdoc/generator/template/darkfish/images/brick_link.png", "lib/rdoc/generator/template/darkfish/images/bug.png", "lib/rdoc/generator/template/darkfish/images/bullet_black.png", "lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png", "lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png", "lib/rdoc/generator/template/darkfish/images/date.png", "lib/rdoc/generator/template/darkfish/images/delete.png", "lib/rdoc/generator/template/darkfish/images/find.png", "lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif", "lib/rdoc/generator/template/darkfish/images/macFFBgHack.png", "lib/rdoc/generator/template/darkfish/images/package.png", "lib/rdoc/generator/template/darkfish/images/page_green.png", "lib/rdoc/generator/template/darkfish/images/page_white_text.png", "lib/rdoc/generator/template/darkfish/images/page_white_width.png", "lib/rdoc/generator/template/darkfish/images/plugin.png", "lib/rdoc/generator/template/darkfish/images/ruby.png", "lib/rdoc/generator/template/darkfish/images/tag_blue.png", "lib/rdoc/generator/template/darkfish/images/tag_green.png", "lib/rdoc/generator/template/darkfish/images/transparent.png", "lib/rdoc/generator/template/darkfish/images/wrench.png", "lib/rdoc/generator/template/darkfish/images/wrench_orange.png", "lib/rdoc/generator/template/darkfish/images/zoom.png", "lib/rdoc/generator/template/darkfish/index.rhtml", "lib/rdoc/generator/template/darkfish/js/darkfish.js", "lib/rdoc/generator/template/darkfish/js/jquery.js", "lib/rdoc/generator/template/darkfish/js/search.js", "lib/rdoc/generator/template/darkfish/page.rhtml", "lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml", "lib/rdoc/generator/template/darkfish/servlet_root.rhtml", "lib/rdoc/generator/template/darkfish/table_of_contents.rhtml", "lib/rdoc/generator/template/json_index/.document", "lib/rdoc/generator/template/json_index/js/navigation.js", "lib/rdoc/generator/template/json_index/js/searcher.js", "lib/rdoc/ghost_method.rb", "lib/rdoc/i18n.rb", "lib/rdoc/i18n/locale.rb", "lib/rdoc/i18n/text.rb", "lib/rdoc/include.rb", "lib/rdoc/known_classes.rb", "lib/rdoc/markdown.kpeg", "lib/rdoc/markdown/entities.rb", "lib/rdoc/markdown/literals.kpeg", "lib/rdoc/markup.rb", "lib/rdoc/markup/attr_changer.rb", "lib/rdoc/markup/attr_span.rb", "lib/rdoc/markup/attribute_manager.rb", "lib/rdoc/markup/attributes.rb", "lib/rdoc/markup/blank_line.rb", "lib/rdoc/markup/block_quote.rb", "lib/rdoc/markup/document.rb", "lib/rdoc/markup/formatter.rb", "lib/rdoc/markup/formatter_test_case.rb", "lib/rdoc/markup/hard_break.rb", "lib/rdoc/markup/heading.rb", "lib/rdoc/markup/include.rb", "lib/rdoc/markup/indented_paragraph.rb", "lib/rdoc/markup/inline.rb", "lib/rdoc/markup/list.rb", "lib/rdoc/markup/list_item.rb", "lib/rdoc/markup/paragraph.rb", "lib/rdoc/markup/parser.rb", "lib/rdoc/markup/pre_process.rb", "lib/rdoc/markup/raw.rb", "lib/rdoc/markup/rule.rb", "lib/rdoc/markup/special.rb", "lib/rdoc/markup/text_formatter_test_case.rb", "lib/rdoc/markup/to_ansi.rb", "lib/rdoc/markup/to_bs.rb", "lib/rdoc/markup/to_html.rb", "lib/rdoc/markup/to_html_crossref.rb", "lib/rdoc/markup/to_html_snippet.rb", "lib/rdoc/markup/to_joined_paragraph.rb", "lib/rdoc/markup/to_label.rb", "lib/rdoc/markup/to_markdown.rb", "lib/rdoc/markup/to_rdoc.rb", "lib/rdoc/markup/to_table_of_contents.rb", "lib/rdoc/markup/to_test.rb", "lib/rdoc/markup/to_tt_only.rb", "lib/rdoc/markup/verbatim.rb", "lib/rdoc/meta_method.rb", "lib/rdoc/method_attr.rb", "lib/rdoc/mixin.rb", "lib/rdoc/normal_class.rb", "lib/rdoc/normal_module.rb", "lib/rdoc/options.rb", "lib/rdoc/parser.rb", "lib/rdoc/parser/c.rb", "lib/rdoc/parser/changelog.rb", "lib/rdoc/parser/markdown.rb", "lib/rdoc/parser/rd.rb", "lib/rdoc/parser/ripper_state_lex.rb", "lib/rdoc/parser/ruby.rb", "lib/rdoc/parser/ruby_tools.rb", "lib/rdoc/parser/simple.rb", "lib/rdoc/parser/text.rb", "lib/rdoc/rd.rb", "lib/rdoc/rd/block_parser.ry", "lib/rdoc/rd/inline.rb", "lib/rdoc/rd/inline_parser.ry", "lib/rdoc/rdoc.rb", "lib/rdoc/require.rb", "lib/rdoc/ri.rb", "lib/rdoc/ri/driver.rb", "lib/rdoc/ri/formatter.rb", "lib/rdoc/ri/paths.rb", "lib/rdoc/ri/store.rb", "lib/rdoc/ri/task.rb", "lib/rdoc/rubygems_hook.rb", "lib/rdoc/servlet.rb", "lib/rdoc/single_class.rb", "lib/rdoc/stats.rb", "lib/rdoc/stats/normal.rb", "lib/rdoc/stats/quiet.rb", "lib/rdoc/stats/verbose.rb", "lib/rdoc/store.rb", "lib/rdoc/task.rb", "lib/rdoc/test_case.rb", "lib/rdoc/text.rb", "lib/rdoc/token_stream.rb", "lib/rdoc/tom_doc.rb", "lib/rdoc/top_level.rb", "rdoc.gemspec"] + s.files = [".document", ".gitignore", ".travis.yml", "CONTRIBUTING.rdoc", "CVE-2013-0256.rdoc", "ExampleMarkdown.md", "ExampleRDoc.rdoc", "Gemfile", "History.rdoc", "LEGAL.rdoc", "LICENSE.rdoc", "README.rdoc", "RI.rdoc", "Rakefile", "TODO.rdoc", "appveyor.yml", "bin/console", "bin/setup", "exe/rdoc", "exe/ri", "lib/rdoc.rb", "lib/rdoc/alias.rb", "lib/rdoc/anon_class.rb", "lib/rdoc/any_method.rb", "lib/rdoc/attr.rb", "lib/rdoc/class_module.rb", "lib/rdoc/code_object.rb", "lib/rdoc/code_objects.rb", "lib/rdoc/comment.rb", "lib/rdoc/constant.rb", "lib/rdoc/context.rb", "lib/rdoc/context/section.rb", "lib/rdoc/cross_reference.rb", "lib/rdoc/encoding.rb", "lib/rdoc/erb_partial.rb", "lib/rdoc/erbio.rb", "lib/rdoc/extend.rb", "lib/rdoc/generator.rb", "lib/rdoc/generator/darkfish.rb", "lib/rdoc/generator/json_index.rb", "lib/rdoc/generator/markup.rb", "lib/rdoc/generator/pot.rb", "lib/rdoc/generator/pot/message_extractor.rb", "lib/rdoc/generator/pot/po.rb", "lib/rdoc/generator/pot/po_entry.rb", "lib/rdoc/generator/ri.rb", "lib/rdoc/generator/template/darkfish/.document", "lib/rdoc/generator/template/darkfish/_footer.rhtml", "lib/rdoc/generator/template/darkfish/_head.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml", "lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml", "lib/rdoc/generator/template/darkfish/class.rhtml", "lib/rdoc/generator/template/darkfish/css/fonts.css", "lib/rdoc/generator/template/darkfish/css/rdoc.css", "lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf", "lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf", "lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf", "lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf", "lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf", "lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf", "lib/rdoc/generator/template/darkfish/images/add.png", "lib/rdoc/generator/template/darkfish/images/arrow_up.png", "lib/rdoc/generator/template/darkfish/images/brick.png", "lib/rdoc/generator/template/darkfish/images/brick_link.png", "lib/rdoc/generator/template/darkfish/images/bug.png", "lib/rdoc/generator/template/darkfish/images/bullet_black.png", "lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png", "lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png", "lib/rdoc/generator/template/darkfish/images/date.png", "lib/rdoc/generator/template/darkfish/images/delete.png", "lib/rdoc/generator/template/darkfish/images/find.png", "lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif", "lib/rdoc/generator/template/darkfish/images/macFFBgHack.png", "lib/rdoc/generator/template/darkfish/images/package.png", "lib/rdoc/generator/template/darkfish/images/page_green.png", "lib/rdoc/generator/template/darkfish/images/page_white_text.png", "lib/rdoc/generator/template/darkfish/images/page_white_width.png", "lib/rdoc/generator/template/darkfish/images/plugin.png", "lib/rdoc/generator/template/darkfish/images/ruby.png", "lib/rdoc/generator/template/darkfish/images/tag_blue.png", "lib/rdoc/generator/template/darkfish/images/tag_green.png", "lib/rdoc/generator/template/darkfish/images/transparent.png", "lib/rdoc/generator/template/darkfish/images/wrench.png", "lib/rdoc/generator/template/darkfish/images/wrench_orange.png", "lib/rdoc/generator/template/darkfish/images/zoom.png", "lib/rdoc/generator/template/darkfish/index.rhtml", "lib/rdoc/generator/template/darkfish/js/darkfish.js", "lib/rdoc/generator/template/darkfish/js/jquery.js", "lib/rdoc/generator/template/darkfish/js/search.js", "lib/rdoc/generator/template/darkfish/page.rhtml", "lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml", "lib/rdoc/generator/template/darkfish/servlet_root.rhtml", "lib/rdoc/generator/template/darkfish/table_of_contents.rhtml", "lib/rdoc/generator/template/json_index/.document", "lib/rdoc/generator/template/json_index/js/navigation.js", "lib/rdoc/generator/template/json_index/js/searcher.js", "lib/rdoc/ghost_method.rb", "lib/rdoc/i18n.rb", "lib/rdoc/i18n/locale.rb", "lib/rdoc/i18n/text.rb", "lib/rdoc/include.rb", "lib/rdoc/known_classes.rb", "lib/rdoc/markdown.kpeg", "lib/rdoc/markdown/entities.rb", "lib/rdoc/markdown/literals.kpeg", "lib/rdoc/markup.rb", "lib/rdoc/markup/attr_changer.rb", "lib/rdoc/markup/attr_span.rb", "lib/rdoc/markup/attribute_manager.rb", "lib/rdoc/markup/attributes.rb", "lib/rdoc/markup/blank_line.rb", "lib/rdoc/markup/block_quote.rb", "lib/rdoc/markup/document.rb", "lib/rdoc/markup/formatter.rb", "lib/rdoc/markup/formatter_test_case.rb", "lib/rdoc/markup/hard_break.rb", "lib/rdoc/markup/heading.rb", "lib/rdoc/markup/include.rb", "lib/rdoc/markup/indented_paragraph.rb", "lib/rdoc/markup/inline.rb", "lib/rdoc/markup/list.rb", "lib/rdoc/markup/list_item.rb", "lib/rdoc/markup/paragraph.rb", "lib/rdoc/markup/parser.rb", "lib/rdoc/markup/pre_process.rb", "lib/rdoc/markup/raw.rb", "lib/rdoc/markup/rule.rb", "lib/rdoc/markup/special.rb", "lib/rdoc/markup/text_formatter_test_case.rb", "lib/rdoc/markup/to_ansi.rb", "lib/rdoc/markup/to_bs.rb", "lib/rdoc/markup/to_html.rb", "lib/rdoc/markup/to_html_crossref.rb", "lib/rdoc/markup/to_html_snippet.rb", "lib/rdoc/markup/to_joined_paragraph.rb", "lib/rdoc/markup/to_label.rb", "lib/rdoc/markup/to_markdown.rb", "lib/rdoc/markup/to_rdoc.rb", "lib/rdoc/markup/to_table_of_contents.rb", "lib/rdoc/markup/to_test.rb", "lib/rdoc/markup/to_tt_only.rb", "lib/rdoc/markup/verbatim.rb", "lib/rdoc/meta_method.rb", "lib/rdoc/method_attr.rb", "lib/rdoc/mixin.rb", "lib/rdoc/normal_class.rb", "lib/rdoc/normal_module.rb", "lib/rdoc/options.rb", "lib/rdoc/parser.rb", "lib/rdoc/parser/c.rb", "lib/rdoc/parser/changelog.rb", "lib/rdoc/parser/markdown.rb", "lib/rdoc/parser/rd.rb", "lib/rdoc/parser/ripper_state_lex.rb", "lib/rdoc/parser/ruby.rb", "lib/rdoc/parser/ruby_tools.rb", "lib/rdoc/parser/simple.rb", "lib/rdoc/parser/text.rb", "lib/rdoc/rd.rb", "lib/rdoc/rd/block_parser.ry", "lib/rdoc/rd/inline.rb", "lib/rdoc/rd/inline_parser.ry", "lib/rdoc/rdoc.rb", "lib/rdoc/require.rb", "lib/rdoc/ri.rb", "lib/rdoc/ri/driver.rb", "lib/rdoc/ri/formatter.rb", "lib/rdoc/ri/paths.rb", "lib/rdoc/ri/store.rb", "lib/rdoc/ri/task.rb", "lib/rdoc/rubygems_hook.rb", "lib/rdoc/servlet.rb", "lib/rdoc/single_class.rb", "lib/rdoc/stats.rb", "lib/rdoc/stats/normal.rb", "lib/rdoc/stats/quiet.rb", "lib/rdoc/stats/verbose.rb", "lib/rdoc/store.rb", "lib/rdoc/task.rb", "lib/rdoc/text.rb", "lib/rdoc/token_stream.rb", "lib/rdoc/tom_doc.rb", "lib/rdoc/top_level.rb", "rdoc.gemspec"] # files from .gitignore s.files << "lib/rdoc/rd/block_parser.rb" << "lib/rdoc/rd/inline_parser.rb" << "lib/rdoc/markdown.rb" << "lib/rdoc/markdown/literals.rb" @@ -58,6 +63,5 @@ RDoc includes the +rdoc+ and +ri+ tools for generating and displaying documentat s.add_development_dependency("rake") s.add_development_dependency("racc", "> 1.4.10") s.add_development_dependency("kpeg") - s.add_development_dependency("minitest", "~> 4") - s.add_development_dependency("json") + s.add_development_dependency("minitest", "~> 5") end diff --git a/lib/rdoc/rdoc.rb b/lib/rdoc/rdoc.rb index 68775c8be1..31a92b3bec 100644 --- a/lib/rdoc/rdoc.rb +++ b/lib/rdoc/rdoc.rb @@ -35,11 +35,6 @@ class RDoc::RDoc GENERATORS = {} - ## - # File pattern to exclude - - attr_accessor :exclude - ## # Generator instance used for creating output @@ -93,7 +88,6 @@ class RDoc::RDoc def initialize @current = nil - @exclude = nil @generator = nil @last_modified = {} @old_siginfo = nil @@ -116,7 +110,7 @@ class RDoc::RDoc def gather_files files files = ["."] if files.empty? - file_list = normalized_file_list files, true, @exclude + file_list = normalized_file_list files, true, @options.exclude file_list = file_list.uniq @@ -188,7 +182,7 @@ class RDoc::RDoc error "#{dir} exists and is not a directory" unless File.directory? dir begin - open flag_file do |io| + File.open flag_file do |io| unless force then Time.parse io.gets @@ -232,8 +226,11 @@ option) def update_output_dir(op_dir, time, last = {}) return if @options.dry_run or not @options.update_output_dir + unless ENV['SOURCE_DATE_EPOCH'].nil? + time = Time.at(ENV['SOURCE_DATE_EPOCH'].to_i).gmtime + end - open output_flag_file(op_dir), "w" do |f| + File.open output_flag_file(op_dir), "w" do |f| f.puts time.rfc2822 last.each do |n, t| f.puts "#{n}\t#{t.rfc2822}" @@ -261,7 +258,7 @@ option) patterns.split.each do |patt| candidates = Dir.glob(File.join(in_dir, patt)) - result.concat normalized_file_list(candidates) + result.concat normalized_file_list(candidates, false, @options.exclude) end result @@ -469,8 +466,6 @@ The internal error was: exit end - @exclude = @options.exclude - unless @options.coverage_report then @last_modified = setup_output_dir @options.op_dir, @options.force_update end diff --git a/lib/rdoc/ri/driver.rb b/lib/rdoc/ri/driver.rb index fa0e040a42..c4d1dd03df 100644 --- a/lib/rdoc/ri/driver.rb +++ b/lib/rdoc/ri/driver.rb @@ -110,7 +110,7 @@ class RDoc::RI::Driver def self.dump data_path require 'pp' - open data_path, 'rb' do |io| + File.open data_path, 'rb' do |io| pp Marshal.load(io.read) end end @@ -425,6 +425,7 @@ or the PAGER environment variable. @server = options[:server] @use_stdout = options[:use_stdout] @show_all = options[:show_all] + @width = options[:width] # pager process for jruby @jruby_pager_process = nil @@ -795,7 +796,9 @@ or the PAGER environment variable. def display document page do |io| - text = document.accept formatter(io) + f = formatter(io) + f.width = @width if @width and f.respond_to?(:width) + text = document.accept f io.write text end @@ -1440,7 +1443,13 @@ or the PAGER environment variable. render_method_arguments out, method.arglists render_method_superclass out, method - render_method_comment out, method + if method.is_alias_for + al = method.is_alias_for + alias_for = store.load_method al.parent_name, "#{al.name_prefix}#{al.name}" + render_method_comment out, method, alias_for + else + render_method_comment out, method + end end def render_method_arguments out, arglists # :nodoc: @@ -1452,10 +1461,22 @@ or the PAGER environment variable. out << RDoc::Markup::Rule.new(1) end - def render_method_comment out, method # :nodoc: - out << RDoc::Markup::BlankLine.new - out << method.comment - out << RDoc::Markup::BlankLine.new + def render_method_comment out, method, alias_for = nil# :nodoc: + if alias_for + unless method.comment.nil? or method.comment.empty? + out << RDoc::Markup::BlankLine.new + out << method.comment + end + out << RDoc::Markup::BlankLine.new + out << RDoc::Markup::Paragraph.new("(this method is alias for #{alias_for.full_name})") + out << RDoc::Markup::BlankLine.new + out << alias_for.comment + out << RDoc::Markup::BlankLine.new + else + out << RDoc::Markup::BlankLine.new + out << method.comment + out << RDoc::Markup::BlankLine.new + end end def render_method_superclass out, method # :nodoc: diff --git a/lib/rdoc/servlet.rb b/lib/rdoc/servlet.rb index f2d6dd5adc..79550fe63b 100644 --- a/lib/rdoc/servlet.rb +++ b/lib/rdoc/servlet.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true require 'rdoc' +require 'erb' require 'time' require 'json' require 'webrick' @@ -111,7 +112,7 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet # GET request entry point. Fills in +res+ for the path, etc. in +req+. def do_GET req, res - req.path = req.path.sub(/^#{Regexp.escape @mount_path}/o, '') if @mount_path + req.path.sub!(/^#{Regexp.escape @mount_path}/o, '') if @mount_path case req.path when '/' then @@ -427,14 +428,14 @@ version. If you're viewing Ruby's documentation, include the version of ruby. end raise WEBrick::HTTPStatus::NotFound, - "Could not find gem \"#{source_name}\". Are you sure you installed it?" unless ri_dir + "Could not find gem \"#{ERB::Util.html_escape(source_name)}\". Are you sure you installed it?" unless ri_dir store = RDoc::Store.new ri_dir, type return store if File.exist? store.cache_path raise WEBrick::HTTPStatus::NotFound, - "Could not find documentation for \"#{source_name}\". Please run `gem rdoc --ri gem_name`" + "Could not find documentation for \"#{ERB::Util.html_escape(source_name)}\". Please run `gem rdoc --ri gem_name`" end end diff --git a/lib/rdoc/store.rb b/lib/rdoc/store.rb index 999aa76f92..b7e677abf9 100644 --- a/lib/rdoc/store.rb +++ b/lib/rdoc/store.rb @@ -116,6 +116,11 @@ class RDoc::Store attr_accessor :encoding + ## + # The lazy constants alias will be discovered in passing + + attr_reader :unmatched_constant_alias + ## # Creates a new Store of +type+ that will load or save to +path+ @@ -152,6 +157,8 @@ class RDoc::Store @unique_classes = nil @unique_modules = nil + + @unmatched_constant_alias = {} end ## @@ -539,7 +546,7 @@ class RDoc::Store def load_cache #orig_enc = @encoding - open cache_path, 'rb' do |io| + File.open cache_path, 'rb' do |io| @cache = Marshal.load io.read end @@ -585,6 +592,8 @@ class RDoc::Store case obj when RDoc::NormalClass then @classes_hash[klass_name] = obj + when RDoc::SingleClass then + @classes_hash[klass_name] = obj when RDoc::NormalModule then @modules_hash[klass_name] = obj end @@ -596,7 +605,7 @@ class RDoc::Store def load_class_data klass_name file = class_file klass_name - open file, 'rb' do |io| + File.open file, 'rb' do |io| Marshal.load io.read end rescue Errno::ENOENT => e @@ -611,7 +620,7 @@ class RDoc::Store def load_method klass_name, method_name file = method_file klass_name, method_name - open file, 'rb' do |io| + File.open file, 'rb' do |io| obj = Marshal.load io.read obj.store = self obj.parent = @@ -631,7 +640,7 @@ class RDoc::Store def load_page page_name file = page_file page_name - open file, 'rb' do |io| + File.open file, 'rb' do |io| obj = Marshal.load io.read obj.store = self obj @@ -778,7 +787,7 @@ class RDoc::Store marshal = Marshal.dump @cache - open cache_path, 'wb' do |io| + File.open cache_path, 'wb' do |io| io.write marshal end end @@ -854,7 +863,7 @@ class RDoc::Store marshal = Marshal.dump klass - open path, 'wb' do |io| + File.open path, 'wb' do |io| io.write marshal end end @@ -879,7 +888,7 @@ class RDoc::Store marshal = Marshal.dump method - open method_file(full_name, method.full_name), 'wb' do |io| + File.open method_file(full_name, method.full_name), 'wb' do |io| io.write marshal end end @@ -901,7 +910,7 @@ class RDoc::Store marshal = Marshal.dump page - open path, 'wb' do |io| + File.open path, 'wb' do |io| io.write marshal end end diff --git a/lib/rdoc/text.rb b/lib/rdoc/text.rb index 7e714be0ad..def80d98a3 100644 --- a/lib/rdoc/text.rb +++ b/lib/rdoc/text.rb @@ -169,7 +169,7 @@ module RDoc::Text encoding = text.encoding - text = text.gsub %r%Document-method:\s+[\w:.#=!?]+%, '' + text = text.gsub %r%Document-method:\s+[\w:.#=!?|^&<>~+-/*\%@`\[\]]+%, '' space = ' ' space = RDoc::Encoding.change_encoding space, encoding if encoding diff --git a/lib/rdoc/token_stream.rb b/lib/rdoc/token_stream.rb index 05fb46e89a..dbe6c5ae85 100644 --- a/lib/rdoc/token_stream.rb +++ b/lib/rdoc/token_stream.rb @@ -107,7 +107,7 @@ module RDoc::TokenStream # Returns a string representation of the token stream def tokens_to_s - token_stream.compact.map { |token| token.text }.join '' + token_stream.compact.map { |token| token[:text] }.join '' end end diff --git a/lib/rdoc/test_case.rb b/test/rdoc/minitest_helper.rb similarity index 96% rename from lib/rdoc/test_case.rb rename to test/rdoc/minitest_helper.rb index 5f38870324..1814669bf9 100644 --- a/lib/rdoc/test_case.rb +++ b/test/rdoc/minitest_helper.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true begin - gem 'minitest', '~> 4.0' unless defined?(Test::Unit) + gem 'minitest', '~> 5.0' rescue NoMethodError, Gem::LoadError # for ruby tests end @@ -29,7 +29,7 @@ require 'rdoc' # * @pwd containing the current working directory # * FileUtils, pp, Tempfile, Dir.tmpdir and StringIO -class RDoc::TestCase < MiniTest::Unit::TestCase +class RDoc::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Unit::TestCase) ## # Abstract test-case setup diff --git a/test/rdoc/test_rdoc_any_method.rb b/test/rdoc/test_rdoc_any_method.rb index 55793255ba..b5281f611d 100644 --- a/test/rdoc/test_rdoc_any_method.rb +++ b/test/rdoc/test_rdoc_any_method.rb @@ -133,7 +133,7 @@ method(a, b) { |c, d| ... } assert_equal 'Klass#method', loaded.full_name assert_equal 'method', loaded.name assert_equal 'param', loaded.params - assert_equal nil, loaded.singleton # defaults to nil + assert_nil loaded.singleton # defaults to nil assert_equal :public, loaded.visibility assert_equal cm, loaded.parent assert_equal section, loaded.section @@ -151,6 +151,19 @@ method(a, b) { |c, d| ... } assert aliased_method.display? end + def test_marshal_load_aliased_method_with_nil_singleton + aliased_method = Marshal.load Marshal.dump(@c2_a) + + aliased_method.store = @store + aliased_method.is_alias_for = ["C2", nil, "b"] + + assert_equal 'C2#a', aliased_method.full_name + assert_equal 'C2', aliased_method.parent_name + assert_equal '()', aliased_method.params + assert_equal @c2_b, aliased_method.is_alias_for, 'is_alias_for' + assert aliased_method.display? + end + def test_marshal_load_class_method class_method = Marshal.load Marshal.dump(@c1.method_list.first) @@ -207,9 +220,9 @@ method(a, b) { |c, d| ... } assert_equal 'Klass#method', loaded.full_name assert_equal 'method', loaded.name assert_equal 'param', loaded.params - assert_equal nil, loaded.singleton # defaults to nil + assert_nil loaded.singleton # defaults to nil assert_equal :public, loaded.visibility - assert_equal nil, loaded.file + assert_nil loaded.file assert_equal cm, loaded.parent assert_equal section, loaded.section assert_nil loaded.is_alias_for @@ -264,7 +277,7 @@ method(a, b) { |c, d| ... } assert_equal 'Klass#method', loaded.full_name assert_equal 'method', loaded.name assert_equal 'param', loaded.params - assert_equal nil, loaded.singleton # defaults to nil + assert_nil loaded.singleton # defaults to nil assert_equal :public, loaded.visibility assert_equal cm, loaded.parent assert_equal section, loaded.section @@ -467,4 +480,3 @@ method(a, b) { |c, d| ... } end end - diff --git a/test/rdoc/test_rdoc_attr.rb b/test/rdoc/test_rdoc_attr.rb index ae702ac702..5910c0fad3 100644 --- a/test/rdoc/test_rdoc_attr.rb +++ b/test/rdoc/test_rdoc_attr.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocAttr < RDoc::TestCase @@ -139,7 +139,7 @@ class TestRDocAttr < RDoc::TestCase assert_equal cm, loaded.parent assert_equal section, loaded.section - assert loaded.display? + assert loaded.display? end def test_marshal_load_version_2 @@ -188,4 +188,3 @@ class TestRDocAttr < RDoc::TestCase end end - diff --git a/test/rdoc/test_rdoc_class_module.rb b/test/rdoc/test_rdoc_class_module.rb index 273a21120f..3dc2a42cf4 100644 --- a/test/rdoc/test_rdoc_class_module.rb +++ b/test/rdoc/test_rdoc_class_module.rb @@ -1277,7 +1277,8 @@ class TestRDocClassModule < XrefTestCase n1 = @xref_data.add_module RDoc::NormalClass, 'N1' n1_k2 = n1.add_module RDoc::NormalClass, 'N2' - n1.add_module_alias n1_k2, 'A1', @xref_data + a1 = RDoc::Constant.new 'A1', '', '' + n1.add_module_alias n1_k2, n1_k2.name, a1, @xref_data n1_a1_c = n1.constants.find { |c| c.name == 'A1' } refute_nil n1_a1_c @@ -1301,7 +1302,8 @@ class TestRDocClassModule < XrefTestCase n1 = @xref_data.add_module RDoc::NormalModule, 'N1' n1_n2 = n1.add_module RDoc::NormalModule, 'N2' - n1.add_module_alias n1_n2, 'A1', @xref_data + a1 = RDoc::Constant.new 'A1', '', '' + n1.add_module_alias n1_n2, n1_n2.name, a1, @xref_data n1_a1_c = n1.constants.find { |c| c.name == 'A1' } refute_nil n1_a1_c @@ -1326,7 +1328,8 @@ class TestRDocClassModule < XrefTestCase l1_l2 = l1.add_module RDoc::NormalModule, 'L2' o1 = @xref_data.add_module RDoc::NormalModule, 'O1' - o1.add_module_alias l1_l2, 'A1', @xref_data + a1 = RDoc::Constant.new 'A1', '', '' + o1.add_module_alias l1_l2, l1_l2.name, a1, @xref_data o1_a1_c = o1.constants.find { |c| c.name == 'A1' } refute_nil o1_a1_c @@ -1358,7 +1361,8 @@ class TestRDocClassModule < XrefTestCase const.record_location top_level const.is_alias_for = klass - top_level.add_module_alias klass, 'A', top_level + a = RDoc::Constant.new 'A', '', '' + top_level.add_module_alias klass, klass.name, a, top_level object.add_constant const diff --git a/test/rdoc/test_rdoc_code_object.rb b/test/rdoc/test_rdoc_code_object.rb index d189ac1c4b..fad182722a 100644 --- a/test/rdoc/test_rdoc_code_object.rb +++ b/test/rdoc/test_rdoc_code_object.rb @@ -213,7 +213,7 @@ class TestRDocCodeObject < XrefTestCase end def test_file_name - assert_equal nil, @co.file_name + assert_nil @co.file_name @co.record_location @store.add_file 'lib/file.rb' diff --git a/test/rdoc/test_rdoc_comment.rb b/test/rdoc/test_rdoc_comment.rb index 567daae51c..9b3c105bb0 100644 --- a/test/rdoc/test_rdoc_comment.rb +++ b/test/rdoc/test_rdoc_comment.rb @@ -1,7 +1,7 @@ # coding: us-ascii # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocComment < RDoc::TestCase @@ -77,7 +77,7 @@ call-seq: comment.extract_call_seq m - assert_equal nil, m.call_seq + assert_nil m.call_seq end def test_extract_call_seq_no_blank diff --git a/test/rdoc/test_rdoc_constant.rb b/test/rdoc/test_rdoc_constant.rb index e715131579..79dcdad57e 100644 --- a/test/rdoc/test_rdoc_constant.rb +++ b/test/rdoc/test_rdoc_constant.rb @@ -118,7 +118,7 @@ class TestRDocConstant < XrefTestCase assert_equal cm, loaded.parent assert_equal section, loaded.section - assert loaded.display? + assert loaded.display? end def test_marshal_load_version_0 diff --git a/test/rdoc/test_rdoc_context.rb b/test/rdoc/test_rdoc_context.rb index a7d6a58716..5a9c5db39e 100644 --- a/test/rdoc/test_rdoc_context.rb +++ b/test/rdoc/test_rdoc_context.rb @@ -14,10 +14,10 @@ class TestRDocContext < XrefTestCase assert_empty @context.in_files assert_equal 'unknown', @context.name assert_equal '', @context.comment - assert_equal nil, @context.parent + assert_nil @context.parent assert_equal :public, @context.visibility assert_equal 1, @context.sections.length - assert_equal nil, @context.temporary_section + assert_nil @context.temporary_section assert_empty @context.classes_hash assert_empty @context.modules_hash @@ -280,7 +280,8 @@ class TestRDocContext < XrefTestCase def test_add_module_alias tl = @store.add_file 'file.rb' - c3_c4 = @c2.add_module_alias @c2_c3, 'C4', tl + c4 = RDoc::Constant.new 'C4', '', '' + c3_c4 = @c2.add_module_alias @c2_c3, @c2_c3.name, c4, tl alias_constant = @c2.constants.first @@ -298,7 +299,8 @@ class TestRDocContext < XrefTestCase object = top_level.add_class RDoc::NormalClass, 'Object' - top_level.add_module_alias klass, 'A', top_level + a = RDoc::Constant.new 'A', '', '' + top_level.add_module_alias klass, klass.name, a, top_level refute_empty object.constants @@ -512,7 +514,7 @@ class TestRDocContext < XrefTestCase end def test_find_attribute_named - assert_equal nil, @c1.find_attribute_named('none') + assert_nil @c1.find_attribute_named('none') assert_equal 'R', @c1.find_attribute_named('attr').rw assert_equal 'R', @c1.find_attribute_named('attr_reader').rw assert_equal 'W', @c1.find_attribute_named('attr_writer').rw @@ -520,7 +522,7 @@ class TestRDocContext < XrefTestCase end def test_find_class_method_named - assert_equal nil, @c1.find_class_method_named('none') + assert_nil @c1.find_class_method_named('none') m = @c1.find_class_method_named('m') assert_instance_of RDoc::AnyMethod, m @@ -528,23 +530,23 @@ class TestRDocContext < XrefTestCase end def test_find_constant_named - assert_equal nil, @c1.find_constant_named('NONE') + assert_nil @c1.find_constant_named('NONE') assert_equal ':const', @c1.find_constant_named('CONST').value end def test_find_enclosing_module_named - assert_equal nil, @c2_c3.find_enclosing_module_named('NONE') + assert_nil @c2_c3.find_enclosing_module_named('NONE') assert_equal @c1, @c2_c3.find_enclosing_module_named('C1') assert_equal @c2, @c2_c3.find_enclosing_module_named('C2') end def test_find_file_named - assert_equal nil, @c1.find_file_named('nonexistent.rb') + assert_nil @c1.find_file_named('nonexistent.rb') assert_equal @xref_data, @c1.find_file_named(@file_name) end def test_find_instance_method_named - assert_equal nil, @c1.find_instance_method_named('none') + assert_nil @c1.find_instance_method_named('none') m = @c1.find_instance_method_named('m') assert_instance_of RDoc::AnyMethod, m @@ -559,6 +561,14 @@ class TestRDocContext < XrefTestCase assert_equal @c2_c3, @c2.find_local_symbol('C3') end + def test_find_method + loaded_c2 = Marshal.load Marshal.dump @c2 + assert_equal @c2_a, loaded_c2.find_method('a', false) + assert_equal @c2_b, loaded_c2.find_method('b', false) + assert_equal @c2_a, loaded_c2.find_method('a', nil) + assert_equal @c2_b, loaded_c2.find_method('b', nil) + end + def test_find_method_named assert_equal true, @c1.find_method_named('m').singleton end diff --git a/test/rdoc/test_rdoc_context_section.rb b/test/rdoc/test_rdoc_context_section.rb index ff88b9b66a..f1cf493d3d 100644 --- a/test/rdoc/test_rdoc_context_section.rb +++ b/test/rdoc/test_rdoc_context_section.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocContextSection < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_encoding.rb b/test/rdoc/test_rdoc_encoding.rb index 9d9ded4bbd..5b2de47aa2 100644 --- a/test/rdoc/test_rdoc_encoding.rb +++ b/test/rdoc/test_rdoc_encoding.rb @@ -1,7 +1,7 @@ # coding: US-ASCII # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocEncoding < RDoc::TestCase @@ -31,7 +31,7 @@ class TestRDocEncoding < RDoc::TestCase @tempfile.flush contents = RDoc::Encoding.read_file @tempfile.path, Encoding::UTF_8 - assert_equal "hi everybody", contents + assert_equal "# coding: utf-8\nhi everybody", contents assert_equal Encoding::UTF_8, contents.encoding end @@ -45,7 +45,7 @@ class TestRDocEncoding < RDoc::TestCase contents = RDoc::Encoding.read_file @tempfile.path, Encoding::UTF_8 assert_equal Encoding::UTF_8, contents.encoding - assert_equal "hi \u00e9verybody", contents.sub("\r", '') + assert_equal "# coding: ISO-8859-1\nhi \u00e9verybody", contents.sub("\r", '') end def test_class_read_file_encoding_fail @@ -65,13 +65,13 @@ class TestRDocEncoding < RDoc::TestCase def test_class_read_file_encoding_fancy expected = "# -*- coding: utf-8; fill-column: 74 -*-\nhi everybody" - exptected = RDoc::Encoding.change_encoding expected, Encoding::UTF_8 + expected = RDoc::Encoding.change_encoding expected, Encoding::UTF_8 @tempfile.write expected @tempfile.flush contents = RDoc::Encoding.read_file @tempfile.path, Encoding::UTF_8 - assert_equal "hi everybody", contents + assert_equal "# -*- coding: utf-8; fill-column: 74 -*-\nhi everybody", contents assert_equal Encoding::UTF_8, contents.encoding end @@ -81,7 +81,7 @@ class TestRDocEncoding < RDoc::TestCase contents = RDoc::Encoding.read_file @tempfile.path, Encoding::US_ASCII, true - assert_equal '?', contents + assert_equal "# coding: utf-8\n?", contents assert_equal Encoding::US_ASCII, contents.encoding end @@ -124,108 +124,58 @@ class TestRDocEncoding < RDoc::TestCase contents = RDoc::Encoding.read_file @tempfile.path, Encoding::UTF_8 - expected = ":\xe3\x82\xb3\xe3\x83\x9e\xe3\x83\xb3\xe3\x83\x89:" + expected = "# coding: ISO-2022-JP\n:\xe3\x82\xb3\xe3\x83\x9e\xe3\x83\xb3\xe3\x83\x89:" expected = RDoc::Encoding.change_encoding expected, Encoding::UTF_8 assert_equal expected, contents assert_equal Encoding::UTF_8, contents.encoding end - def test_class_set_encoding + def test_class_detect_encoding s = "# coding: UTF-8\n" - s = RDoc::Encoding.set_encoding s + encoding = RDoc::Encoding.detect_encoding s # sanity check for 1.8 - assert_equal Encoding::UTF_8, s.encoding + assert_equal Encoding::UTF_8, encoding s = "#!/bin/ruby\n# coding: UTF-8\n" - s = RDoc::Encoding.set_encoding s + encoding = RDoc::Encoding.detect_encoding s - assert_equal Encoding::UTF_8, s.encoding + assert_equal Encoding::UTF_8, encoding s = "\n" - s = RDoc::Encoding.set_encoding s + encoding = RDoc::Encoding.detect_encoding s - assert_equal Encoding::UTF_8, s.encoding + assert_equal Encoding::UTF_8, encoding s = "\n" - s = RDoc::Encoding.set_encoding s + encoding = RDoc::Encoding.detect_encoding s - assert_equal Encoding::UTF_8, s.encoding - end - - def test_class_set_encoding_strip - s = "# coding: UTF-8\n# more comments" - - s = RDoc::Encoding.set_encoding s - - assert_equal "# more comments", s - - s = "#!/bin/ruby\n# coding: UTF-8\n# more comments" - - s = RDoc::Encoding.set_encoding s - - assert_equal "#!/bin/ruby\n# more comments", s + assert_equal Encoding::UTF_8, encoding end def test_class_set_encoding_bad s = "" - expected = s.encoding - s = RDoc::Encoding.set_encoding s + encoding = RDoc::Encoding.detect_encoding s - assert_equal expected, s.encoding + assert_nil encoding s = "# vim:set fileencoding=utf-8:\n" - expected = s.encoding - s = RDoc::Encoding.set_encoding s + encoding = RDoc::Encoding.detect_encoding s - assert_equal expected, s.encoding + assert_nil encoding s = "# vim:set fileencoding=utf-8:\n" - expected = s.encoding - s = RDoc::Encoding.set_encoding s + encoding = RDoc::Encoding.detect_encoding s - assert_equal expected, s.encoding + assert_nil encoding assert_raises ArgumentError do - s = RDoc::Encoding.set_encoding "# -*- encoding: undecided -*-\n" + s = RDoc::Encoding.detect_encoding "# -*- encoding: undecided -*-\n" end end - def test_skip_frozen_string_literal - expected = "# frozen_string_literal: true\nhi everybody" - - @tempfile.write expected - @tempfile.flush - - contents = RDoc::Encoding.read_file @tempfile.path, Encoding::UTF_8 - assert_equal "hi everybody", contents - assert_equal Encoding::UTF_8, contents.encoding - end - - def test_skip_frozen_string_literal_after_coding - expected = "# coding: utf-8\n# frozen-string-literal: false\nhi everybody" - - @tempfile.write expected - @tempfile.flush - - contents = RDoc::Encoding.read_file @tempfile.path, Encoding::UTF_8 - assert_equal "hi everybody", contents - assert_equal Encoding::UTF_8, contents.encoding - end - - def test_skip_frozen_string_literal_before_coding - expected = "# frozen_string_literal: true\n# coding: utf-8\nhi everybody" - - @tempfile.write expected - @tempfile.flush - - contents = RDoc::Encoding.read_file @tempfile.path, Encoding::UTF_8 - assert_equal "hi everybody", contents - assert_equal Encoding::UTF_8, contents.encoding - end - def test_sanity assert_equal Encoding::US_ASCII, ''.encoding, 'If this file is not ASCII tests may incorrectly pass' diff --git a/test/rdoc/test_rdoc_generator_darkfish.rb b/test/rdoc/test_rdoc_generator_darkfish.rb index c004bb271e..edabe4fad4 100644 --- a/test/rdoc/test_rdoc_generator_darkfish.rb +++ b/test/rdoc/test_rdoc_generator_darkfish.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocGeneratorDarkfish < RDoc::TestCase @@ -39,7 +39,7 @@ class TestRDocGeneratorDarkfish < RDoc::TestCase @top_level.add_constant @alias_constant - @klass.add_module_alias @klass, 'A', @top_level + @klass.add_module_alias @klass, @klass.name, @alias_constant, @top_level @meth = RDoc::AnyMethod.new nil, 'method' @meth_bang = RDoc::AnyMethod.new nil, 'method!' @@ -135,7 +135,7 @@ class TestRDocGeneratorDarkfish < RDoc::TestCase end def test_install_rdoc_static_file - src = Pathname(__FILE__) + src = Pathname File.expand_path(__FILE__, @pwd) dst = File.join @tmpdir, File.basename(src) options = {} diff --git a/test/rdoc/test_rdoc_generator_json_index.rb b/test/rdoc/test_rdoc_generator_json_index.rb index 6cb5463d29..ca7260c820 100644 --- a/test/rdoc/test_rdoc_generator_json_index.rb +++ b/test/rdoc/test_rdoc_generator_json_index.rb @@ -1,14 +1,14 @@ # coding: US-ASCII # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocGeneratorJsonIndex < RDoc::TestCase def setup super - @tmpdir = File.join Dir.tmpdir, "test_rdoc_generator_darkfish_#{$$}" + @tmpdir = Dir.mktmpdir "test_rdoc_generator_darkfish_#{$$}_" FileUtils.mkdir_p @tmpdir @options = RDoc::Options.new @@ -89,12 +89,31 @@ class TestRDocGeneratorJsonIndex < RDoc::TestCase end def test_generate + now = Time.now @g.generate assert_file 'js/searcher.js' assert_file 'js/navigation.js' assert_file 'js/search_index.js' + srcdir = File.expand_path("../../lib/rdoc", __FILE__) + if !File.directory? srcdir + # for Ruby core repository + srcdir = File.expand_path("../../../lib/rdoc", __FILE__) + end + + orig_file = Pathname(File.join srcdir, 'generator/template/json_index/js/navigation.js') + generated_file = Pathname(File.join @tmpdir, 'js/navigation.js') + + # This is dirty hack on JRuby for MiniTest 4 + assert orig_file.mtime.inspect == generated_file.mtime.inspect, + '.js files should be tha same timestamp of original' + + assert generated_file.mtime < now, '.js files should be the same timestamp' + + generated_search_index = Pathname(File.join @tmpdir, 'js/search_index.js') + assert generated_search_index.mtime > (now - 1), 'search_index.js should be generated timestamp' + json = File.read 'js/search_index.js' json =~ /\Avar search_data = / @@ -137,6 +156,20 @@ class TestRDocGeneratorJsonIndex < RDoc::TestCase assert_equal expected, index end + def test_generate_search_index_with_reproducible_builds + backup_epoch = ENV['SOURCE_DATE_EPOCH'] + ruby_birthday = Time.parse 'Wed, 24 Feb 1993 21:00:00 +0900' + ENV['SOURCE_DATE_EPOCH'] = ruby_birthday.to_i.to_s + + @g.generate + + assert_file 'js/search_index.js' + generated_search_index = Pathname(File.join @tmpdir, 'js/search_index.js') + assert_equal ruby_birthday, generated_search_index.mtime + + ENV['SOURCE_DATE_EPOCH'] = backup_epoch + end + def test_generate_gzipped begin require 'zlib' diff --git a/test/rdoc/test_rdoc_generator_markup.rb b/test/rdoc/test_rdoc_generator_markup.rb index d13f5119be..5588d9c5f0 100644 --- a/test/rdoc/test_rdoc_generator_markup.rb +++ b/test/rdoc/test_rdoc_generator_markup.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocGeneratorMarkup < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_generator_pot.rb b/test/rdoc/test_rdoc_generator_pot.rb index 5675f96b75..26641345ef 100644 --- a/test/rdoc/test_rdoc_generator_pot.rb +++ b/test/rdoc/test_rdoc_generator_pot.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocGeneratorPOT < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_generator_pot_po.rb b/test/rdoc/test_rdoc_generator_pot_po.rb index 8786f632c0..c50899d446 100644 --- a/test/rdoc/test_rdoc_generator_pot_po.rb +++ b/test/rdoc/test_rdoc_generator_pot_po.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocGeneratorPOTPO < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_generator_pot_po_entry.rb b/test/rdoc/test_rdoc_generator_pot_po_entry.rb index 5c24c2d70d..f3bf329348 100644 --- a/test/rdoc/test_rdoc_generator_pot_po_entry.rb +++ b/test/rdoc/test_rdoc_generator_pot_po_entry.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocGeneratorPOTPOEntry < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_generator_ri.rb b/test/rdoc/test_rdoc_generator_ri.rb index 02bcee8904..a33f5ca2ac 100644 --- a/test/rdoc/test_rdoc_generator_ri.rb +++ b/test/rdoc/test_rdoc_generator_ri.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocGeneratorRI < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_i18n_locale.rb b/test/rdoc/test_rdoc_i18n_locale.rb index ff9836f9a6..c936a7219f 100644 --- a/test/rdoc/test_rdoc_i18n_locale.rb +++ b/test/rdoc/test_rdoc_i18n_locale.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocI18nLocale < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_i18n_text.rb b/test/rdoc/test_rdoc_i18n_text.rb index be5ff581f5..beb9f307a7 100644 --- a/test/rdoc/test_rdoc_i18n_text.rb +++ b/test/rdoc/test_rdoc_i18n_text.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocI18nText < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_markdown.rb b/test/rdoc/test_rdoc_markdown.rb index 99f8abf5ab..8b58150f8a 100644 --- a/test/rdoc/test_rdoc_markdown.rb +++ b/test/rdoc/test_rdoc_markdown.rb @@ -1,7 +1,7 @@ # coding: UTF-8 # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' require 'rdoc/markup/block_quote' require 'rdoc/markdown' diff --git a/test/rdoc/test_rdoc_markup.rb b/test/rdoc/test_rdoc_markup.rb index 8e4e8b968e..2812a2994f 100644 --- a/test/rdoc/test_rdoc_markup.rb +++ b/test/rdoc/test_rdoc_markup.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocMarkup < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_markup_attribute_manager.rb b/test/rdoc/test_rdoc_markup_attribute_manager.rb index a939623e01..93338ecb50 100644 --- a/test/rdoc/test_rdoc_markup_attribute_manager.rb +++ b/test/rdoc/test_rdoc_markup_attribute_manager.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocMarkupAttributeManager < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_markup_attributes.rb b/test/rdoc/test_rdoc_markup_attributes.rb index 1fad62208c..91c253a6b0 100644 --- a/test/rdoc/test_rdoc_markup_attributes.rb +++ b/test/rdoc/test_rdoc_markup_attributes.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocMarkupAttributes < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_markup_document.rb b/test/rdoc/test_rdoc_markup_document.rb index d817f1b9aa..8202916238 100644 --- a/test/rdoc/test_rdoc_markup_document.rb +++ b/test/rdoc/test_rdoc_markup_document.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocMarkupDocument < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_markup_formatter.rb b/test/rdoc/test_rdoc_markup_formatter.rb index 0e7f72fb16..b1f0855de3 100644 --- a/test/rdoc/test_rdoc_markup_formatter.rb +++ b/test/rdoc/test_rdoc_markup_formatter.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocMarkupFormatter < RDoc::TestCase @@ -111,15 +111,15 @@ class TestRDocMarkupFormatter < RDoc::TestCase assert_equal 'http', scheme assert_equal 'example/foo', url - assert_equal nil, id + assert_nil id end def test_parse_url_anchor scheme, url, id = @to.parse_url '#foottext-1' - assert_equal nil, scheme + assert_nil scheme assert_equal '#foottext-1', url - assert_equal nil, id + assert_nil id end def test_parse_url_link @@ -127,7 +127,7 @@ class TestRDocMarkupFormatter < RDoc::TestCase assert_equal 'link', scheme assert_equal 'README.txt', url - assert_equal nil, id + assert_nil id end def test_parse_url_link_id @@ -135,7 +135,7 @@ class TestRDocMarkupFormatter < RDoc::TestCase assert_equal 'link', scheme assert_equal 'README.txt#label-foo', url - assert_equal nil, id + assert_nil id end def test_parse_url_rdoc_label @@ -143,7 +143,7 @@ class TestRDocMarkupFormatter < RDoc::TestCase assert_equal 'link', scheme assert_equal '#foo', url - assert_equal nil, id + assert_nil id scheme, url, id = @to.parse_url 'rdoc-label:foo:bar' @@ -157,13 +157,13 @@ class TestRDocMarkupFormatter < RDoc::TestCase assert_equal 'http', scheme assert_equal 'http://example/foo', url - assert_equal nil, id + assert_nil id scheme, url, id = @to.parse_url 'https://example/foo' assert_equal 'https', scheme assert_equal 'https://example/foo', url - assert_equal nil, id + assert_nil id end def test_convert_tt_special @@ -173,4 +173,3 @@ class TestRDocMarkupFormatter < RDoc::TestCase end end - diff --git a/test/rdoc/test_rdoc_markup_hard_break.rb b/test/rdoc/test_rdoc_markup_hard_break.rb index d93d52eeda..1d6c8927b5 100644 --- a/test/rdoc/test_rdoc_markup_hard_break.rb +++ b/test/rdoc/test_rdoc_markup_hard_break.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocMarkupHardBreak < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_markup_heading.rb b/test/rdoc/test_rdoc_markup_heading.rb index 33e29e90e6..4508561a79 100644 --- a/test/rdoc/test_rdoc_markup_heading.rb +++ b/test/rdoc/test_rdoc_markup_heading.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocMarkupHeading < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_markup_include.rb b/test/rdoc/test_rdoc_markup_include.rb index 28712fa7ed..6b2d570286 100644 --- a/test/rdoc/test_rdoc_markup_include.rb +++ b/test/rdoc/test_rdoc_markup_include.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocMarkupInclude < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_markup_indented_paragraph.rb b/test/rdoc/test_rdoc_markup_indented_paragraph.rb index 53d44dcec2..06dcb25357 100644 --- a/test/rdoc/test_rdoc_markup_indented_paragraph.rb +++ b/test/rdoc/test_rdoc_markup_indented_paragraph.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocMarkupIndentedParagraph < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_markup_paragraph.rb b/test/rdoc/test_rdoc_markup_paragraph.rb index dce3ed8efd..00e4320119 100644 --- a/test/rdoc/test_rdoc_markup_paragraph.rb +++ b/test/rdoc/test_rdoc_markup_paragraph.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocMarkupParagraph < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_markup_parser.rb b/test/rdoc/test_rdoc_markup_parser.rb index fa4730a06f..6d4953bc06 100644 --- a/test/rdoc/test_rdoc_markup_parser.rb +++ b/test/rdoc/test_rdoc_markup_parser.rb @@ -1,7 +1,7 @@ # coding: utf-8 # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocMarkupParser < RDoc::TestCase @@ -1068,7 +1068,7 @@ the time assert_equal [:NEWLINE, "\n", 9, 0], parser.peek_token - assert_equal nil, parser.skip(:NONE, false) + assert_nil parser.skip(:NONE, false) assert_equal [:NEWLINE, "\n", 9, 0], parser.peek_token end diff --git a/test/rdoc/test_rdoc_markup_pre_process.rb b/test/rdoc/test_rdoc_markup_pre_process.rb index 887ff6de9c..60ec75c19e 100644 --- a/test/rdoc/test_rdoc_markup_pre_process.rb +++ b/test/rdoc/test_rdoc_markup_pre_process.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocMarkupPreProcess < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_markup_raw.rb b/test/rdoc/test_rdoc_markup_raw.rb index aaf4e48439..95de62208a 100644 --- a/test/rdoc/test_rdoc_markup_raw.rb +++ b/test/rdoc/test_rdoc_markup_raw.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocMarkupRaw < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_markup_to_ansi.rb b/test/rdoc/test_rdoc_markup_to_ansi.rb index d06ad98fa3..4c312e7972 100644 --- a/test/rdoc/test_rdoc_markup_to_ansi.rb +++ b/test/rdoc/test_rdoc_markup_to_ansi.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocMarkupToAnsi < RDoc::Markup::TextFormatterTestCase diff --git a/test/rdoc/test_rdoc_markup_to_bs.rb b/test/rdoc/test_rdoc_markup_to_bs.rb index 9b798c92b3..f269790357 100644 --- a/test/rdoc/test_rdoc_markup_to_bs.rb +++ b/test/rdoc/test_rdoc_markup_to_bs.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocMarkupToBs < RDoc::Markup::TextFormatterTestCase diff --git a/test/rdoc/test_rdoc_markup_to_html.rb b/test/rdoc/test_rdoc_markup_to_html.rb index fa5828a007..59889dcc5a 100644 --- a/test/rdoc/test_rdoc_markup_to_html.rb +++ b/test/rdoc/test_rdoc_markup_to_html.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase diff --git a/test/rdoc/test_rdoc_markup_to_html_snippet.rb b/test/rdoc/test_rdoc_markup_to_html_snippet.rb index d7ce211999..98102ba553 100644 --- a/test/rdoc/test_rdoc_markup_to_html_snippet.rb +++ b/test/rdoc/test_rdoc_markup_to_html_snippet.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocMarkupToHtmlSnippet < RDoc::Markup::FormatterTestCase diff --git a/test/rdoc/test_rdoc_markup_to_joined_paragraph.rb b/test/rdoc/test_rdoc_markup_to_joined_paragraph.rb index 0a6a864bfa..b4eed5f601 100644 --- a/test/rdoc/test_rdoc_markup_to_joined_paragraph.rb +++ b/test/rdoc/test_rdoc_markup_to_joined_paragraph.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocMarkupToJoinedParagraph < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_markup_to_label.rb b/test/rdoc/test_rdoc_markup_to_label.rb index 23ab8cbfab..b869745528 100644 --- a/test/rdoc/test_rdoc_markup_to_label.rb +++ b/test/rdoc/test_rdoc_markup_to_label.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocMarkupToLabel < RDoc::Markup::FormatterTestCase diff --git a/test/rdoc/test_rdoc_markup_to_markdown.rb b/test/rdoc/test_rdoc_markup_to_markdown.rb index f5ea8d05da..9c5b6d3e57 100644 --- a/test/rdoc/test_rdoc_markup_to_markdown.rb +++ b/test/rdoc/test_rdoc_markup_to_markdown.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocMarkupToMarkdown < RDoc::Markup::TextFormatterTestCase diff --git a/test/rdoc/test_rdoc_markup_to_rdoc.rb b/test/rdoc/test_rdoc_markup_to_rdoc.rb index 31761eb44d..e81bc2f1ad 100644 --- a/test/rdoc/test_rdoc_markup_to_rdoc.rb +++ b/test/rdoc/test_rdoc_markup_to_rdoc.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocMarkupToRDoc < RDoc::Markup::TextFormatterTestCase diff --git a/test/rdoc/test_rdoc_markup_to_table_of_contents.rb b/test/rdoc/test_rdoc_markup_to_table_of_contents.rb index f21dbfe748..bfeb2d6f58 100644 --- a/test/rdoc/test_rdoc_markup_to_table_of_contents.rb +++ b/test/rdoc/test_rdoc_markup_to_table_of_contents.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocMarkupToTableOfContents < RDoc::Markup::FormatterTestCase diff --git a/test/rdoc/test_rdoc_markup_to_tt_only.rb b/test/rdoc/test_rdoc_markup_to_tt_only.rb index b08362cd0b..856eb592c5 100644 --- a/test/rdoc/test_rdoc_markup_to_tt_only.rb +++ b/test/rdoc/test_rdoc_markup_to_tt_only.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocMarkupToTtOnly < RDoc::Markup::FormatterTestCase diff --git a/test/rdoc/test_rdoc_markup_verbatim.rb b/test/rdoc/test_rdoc_markup_verbatim.rb index 3b05100a33..88ca4906bb 100644 --- a/test/rdoc/test_rdoc_markup_verbatim.rb +++ b/test/rdoc/test_rdoc_markup_verbatim.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocMarkupVerbatim < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_options.rb b/test/rdoc/test_rdoc_options.rb index 400ed9a549..394d155241 100644 --- a/test/rdoc/test_rdoc_options.rb +++ b/test/rdoc/test_rdoc_options.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocOptions < RDoc::TestCase @@ -18,7 +18,6 @@ class TestRDocOptions < RDoc::TestCase def test_check_files skip "assumes UNIX permission model" if /mswin|mingw/ =~ RUBY_PLATFORM - skip "skipped in root privilege" if Process.uid == 0 out, err = capture_io do temp_dir do diff --git a/test/rdoc/test_rdoc_parser.rb b/test/rdoc/test_rdoc_parser.rb index 5d4da7e425..2638adcd15 100644 --- a/test/rdoc/test_rdoc_parser.rb +++ b/test/rdoc/test_rdoc_parser.rb @@ -1,7 +1,7 @@ # -*- coding: us-ascii -*- # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocParser < RDoc::TestCase @@ -19,7 +19,7 @@ class TestRDocParser < RDoc::TestCase def test_class_binary_eh_ISO_2022_JP iso_2022_jp = File.join Dir.tmpdir, "test_rdoc_parser_#{$$}.rd" - open iso_2022_jp, 'wb' do |io| + File.open iso_2022_jp, 'wb' do |io| io.write "# coding: ISO-2022-JP\n" io.write ":\e$B%3%^%s%I\e(B:\n" end @@ -31,7 +31,7 @@ class TestRDocParser < RDoc::TestCase def test_class_binary_eh_marshal marshal = File.join Dir.tmpdir, "test_rdoc_parser_#{$$}.marshal" - open marshal, 'wb' do |io| + File.open marshal, 'wb' do |io| io.write Marshal.dump('') io.write 'lots of text ' * 500 end @@ -92,7 +92,7 @@ class TestRDocParser < RDoc::TestCase def test_class_for_executable temp_dir do content = "#!/usr/bin/env ruby -w\n" - open 'app', 'w' do |io| io.write content end + File.open 'app', 'w' do |io| io.write content end app = @store.add_file 'app' parser = @RP.for app, 'app', content, @options, :stats @@ -126,7 +126,7 @@ class TestRDocParser < RDoc::TestCase temp_dir do content = "# -*- rdoc -*-\n= NEWS\n" - open 'NEWS', 'w' do |io| io.write content end + File.open 'NEWS', 'w' do |io| io.write content end app = @store.add_file 'NEWS' parser = @RP.for app, 'NEWS', content, @options, :stats @@ -140,7 +140,7 @@ class TestRDocParser < RDoc::TestCase def test_can_parse_modeline readme_ext = File.join Dir.tmpdir, "README.EXT.#{$$}" - open readme_ext, 'w' do |io| + File.open readme_ext, 'w' do |io| io.puts "# README.EXT - -*- rdoc -*- created at: Mon Aug 7 16:45:54 JST 1995" io.puts io.puts "This document explains how to make extension libraries for Ruby." @@ -162,7 +162,7 @@ class TestRDocParser < RDoc::TestCase def test_check_modeline readme_ext = File.join Dir.tmpdir, "README.EXT.#{$$}" - open readme_ext, 'w' do |io| + File.open readme_ext, 'w' do |io| io.puts "# README.EXT - -*- RDoc -*- created at: Mon Aug 7 16:45:54 JST 1995" io.puts io.puts "This document explains how to make extension libraries for Ruby." @@ -176,7 +176,7 @@ class TestRDocParser < RDoc::TestCase def test_check_modeline_coding readme_ext = File.join Dir.tmpdir, "README.EXT.#{$$}" - open readme_ext, 'w' do |io| + File.open readme_ext, 'w' do |io| io.puts "# -*- coding: utf-8 -*-" end @@ -188,7 +188,7 @@ class TestRDocParser < RDoc::TestCase def test_check_modeline_with_other readme_ext = File.join Dir.tmpdir, "README.EXT.#{$$}" - open readme_ext, 'w' do |io| + File.open readme_ext, 'w' do |io| io.puts "# README.EXT - -*- mode: RDoc; indent-tabs-mode: nil -*-" io.puts io.puts "This document explains how to make extension libraries for Ruby." @@ -202,7 +202,7 @@ class TestRDocParser < RDoc::TestCase def test_check_modeline_no_modeline readme_ext = File.join Dir.tmpdir, "README.EXT.#{$$}" - open readme_ext, 'w' do |io| + File.open readme_ext, 'w' do |io| io.puts "This document explains how to make extension libraries for Ruby." end diff --git a/test/rdoc/test_rdoc_parser_c.rb b/test/rdoc/test_rdoc_parser_c.rb index 2cc8ddf79a..b8bdbca7fd 100644 --- a/test/rdoc/test_rdoc_parser_c.rb +++ b/test/rdoc/test_rdoc_parser_c.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' =begin TODO: test call-seq parsing @@ -327,7 +327,7 @@ VALUE cFoo = boot_defclass("Foo", 0); klass = util_get_class content, 'cFoo' assert_equal "this is the Foo boot class", klass.comment.text - assert_equal nil, klass.superclass + assert_nil klass.superclass end def test_do_aliases_missing_class @@ -1377,7 +1377,7 @@ commercial() -> Date
parser.find_modifiers comment, method_obj - assert_equal nil, method_obj.document_self + assert_nil method_obj.document_self end def test_find_modifiers_yields diff --git a/test/rdoc/test_rdoc_parser_changelog.rb b/test/rdoc/test_rdoc_parser_changelog.rb index 06c3ff206e..18ea81b34e 100644 --- a/test/rdoc/test_rdoc_parser_changelog.rb +++ b/test/rdoc/test_rdoc_parser_changelog.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocParserChangeLog < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_parser_markdown.rb b/test/rdoc/test_rdoc_parser_markdown.rb index 50893ecf99..30e66e2833 100644 --- a/test/rdoc/test_rdoc_parser_markdown.rb +++ b/test/rdoc/test_rdoc_parser_markdown.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocParserMarkdown < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_parser_rd.rb b/test/rdoc/test_rdoc_parser_rd.rb index e8f4250284..15112fdb0e 100644 --- a/test/rdoc/test_rdoc_parser_rd.rb +++ b/test/rdoc/test_rdoc_parser_rd.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocParserRd < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_parser_ruby.rb b/test/rdoc/test_rdoc_parser_ruby.rb index e28112fbee..ce2aaae981 100644 --- a/test/rdoc/test_rdoc_parser_ruby.rb +++ b/test/rdoc/test_rdoc_parser_ruby.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocParserRuby < RDoc::TestCase @@ -231,8 +231,8 @@ class C; end @parser.look_for_directives_in @top_level, comment section = @top_level.current_section - assert_equal nil, section.title - assert_equal nil, section.comment + assert_nil section.title + assert_nil section.comment assert_equal "# how to make a section:\n# # :section: new section\n", comment.text @@ -306,6 +306,67 @@ ruby assert_equal @top_level, sum.file end + def test_parse_on_ignored_nl_with_nil_text + util_parser <def meth + variable # comment + .chain +end +EXPECTED + expected = expected.rstrip + + @parser.scan + + foo = @store.find_class_named 'Foo' + meth = foo.method_list.first + + assert_equal 'meth', meth.name + assert_equal @top_level, meth.file + + markup_code = meth.markup_code.sub(/^.*\n/, '') + assert_equal expected, markup_code + end + + def test_parse_redefined_op_with_constant + klass = RDoc::NormalClass.new 'Foo' + klass.parent = @top_level + + comment = RDoc::Comment.new '', @top_level + + util_parser < [@store1], 'Foo::Baz' => [@store1, @store2], 'Inc' => [@store1], + 'Qux' => [@store1], } classes = @driver.classes @@ -923,6 +966,7 @@ Foo::Bar#bother [@store1, 'Foo::Bar', 'Foo::Bar', :both, 'blah'], [@store1, 'Foo::Baz', 'Foo::Baz', :both, 'blah'], [@store1, 'Inc', 'Inc', :both, 'blah'], + [@store1, 'Qux', 'Qux', :both, 'blah'], ] assert_equal expected, items @@ -1056,7 +1100,7 @@ Foo::Bar#bother @driver.list_known_classes end - assert_equal "Ambiguous\nExt\nFoo\nFoo::Bar\nFoo::Baz\nInc\n", out + assert_equal "Ambiguous\nExt\nFoo\nFoo::Bar\nFoo::Baz\nInc\nQux\n", out end def test_list_known_classes_name @@ -1127,7 +1171,7 @@ Foo::Bar#bother method = @driver.load_method(@store2, :instance_methods, 'Bar', '#', 'inherit') - assert_equal nil, method + assert_nil method end def test_load_methods_matching @@ -1232,7 +1276,7 @@ Foo::Bar#bother assert_equal 'ruby', klass, 'ruby project' assert_equal ':', type, 'ruby type' - assert_equal nil, meth, 'ruby page' + assert_nil meth, 'ruby page' end def test_parse_name_page_extenson @@ -1247,26 +1291,26 @@ Foo::Bar#bother klass, type, meth = @driver.parse_name 'Foo' assert_equal 'Foo', klass, 'Foo class' - assert_equal nil, type, 'Foo type' - assert_equal nil, meth, 'Foo method' + assert_nil type, 'Foo type' + assert_nil meth, 'Foo method' klass, type, meth = @driver.parse_name 'Foo#' assert_equal 'Foo', klass, 'Foo# class' assert_equal '#', type, 'Foo# type' - assert_equal nil, meth, 'Foo# method' + assert_nil meth, 'Foo# method' klass, type, meth = @driver.parse_name 'Foo::' assert_equal 'Foo', klass, 'Foo:: class' assert_equal '::', type, 'Foo:: type' - assert_equal nil, meth, 'Foo:: method' + assert_nil meth, 'Foo:: method' klass, type, meth = @driver.parse_name 'Foo.' assert_equal 'Foo', klass, 'Foo. class' assert_equal '.', type, 'Foo. type' - assert_equal nil, meth, 'Foo. method' + assert_nil meth, 'Foo. method' klass, type, meth = @driver.parse_name 'Foo#Bar' @@ -1291,14 +1335,14 @@ Foo::Bar#bother klass, type, meth = @driver.parse_name 'Foo::Bar' assert_equal 'Foo::Bar', klass, 'Foo::Bar class' - assert_equal nil, type, 'Foo::Bar type' - assert_equal nil, meth, 'Foo::Bar method' + assert_nil type, 'Foo::Bar type' + assert_nil meth, 'Foo::Bar method' klass, type, meth = @driver.parse_name 'Foo::Bar#' assert_equal 'Foo::Bar', klass, 'Foo::Bar# class' assert_equal '#', type, 'Foo::Bar# type' - assert_equal nil, meth, 'Foo::Bar# method' + assert_nil meth, 'Foo::Bar# method' klass, type, meth = @driver.parse_name 'Foo::Bar#baz' @@ -1481,6 +1525,15 @@ Foo::Bar#bother @overridden.comment = 'must not be displayed in Bar#override' @overridden.record_location @top_level + @cQux = @top_level.add_class RDoc::NormalClass, 'Qux' + + @original = @cQux.add_method RDoc::AnyMethod.new(nil, 'original') + @original.comment = 'original comment' + @original.record_location @top_level + + @aliased = @original.add_alias RDoc::Alias.new(nil, 'original', 'aliased', 'alias comment'), @cQux + @aliased.record_location @top_level + @store1.save @driver.stores = [@store1] diff --git a/test/rdoc/test_rdoc_ri_paths.rb b/test/rdoc/test_rdoc_ri_paths.rb index b0f368353a..eb9b7fc93c 100644 --- a/test/rdoc/test_rdoc_ri_paths.rb +++ b/test/rdoc/test_rdoc_ri_paths.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocRIPaths < RDoc::TestCase @@ -22,7 +22,7 @@ class TestRDocRIPaths < RDoc::TestCase specs.each do |spec| spec.loaded_from = spec.spec_file - open spec.spec_file, 'w' do |file| + File.open spec.spec_file, 'w' do |file| file.write spec.to_ruby_for_cache end diff --git a/test/rdoc/test_rdoc_rubygems_hook.rb b/test/rdoc/test_rdoc_rubygems_hook.rb index 2664b35cbb..2fb79ff577 100644 --- a/test/rdoc/test_rdoc_rubygems_hook.rb +++ b/test/rdoc/test_rdoc_rubygems_hook.rb @@ -200,7 +200,6 @@ class TestRDocRubygemsHook < Gem::TestCase def test_remove_unwritable skip 'chmod not supported' if Gem.win_platform? - skip 'skipped in root privilege' if Process.uid == 0 FileUtils.mkdir_p @a.base_dir FileUtils.chmod 0, @a.base_dir @@ -229,7 +228,6 @@ class TestRDocRubygemsHook < Gem::TestCase def test_setup_unwritable skip 'chmod not supported' if Gem.win_platform? - skip 'skipped in root privilege' if Process.uid == 0 FileUtils.mkdir_p @a.doc_dir FileUtils.chmod 0, @a.doc_dir diff --git a/test/rdoc/test_rdoc_servlet.rb b/test/rdoc/test_rdoc_servlet.rb index 4dd1f08ddd..c0c0869293 100644 --- a/test/rdoc/test_rdoc_servlet.rb +++ b/test/rdoc/test_rdoc_servlet.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocServlet < RDoc::TestCase @@ -69,7 +69,7 @@ class TestRDocServlet < RDoc::TestCase FileUtils.mkdir 'css' now = Time.now - open 'css/rdoc.css', 'w' do |io| io.write 'h1 { color: red }' end + File.open 'css/rdoc.css', 'w' do |io| io.write 'h1 { color: red }' end File.utime now, now, 'css/rdoc.css' @s.asset_dirs[:darkfish] = '.' @@ -143,7 +143,7 @@ class TestRDocServlet < RDoc::TestCase @s.asset_dirs[:darkfish] = '.' - @req.path = '/mount/path/css/rdoc.css' + @req.path = '/mount/path/css/rdoc.css'.dup @s.do_GET @req, @res diff --git a/test/rdoc/test_rdoc_single_class.rb b/test/rdoc/test_rdoc_single_class.rb index 5761bfef4d..e4123cb9bc 100644 --- a/test/rdoc/test_rdoc_single_class.rb +++ b/test/rdoc/test_rdoc_single_class.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocSingleClass < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_stats.rb b/test/rdoc/test_rdoc_stats.rb index 19fc2365b3..cac30d15aa 100644 --- a/test/rdoc/test_rdoc_stats.rb +++ b/test/rdoc/test_rdoc_stats.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocStats < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_store.rb b/test/rdoc/test_rdoc_store.rb index 4a4cf3ac0f..4246b4cbbf 100644 --- a/test/rdoc/test_rdoc_store.rb +++ b/test/rdoc/test_rdoc_store.rb @@ -162,7 +162,7 @@ class TestRDocStore < XrefTestCase def test_all_classes_and_modules expected = %w[ - C1 C2 C2::C3 C2::C3::H1 C3 C3::H1 C3::H2 C4 C4::C4 C5 C5::C1 C6 C7 + C1 C2 C2::C3 C2::C3::H1 C3 C3::H1 C3::H2 C4 C4::C4 C5 C5::C1 C6 C7 C8 C8::S1 Child M1 M1::M2 Parent @@ -213,7 +213,7 @@ class TestRDocStore < XrefTestCase def test_classes expected = %w[ - C1 C2 C2::C3 C2::C3::H1 C3 C3::H1 C3::H2 C4 C4::C4 C5 C5::C1 C6 C7 + C1 C2 C2::C3 C2::C3::H1 C3 C3::H1 C3::H2 C4 C4::C4 C5 C5::C1 C6 C7 C8 C8::S1 Child Parent ] @@ -222,7 +222,8 @@ class TestRDocStore < XrefTestCase end def test_complete - @c2.add_module_alias @c2_c3, 'A1', @top_level + a1 = RDoc::Constant.new 'A1', '', '' + @c2.add_module_alias @c2_c3, @c2_c3.name, a1, @top_level @store.complete :public @@ -407,7 +408,7 @@ class TestRDocStore < XrefTestCase Dir.mkdir @tmpdir - open File.join(@tmpdir, 'cache.ri'), 'wb' do |io| + File.open File.join(@tmpdir, 'cache.ri'), 'wb' do |io| Marshal.dump cache, io end @@ -441,7 +442,7 @@ class TestRDocStore < XrefTestCase Dir.mkdir @tmpdir - open File.join(@tmpdir, 'cache.ri'), 'wb' do |io| + File.open File.join(@tmpdir, 'cache.ri'), 'wb' do |io| Marshal.dump cache, io end @@ -490,7 +491,7 @@ class TestRDocStore < XrefTestCase Dir.mkdir @tmpdir - open File.join(@tmpdir, 'cache.ri'), 'wb' do |io| + File.open File.join(@tmpdir, 'cache.ri'), 'wb' do |io| Marshal.dump cache, io end @@ -524,6 +525,15 @@ class TestRDocStore < XrefTestCase assert_includes @s.classes_hash, 'Object' end + def test_load_single_class + @s.save_class @c8_s1 + @s.classes_hash.clear + + assert_equal @c8_s1, @s.load_class('C8::S1') + + assert_includes @s.classes_hash, 'C8::S1' + end + def test_load_method @s.save_method @klass, @meth_bang @@ -538,7 +548,7 @@ class TestRDocStore < XrefTestCase file = @s.method_file @klass.full_name, @meth.full_name - open file, 'wb' do |io| + File.open file, 'wb' do |io| io.write "\x04\bU:\x14RDoc::AnyMethod[\x0Fi\x00I" + "\"\vmethod\x06:\x06EF\"\x11Klass#method0:\vpublic" + "o:\eRDoc::Markup::Document\x06:\v@parts[\x06" + @@ -563,7 +573,7 @@ class TestRDocStore < XrefTestCase end def test_main - assert_equal nil, @s.main + assert_nil @s.main @s.main = 'README.txt' @@ -633,7 +643,7 @@ class TestRDocStore < XrefTestCase expected[:ancestors]['Object'] = %w[BasicObject] - open File.join(@tmpdir, 'cache.ri'), 'rb' do |io| + File.open File.join(@tmpdir, 'cache.ri'), 'rb' do |io| cache = Marshal.load io.read assert_equal expected, cache @@ -701,7 +711,7 @@ class TestRDocStore < XrefTestCase expected[:ancestors]['Object'] = %w[BasicObject] - open File.join(@tmpdir, 'cache.ri'), 'rb' do |io| + File.open File.join(@tmpdir, 'cache.ri'), 'rb' do |io| cache = Marshal.load io.read assert_equal expected, cache @@ -981,7 +991,7 @@ class TestRDocStore < XrefTestCase end def test_title - assert_equal nil, @s.title + assert_nil @s.title @s.title = 'rdoc' diff --git a/test/rdoc/test_rdoc_task.rb b/test/rdoc/test_rdoc_task.rb index ac3512f42a..3ce8529aef 100644 --- a/test/rdoc/test_rdoc_task.rb +++ b/test/rdoc/test_rdoc_task.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' begin require 'rake' rescue LoadError diff --git a/test/rdoc/test_rdoc_text.rb b/test/rdoc/test_rdoc_text.rb index 9f0e9480d3..61f528a5a4 100644 --- a/test/rdoc/test_rdoc_text.rb +++ b/test/rdoc/test_rdoc_text.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' +require 'timeout' class TestRDocText < RDoc::TestCase @@ -377,6 +378,32 @@ paragraph will be cut off … assert_equal expected, strip_stars(text) end + def test_strip_stars_document_method_special + text = <<-TEXT +/* + * Document-method: Zlib::GzipFile#mtime= + * Document-method: [] + * Document-method: ` + * Document-method: | + * Document-method: & + * Document-method: <=> + * Document-method: =~ + * Document-method: + + * Document-method: - + * Document-method: +@ + * + * A comment + */ + TEXT + + expected = <<-EXPECTED + + A comment + EXPECTED + + assert_equal expected, strip_stars(text) + end + def test_strip_stars_encoding text = <<-TEXT /* diff --git a/test/rdoc/test_rdoc_token_stream.rb b/test/rdoc/test_rdoc_token_stream.rb index abf1469bbc..c946d0f1ef 100644 --- a/test/rdoc/test_rdoc_token_stream.rb +++ b/test/rdoc/test_rdoc_token_stream.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocTokenStream < RDoc::TestCase @@ -39,5 +39,20 @@ class TestRDocTokenStream < RDoc::TestCase assert_equal '', RDoc::TokenStream.to_html([]) end + def test_tokens_to_s + foo = Class.new do + include RDoc::TokenStream + + def initialize + @token_stream = [ + { line_no: 0, char_no: 0, kind: :on_ident, text: "foo" }, + { line_no: 0, char_no: 0, kind: :on_sp, text: " " }, + { line_no: 0, char_no: 0, kind: :on_tstring, text: "'bar'" }, + ] + end + end.new + + assert_equal "foo 'bar'", foo.tokens_to_s + end end diff --git a/test/rdoc/test_rdoc_tom_doc.rb b/test/rdoc/test_rdoc_tom_doc.rb index 15bbd9b32d..6a6822d50d 100644 --- a/test/rdoc/test_rdoc_tom_doc.rb +++ b/test/rdoc/test_rdoc_tom_doc.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rdoc/test_case' +require 'minitest_helper' class TestRDocTomDoc < RDoc::TestCase diff --git a/test/rdoc/test_rdoc_top_level.rb b/test/rdoc/test_rdoc_top_level.rb index 00fc7a1bd5..e396791ab8 100644 --- a/test/rdoc/test_rdoc_top_level.rb +++ b/test/rdoc/test_rdoc_top_level.rb @@ -160,7 +160,7 @@ class TestRDocTopLevel < XrefTestCase end def test_last_modified - assert_equal nil, @top_level.last_modified + assert_nil @top_level.last_modified stat = Object.new def stat.mtime() 0 end @top_level.file_stat = stat diff --git a/test/rdoc/xref_data.rb b/test/rdoc/xref_data.rb index bc20d8ed91..d002b422f9 100644 --- a/test/rdoc/xref_data.rb +++ b/test/rdoc/xref_data.rb @@ -94,6 +94,13 @@ class C7 CONST_NODOC = :const_nodoc # :nodoc: end +class C8 + class << self + class S1 + end + end +end + module M1 def m end diff --git a/test/rdoc/xref_test_case.rb b/test/rdoc/xref_test_case.rb index 9f709964c6..70b7df4222 100644 --- a/test/rdoc/xref_test_case.rb +++ b/test/rdoc/xref_test_case.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true ENV['RDOC_TEST'] = 'yes' -require 'rdoc' +require 'minitest_helper' require File.expand_path '../xref_data', __FILE__ class XrefTestCase < RDoc::TestCase @@ -53,6 +53,8 @@ class XrefTestCase < RDoc::TestCase @c3_h2 = @xref_data.find_module_named 'C3::H2' @c6 = @xref_data.find_module_named 'C6' @c7 = @xref_data.find_module_named 'C7' + @c8 = @xref_data.find_module_named 'C8' + @c8_s1 = @xref_data.find_module_named 'C8::S1' @m1 = @xref_data.find_module_named 'M1' @m1_m = @m1.method_list.first