From 98c7058bf7b3eab91c62a77cb10b09f6c8ed368e Mon Sep 17 00:00:00 2001 From: hsbt Date: Mon, 26 Mar 2018 05:56:26 +0000 Subject: Merge RDoc 6.0.3 from upstream. It fixed the several bugs that was found after RDoc 6 releasing. From: SHIBATA Hiroshi git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62924 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rdoc/context.rb | 51 ++++++--- lib/rdoc/encoding.rb | 48 +++++---- lib/rdoc/erbio.rb | 2 +- lib/rdoc/generator/json_index.rb | 5 +- lib/rdoc/generator/pot.rb | 6 +- lib/rdoc/i18n.rb | 2 +- lib/rdoc/markdown.rb | 1 + lib/rdoc/markdown/literals.rb | 1 + lib/rdoc/markup/pre_process.rb | 1 + lib/rdoc/options.rb | 2 +- lib/rdoc/parser.rb | 2 +- lib/rdoc/parser/ripper_state_lex.rb | 20 +++- lib/rdoc/parser/ruby.rb | 35 +++++-- lib/rdoc/rd/block_parser.rb | 125 +++++++++++----------- lib/rdoc/rd/inline_parser.rb | 99 +++++++++--------- lib/rdoc/rdoc.gemspec | 16 +-- lib/rdoc/rdoc.rb | 19 ++-- lib/rdoc/ri/driver.rb | 35 +++++-- lib/rdoc/servlet.rb | 7 +- lib/rdoc/store.rb | 25 +++-- lib/rdoc/test_case.rb | 203 ------------------------------------ lib/rdoc/text.rb | 2 +- lib/rdoc/token_stream.rb | 2 +- 23 files changed, 300 insertions(+), 409 deletions(-) delete mode 100644 lib/rdoc/test_case.rb (limited to 'lib/rdoc') 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 + + unless from + @store.unmatched_constant_alias[child_name(from_name)] = [to, file] + return to + end - to = from.dup - to.name = name - to.full_name = nil + new_to = from.dup + new_to.name = to.name + new_to.full_name = nil - if to.module? then - @store.modules_hash[to_name] = to - @modules[name] = to + 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 - - def self.set_encoding string - string = remove_frozen_string_literal string - - string =~ /\A(?:#!.*\n)?(.*\n)/ - - first_line = $1 + # Detects the encoding of +string+ based on the magic comment - name = case first_line - when /^<\?xml[^?]*encoding=(["'])(.*?)\1/ then $2 - when /\b(?:en)?coding[=:]\s*([^\s;]+)/i then $1 - else return string - end + def self.detect_encoding string + result = HEADER_REGEXP.match string + name = result && result[:name] - string = string.sub first_line, '' - - string = remove_frozen_string_literal string + name ? Encoding.find(name) : nil + end - enc = Encoding.find name - string = RDoc::Encoding.change_encoding string, enc if enc + ## + # Removes magic comments and shebang - 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/test_case.rb b/lib/rdoc/test_case.rb deleted file mode 100644 index 5f38870324..0000000000 --- a/lib/rdoc/test_case.rb +++ /dev/null @@ -1,203 +0,0 @@ -# frozen_string_literal: true -begin - gem 'minitest', '~> 4.0' unless defined?(Test::Unit) -rescue NoMethodError, Gem::LoadError - # for ruby tests -end - -require 'minitest/autorun' -require 'minitest/benchmark' unless ENV['NOBENCHMARK'] - -require 'fileutils' -require 'pp' -require 'tempfile' -require 'tmpdir' -require 'stringio' - -require 'rdoc' - -## -# RDoc::TestCase is an abstract TestCase to provide common setup and teardown -# across all RDoc tests. The test case uses minitest, so all the assertions -# of minitest may be used. -# -# The testcase provides the following: -# -# * A reset code-object tree -# * A reset markup preprocessor (RDoc::Markup::PreProcess) -# * The @RM alias of RDoc::Markup (for less typing) -# * @pwd containing the current working directory -# * FileUtils, pp, Tempfile, Dir.tmpdir and StringIO - -class RDoc::TestCase < MiniTest::Unit::TestCase - - ## - # Abstract test-case setup - - def setup - super - - @top_level = nil - - @RM = RDoc::Markup - - @pwd = Dir.pwd - - @store = RDoc::Store.new - - @rdoc = RDoc::RDoc.new - @rdoc.store = @store - @rdoc.options = RDoc::Options.new - - g = Object.new - def g.class_dir() end - def g.file_dir() end - @rdoc.generator = g - - RDoc::Markup::PreProcess.reset - end - - ## - # Asserts +path+ is a file - - def assert_file path - assert File.file?(path), "#{path} is not a file" - end - - ## - # Asserts +path+ is a directory - - def assert_directory path - assert File.directory?(path), "#{path} is not a directory" - end - - ## - # Refutes +path+ exists - - def refute_file path - refute File.exist?(path), "#{path} exists" - end - - ## - # Shortcut for RDoc::Markup::BlankLine.new - - def blank_line - @RM::BlankLine.new - end - - ## - # Shortcut for RDoc::Markup::BlockQuote.new with +contents+ - - def block *contents - @RM::BlockQuote.new(*contents) - end - - ## - # Creates an RDoc::Comment with +text+ which was defined on +top_level+. - # By default the comment has the 'rdoc' format. - - def comment text, top_level = @top_level - RDoc::Comment.new text, top_level - end - - ## - # Shortcut for RDoc::Markup::Document.new with +contents+ - - def doc *contents - @RM::Document.new(*contents) - end - - ## - # Shortcut for RDoc::Markup::HardBreak.new - - def hard_break - @RM::HardBreak.new - end - - ## - # Shortcut for RDoc::Markup::Heading.new with +level+ and +text+ - - def head level, text - @RM::Heading.new level, text - end - - ## - # Shortcut for RDoc::Markup::ListItem.new with +label+ and +parts+ - - def item label = nil, *parts - @RM::ListItem.new label, *parts - end - - ## - # Shortcut for RDoc::Markup::List.new with +type+ and +items+ - - def list type = nil, *items - @RM::List.new type, *items - end - - ## - # Enables pretty-print output - - def mu_pp obj # :nodoc: - s = obj.pretty_inspect - s = RDoc::Encoding.change_encoding s, Encoding.default_external - s.chomp - end - - ## - # Shortcut for RDoc::Markup::Paragraph.new with +contents+ - - def para *a - @RM::Paragraph.new(*a) - end - - ## - # Shortcut for RDoc::Markup::Rule.new with +weight+ - - def rule weight - @RM::Rule.new weight - end - - ## - # Shortcut for RDoc::Markup::Raw.new with +contents+ - - def raw *contents - @RM::Raw.new(*contents) - end - - ## - # Creates a temporary directory changes the current directory to it for the - # duration of the block. - # - # Depends upon Dir.mktmpdir - - def temp_dir - Dir.mktmpdir do |temp_dir| - Dir.chdir temp_dir do - yield temp_dir - end - end - end - - ## - # Shortcut for RDoc::Markup::Verbatim.new with +parts+ - - def verb *parts - @RM::Verbatim.new(*parts) - end - - ## - # run capture_io with setting $VERBOSE = true - - def verbose_capture_io - capture_io do - begin - orig_verbose = $VERBOSE - $VERBOSE = true - yield - ensure - $VERBOSE = orig_verbose - end - end - 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 -- cgit v1.2.3