[前][次][番号順一覧][スレッド一覧]

ruby-changes:48804

From: hsbt <ko1@a...>
Date: Mon, 27 Nov 2017 19:45:41 +0900 (JST)
Subject: [ruby-changes:48804] hsbt:r60920 (trunk): Merge rdoc-6.0.0.beta4 from upstream.

hsbt	2017-11-27 19:45:24 +0900 (Mon, 27 Nov 2017)

  New Revision: 60920

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60920

  Log:
    Merge rdoc-6.0.0.beta4 from upstream.
    
      It version applied `frozen_string_literal: true`

  Modified files:
    trunk/lib/rdoc/alias.rb
    trunk/lib/rdoc/anon_class.rb
    trunk/lib/rdoc/any_method.rb
    trunk/lib/rdoc/attr.rb
    trunk/lib/rdoc/class_module.rb
    trunk/lib/rdoc/code_object.rb
    trunk/lib/rdoc/code_objects.rb
    trunk/lib/rdoc/comment.rb
    trunk/lib/rdoc/constant.rb
    trunk/lib/rdoc/context/section.rb
    trunk/lib/rdoc/context.rb
    trunk/lib/rdoc/cross_reference.rb
    trunk/lib/rdoc/encoding.rb
    trunk/lib/rdoc/erb_partial.rb
    trunk/lib/rdoc/erbio.rb
    trunk/lib/rdoc/extend.rb
    trunk/lib/rdoc/generator/darkfish.rb
    trunk/lib/rdoc/generator/json_index.rb
    trunk/lib/rdoc/generator/markup.rb
    trunk/lib/rdoc/generator/pot/message_extractor.rb
    trunk/lib/rdoc/generator/pot/po.rb
    trunk/lib/rdoc/generator/pot/po_entry.rb
    trunk/lib/rdoc/generator/pot.rb
    trunk/lib/rdoc/generator/ri.rb
    trunk/lib/rdoc/generator.rb
    trunk/lib/rdoc/ghost_method.rb
    trunk/lib/rdoc/i18n/locale.rb
    trunk/lib/rdoc/i18n/text.rb
    trunk/lib/rdoc/i18n.rb
    trunk/lib/rdoc/include.rb
    trunk/lib/rdoc/known_classes.rb
    trunk/lib/rdoc/markdown/entities.rb
    trunk/lib/rdoc/markdown/literals.rb
    trunk/lib/rdoc/markdown.rb
    trunk/lib/rdoc/markup/attr_changer.rb
    trunk/lib/rdoc/markup/attr_span.rb
    trunk/lib/rdoc/markup/attribute_manager.rb
    trunk/lib/rdoc/markup/attributes.rb
    trunk/lib/rdoc/markup/blank_line.rb
    trunk/lib/rdoc/markup/block_quote.rb
    trunk/lib/rdoc/markup/document.rb
    trunk/lib/rdoc/markup/formatter.rb
    trunk/lib/rdoc/markup/formatter_test_case.rb
    trunk/lib/rdoc/markup/hard_break.rb
    trunk/lib/rdoc/markup/heading.rb
    trunk/lib/rdoc/markup/include.rb
    trunk/lib/rdoc/markup/indented_paragraph.rb
    trunk/lib/rdoc/markup/inline.rb
    trunk/lib/rdoc/markup/list.rb
    trunk/lib/rdoc/markup/list_item.rb
    trunk/lib/rdoc/markup/paragraph.rb
    trunk/lib/rdoc/markup/parser.rb
    trunk/lib/rdoc/markup/pre_process.rb
    trunk/lib/rdoc/markup/raw.rb
    trunk/lib/rdoc/markup/rule.rb
    trunk/lib/rdoc/markup/special.rb
    trunk/lib/rdoc/markup/text_formatter_test_case.rb
    trunk/lib/rdoc/markup/to_ansi.rb
    trunk/lib/rdoc/markup/to_bs.rb
    trunk/lib/rdoc/markup/to_html.rb
    trunk/lib/rdoc/markup/to_html_crossref.rb
    trunk/lib/rdoc/markup/to_html_snippet.rb
    trunk/lib/rdoc/markup/to_joined_paragraph.rb
    trunk/lib/rdoc/markup/to_label.rb
    trunk/lib/rdoc/markup/to_markdown.rb
    trunk/lib/rdoc/markup/to_rdoc.rb
    trunk/lib/rdoc/markup/to_table_of_contents.rb
    trunk/lib/rdoc/markup/to_test.rb
    trunk/lib/rdoc/markup/to_tt_only.rb
    trunk/lib/rdoc/markup/verbatim.rb
    trunk/lib/rdoc/markup.rb
    trunk/lib/rdoc/meta_method.rb
    trunk/lib/rdoc/method_attr.rb
    trunk/lib/rdoc/mixin.rb
    trunk/lib/rdoc/normal_class.rb
    trunk/lib/rdoc/normal_module.rb
    trunk/lib/rdoc/options.rb
    trunk/lib/rdoc/parser/c.rb
    trunk/lib/rdoc/parser/changelog.rb
    trunk/lib/rdoc/parser/markdown.rb
    trunk/lib/rdoc/parser/rd.rb
    trunk/lib/rdoc/parser/ripper_state_lex.rb
    trunk/lib/rdoc/parser/ruby.rb
    trunk/lib/rdoc/parser/ruby_tools.rb
    trunk/lib/rdoc/parser/simple.rb
    trunk/lib/rdoc/parser/text.rb
    trunk/lib/rdoc/parser.rb
    trunk/lib/rdoc/rd/block_parser.rb
    trunk/lib/rdoc/rd/inline.rb
    trunk/lib/rdoc/rd/inline_parser.rb
    trunk/lib/rdoc/rd.rb
    trunk/lib/rdoc/rdoc.gemspec
    trunk/lib/rdoc/rdoc.rb
    trunk/lib/rdoc/require.rb
    trunk/lib/rdoc/ri/driver.rb
    trunk/lib/rdoc/ri/formatter.rb
    trunk/lib/rdoc/ri/paths.rb
    trunk/lib/rdoc/ri/store.rb
    trunk/lib/rdoc/ri/task.rb
    trunk/lib/rdoc/ri.rb
    trunk/lib/rdoc/rubygems_hook.rb
    trunk/lib/rdoc/servlet.rb
    trunk/lib/rdoc/single_class.rb
    trunk/lib/rdoc/stats/normal.rb
    trunk/lib/rdoc/stats/quiet.rb
    trunk/lib/rdoc/stats/verbose.rb
    trunk/lib/rdoc/stats.rb
    trunk/lib/rdoc/store.rb
    trunk/lib/rdoc/task.rb
    trunk/lib/rdoc/test_case.rb
    trunk/lib/rdoc/text.rb
    trunk/lib/rdoc/token_stream.rb
    trunk/lib/rdoc/tom_doc.rb
    trunk/lib/rdoc/top_level.rb
    trunk/lib/rdoc.rb
    trunk/test/rdoc/test_rdoc_alias.rb
    trunk/test/rdoc/test_rdoc_any_method.rb
    trunk/test/rdoc/test_rdoc_attr.rb
    trunk/test/rdoc/test_rdoc_class_module.rb
    trunk/test/rdoc/test_rdoc_code_object.rb
    trunk/test/rdoc/test_rdoc_comment.rb
    trunk/test/rdoc/test_rdoc_constant.rb
    trunk/test/rdoc/test_rdoc_context.rb
    trunk/test/rdoc/test_rdoc_context_section.rb
    trunk/test/rdoc/test_rdoc_cross_reference.rb
    trunk/test/rdoc/test_rdoc_encoding.rb
    trunk/test/rdoc/test_rdoc_extend.rb
    trunk/test/rdoc/test_rdoc_generator_darkfish.rb
    trunk/test/rdoc/test_rdoc_generator_json_index.rb
    trunk/test/rdoc/test_rdoc_generator_markup.rb
    trunk/test/rdoc/test_rdoc_generator_pot.rb
    trunk/test/rdoc/test_rdoc_generator_pot_po.rb
    trunk/test/rdoc/test_rdoc_generator_pot_po_entry.rb
    trunk/test/rdoc/test_rdoc_generator_ri.rb
    trunk/test/rdoc/test_rdoc_i18n_locale.rb
    trunk/test/rdoc/test_rdoc_i18n_text.rb
    trunk/test/rdoc/test_rdoc_include.rb
    trunk/test/rdoc/test_rdoc_markdown.rb
    trunk/test/rdoc/test_rdoc_markdown_test.rb
    trunk/test/rdoc/test_rdoc_markup.rb
    trunk/test/rdoc/test_rdoc_markup_attribute_manager.rb
    trunk/test/rdoc/test_rdoc_markup_attributes.rb
    trunk/test/rdoc/test_rdoc_markup_document.rb
    trunk/test/rdoc/test_rdoc_markup_formatter.rb
    trunk/test/rdoc/test_rdoc_markup_hard_break.rb
    trunk/test/rdoc/test_rdoc_markup_heading.rb
    trunk/test/rdoc/test_rdoc_markup_include.rb
    trunk/test/rdoc/test_rdoc_markup_indented_paragraph.rb
    trunk/test/rdoc/test_rdoc_markup_paragraph.rb
    trunk/test/rdoc/test_rdoc_markup_parser.rb
    trunk/test/rdoc/test_rdoc_markup_pre_process.rb
    trunk/test/rdoc/test_rdoc_markup_raw.rb
    trunk/test/rdoc/test_rdoc_markup_to_ansi.rb
    trunk/test/rdoc/test_rdoc_markup_to_bs.rb
    trunk/test/rdoc/test_rdoc_markup_to_html.rb
    trunk/test/rdoc/test_rdoc_markup_to_html_crossref.rb
    trunk/test/rdoc/test_rdoc_markup_to_html_snippet.rb
    trunk/test/rdoc/test_rdoc_markup_to_joined_paragraph.rb
    trunk/test/rdoc/test_rdoc_markup_to_label.rb
    trunk/test/rdoc/test_rdoc_markup_to_markdown.rb
    trunk/test/rdoc/test_rdoc_markup_to_rdoc.rb
    trunk/test/rdoc/test_rdoc_markup_to_table_of_contents.rb
    trunk/test/rdoc/test_rdoc_markup_to_tt_only.rb
    trunk/test/rdoc/test_rdoc_markup_verbatim.rb
    trunk/test/rdoc/test_rdoc_method_attr.rb
    trunk/test/rdoc/test_rdoc_normal_class.rb
    trunk/test/rdoc/test_rdoc_normal_module.rb
    trunk/test/rdoc/test_rdoc_options.rb
    trunk/test/rdoc/test_rdoc_parser.rb
    trunk/test/rdoc/test_rdoc_parser_c.rb
    trunk/test/rdoc/test_rdoc_parser_changelog.rb
    trunk/test/rdoc/test_rdoc_parser_markdown.rb
    trunk/test/rdoc/test_rdoc_parser_rd.rb
    trunk/test/rdoc/test_rdoc_parser_ruby.rb
    trunk/test/rdoc/test_rdoc_parser_simple.rb
    trunk/test/rdoc/test_rdoc_rd.rb
    trunk/test/rdoc/test_rdoc_rd_block_parser.rb
    trunk/test/rdoc/test_rdoc_rd_inline.rb
    trunk/test/rdoc/test_rdoc_rd_inline_parser.rb
    trunk/test/rdoc/test_rdoc_rdoc.rb
    trunk/test/rdoc/test_rdoc_require.rb
    trunk/test/rdoc/test_rdoc_ri_driver.rb
    trunk/test/rdoc/test_rdoc_ri_paths.rb
    trunk/test/rdoc/test_rdoc_rubygems_hook.rb
    trunk/test/rdoc/test_rdoc_servlet.rb
    trunk/test/rdoc/test_rdoc_single_class.rb
    trunk/test/rdoc/test_rdoc_stats.rb
    trunk/test/rdoc/test_rdoc_store.rb
    trunk/test/rdoc/test_rdoc_task.rb
    trunk/test/rdoc/test_rdoc_text.rb
    trunk/test/rdoc/test_rdoc_token_stream.rb
    trunk/test/rdoc/test_rdoc_tom_doc.rb
    trunk/test/rdoc/test_rdoc_top_level.rb
    trunk/test/rdoc/xref_data.rb
    trunk/test/rdoc/xref_test_case.rb
Index: lib/rdoc.rb
===================================================================
--- lib/rdoc.rb	(revision 60919)
+++ lib/rdoc.rb	(revision 60920)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/lib/rdoc.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 $DEBUG_RDOC = nil
 
 # :main: README.rdoc
@@ -65,7 +65,7 @@ module RDoc https://github.com/ruby/ruby/blob/trunk/lib/rdoc.rb#L65
   ##
   # RDoc version you are using
 
-  VERSION = '6.0.0.beta3'
+  VERSION = '6.0.0.beta4'
 
   ##
   # Method visibilities
Index: lib/rdoc/i18n.rb
===================================================================
--- lib/rdoc/i18n.rb	(revision 60919)
+++ lib/rdoc/i18n.rb	(revision 60920)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/lib/rdoc/i18n.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 ##
 # This module provides i18n related features.
 
Index: lib/rdoc/context/section.rb
===================================================================
--- lib/rdoc/context/section.rb	(revision 60919)
+++ lib/rdoc/context/section.rb	(revision 60920)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/lib/rdoc/context/section.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 ##
 # A section of documentation like:
 #
@@ -43,7 +43,7 @@ class RDoc::Context::Section https://github.com/ruby/ruby/blob/trunk/lib/rdoc/context/section.rb#L43
     @parent = parent
     @title = title ? title.strip : title
 
-    @@sequence.succ!
+    @@sequence = @@sequence.succ
     @sequence = @@sequence.dup
 
     @comments = []
Index: lib/rdoc/ghost_method.rb
===================================================================
--- lib/rdoc/ghost_method.rb	(revision 60919)
+++ lib/rdoc/ghost_method.rb	(revision 60920)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/lib/rdoc/ghost_method.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 ##
 # GhostMethod represents a method referenced only by a comment
 
Index: lib/rdoc/text.rb
===================================================================
--- lib/rdoc/text.rb	(revision 60919)
+++ lib/rdoc/text.rb	(revision 60920)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/lib/rdoc/text.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 
 ##
 # For RDoc::Text#to_html
@@ -60,7 +60,7 @@ module RDoc::Text https://github.com/ruby/ruby/blob/trunk/lib/rdoc/text.rb#L60
     text.each_line do |line|
       nil while line.gsub!(/(?:\G|\r)((?:.{8})*?)([^\t\r\n]{0,7})\t/) do
         r = "#{$1}#{$2}#{' ' * (8 - $2.size)}"
-        r.force_encoding text.encoding
+        r = RDoc::Encoding.change_encoding r, text.encoding
         r
       end
 
@@ -82,7 +82,7 @@ module RDoc::Text https://github.com/ruby/ruby/blob/trunk/lib/rdoc/text.rb#L82
     end
 
     empty = ''
-    empty.force_encoding text.encoding
+    empty = RDoc::Encoding.change_encoding empty, text.encoding
 
     text.gsub(/^ {0,#{indent}}/, empty)
   end
@@ -149,7 +149,7 @@ module RDoc::Text https://github.com/ruby/ruby/blob/trunk/lib/rdoc/text.rb#L149
     return text if text =~ /^(?>\s*)[^\#]/
 
     empty = ''
-    empty.force_encoding text.encoding
+    empty = RDoc::Encoding.change_encoding empty, text.encoding
 
     text.gsub(/^\s*(#+)/) { $1.tr '#', ' ' }.gsub(/^\s+$/, empty)
   end
@@ -172,14 +172,14 @@ module RDoc::Text https://github.com/ruby/ruby/blob/trunk/lib/rdoc/text.rb#L172
     text = text.gsub %r%Document-method:\s+[\w:.#=!?]+%, ''
 
     space = ' '
-    space.force_encoding encoding if encoding
+    space = RDoc::Encoding.change_encoding space, encoding if encoding
 
     text.sub!  %r%/\*+%       do space * $&.length end
     text.sub!  %r%\*+/%       do space * $&.length end
     text.gsub! %r%^[ \t]*\*%m do space * $&.length end
 
     empty = ''
-    empty.force_encoding encoding if encoding
+    empty = RDoc::Encoding.change_encoding empty, encoding if encoding
     text.gsub(/^\s+$/, empty)
   end
 
@@ -188,7 +188,7 @@ module RDoc::Text https://github.com/ruby/ruby/blob/trunk/lib/rdoc/text.rb#L188
   # trademark symbols in +text+ to properly encoded characters.
 
   def to_html text
-    html = ''.encode text.encoding
+    html = (''.encode text.encoding).dup
 
     encoded = RDoc::Text::TO_HTML_CHARACTERS[text.encoding]
 
Index: lib/rdoc/mixin.rb
===================================================================
--- lib/rdoc/mixin.rb	(revision 60919)
+++ lib/rdoc/mixin.rb	(revision 60920)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/lib/rdoc/mixin.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 ##
 # A Mixin adds features from a module into another context.  RDoc::Include and
 # RDoc::Extend are both mixins.
Index: lib/rdoc/context.rb
===================================================================
--- lib/rdoc/context.rb	(revision 60919)
+++ lib/rdoc/context.rb	(revision 60920)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/lib/rdoc/context.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 require 'cgi'
 
 ##
@@ -239,7 +239,7 @@ class RDoc::Context < RDoc::CodeObject https://github.com/ruby/ruby/blob/trunk/lib/rdoc/context.rb#L239
 
       if known then
         known.comment = attribute.comment if known.comment.empty?
-      elsif registered = @methods_hash[attribute.pretty_name << '='] and
+      elsif registered = @methods_hash[attribute.pretty_name + '='] and
             RDoc::Attr === registered then
         registered.rw = 'RW'
       else
@@ -249,7 +249,7 @@ class RDoc::Context < RDoc::CodeObject https://github.com/ruby/ruby/blob/trunk/lib/rdoc/context.rb#L249
     end
 
     if attribute.rw.index 'W' then
-      key = attribute.pretty_name << '='
+      key = attribute.pretty_name + '='
       known = @methods_hash[key]
 
       if known then
Index: lib/rdoc/erb_partial.rb
===================================================================
--- lib/rdoc/erb_partial.rb	(revision 60919)
+++ lib/rdoc/erb_partial.rb	(revision 60920)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/lib/rdoc/erb_partial.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 ##
 # Allows an ERB template to be rendered in the context (binding) of an
 # existing ERB template evaluation.
Index: lib/rdoc/encoding.rb
===================================================================
--- lib/rdoc/encoding.rb	(revision 60919)
+++ lib/rdoc/encoding.rb	(revision 60920)
@@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/lib/rdoc/encoding.rb#L1
 # coding: US-ASCII
-# frozen_string_literal: false
+# frozen_string_literal: true
 
 ##
 # This class is a wrapper around File IO and Encoding that helps RDoc load
@@ -23,26 +23,26 @@ module RDoc::Encoding https://github.com/ruby/ruby/blob/trunk/lib/rdoc/encoding.rb#L23
 
     utf8 = content.sub!(/\A\xef\xbb\xbf/, '')
 
-    RDoc::Encoding.set_encoding content
+    content = RDoc::Encoding.set_encoding content
 
     begin
       encoding ||= Encoding.default_external
       orig_encoding = content.encoding
 
       if not orig_encoding.ascii_compatible? then
-        content.encode! encoding
+        content = content.encode encoding
       elsif utf8 then
-        content.force_encoding Encoding::UTF_8
-        content.encode! encoding
+        content = RDoc::Encoding.change_encoding content, Encoding::UTF_8
+        content = content.encode encoding
       else
         # assume the content is in our output encoding
-        content.force_encoding encoding
+        content = RDoc::Encoding.change_encoding content, encoding
       end
 
       unless content.valid_encoding? then
         # revert and try to transcode
-        content.force_encoding orig_encoding
-        content.encode! encoding
+        content = RDoc::Encoding.change_encoding content, orig_encoding
+        content = content.encode encoding
       end
 
       unless content.valid_encoding? then
@@ -52,10 +52,11 @@ module RDoc::Encoding https://github.com/ruby/ruby/blob/trunk/lib/rdoc/encoding.rb#L52
     rescue Encoding::InvalidByteSequenceError,
            Encoding::UndefinedConversionError => e
       if force_transcode then
-        content.force_encoding orig_encoding
-        content.encode!(encoding,
-                        :invalid => :replace, :undef => :replace,
-                        :replace => '?')
+        content = RDoc::Encoding.change_encoding content, orig_encoding
+        content = content.encode(encoding,
+                                 :invalid => :replace,
+                                 :undef => :replace,
+                                 :replace => '?')
         return content
       else
         warn "unable to convert #{e.message} for #{filename}, skipping"
@@ -77,15 +78,17 @@ module RDoc::Encoding https://github.com/ruby/ruby/blob/trunk/lib/rdoc/encoding.rb#L78
     first_line = $1
 
     if first_line =~ /\A# +frozen[-_]string[-_]literal[=:].+$/i
-      string.sub! first_line, ''
+      string = string.sub first_line, ''
     end
+
+    string
   end
 
   ##
   # Sets the encoding of +string+ based on the magic comment
 
   def self.set_encoding string
-    remove_frozen_string_literal string
+    string = remove_frozen_string_literal string
 
     string =~ /\A(?:#!.*\n)?(.*\n)/
 
@@ -94,15 +97,34 @@ module RDoc::Encoding https://github.com/ruby/ruby/blob/trunk/lib/rdoc/encoding.rb#L97
     name = case first_line
            when /^<\?xml[^?]*encoding=(["'])(.*?)\1/ then $2
            when /\b(?:en)?coding[=:]\s*([^\s;]+)/i   then $1
-           else                                           return
+           else                                           return string
            end
 
-    string.sub! first_line, ''
+    string = string.sub first_line, ''
 
-    remove_frozen_string_literal string
+    string = remove_frozen_string_literal string
 
     enc = Encoding.find name
-    string.force_encoding enc if enc
+    string = RDoc::Encoding.change_encoding string, enc if enc
+
+    string
+  end
+
+  ##
+  # Changes encoding based on +encoding+ without converting and returns new
+  # string
+
+  def self.change_encoding text, encoding
+    if text.kind_of? RDoc::Comment
+      text.encode! encoding
+    else
+      # TODO: Remove this condition after Ruby 2.2 EOL
+      if RUBY_VERSION < '2.3.0'
+        text.force_encoding encoding
+      else
+        String.new text, encoding: encoding
+      end
+    end
   end
 
 end
Index: lib/rdoc/any_method.rb
===================================================================
--- lib/rdoc/any_method.rb	(revision 60919)
+++ lib/rdoc/any_method.rb	(revision 60920)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/lib/rdoc/any_method.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 ##
 # AnyMethod is the base class for objects representing methods
 
@@ -244,9 +244,9 @@ class RDoc::AnyMethod < RDoc::MethodAttr https://github.com/ruby/ruby/blob/trunk/lib/rdoc/any_method.rb#L244
     if @block_params then
       # If this method has explicit block parameters, remove any explicit
       # &block
-      params.sub!(/,?\s*&\w+/, '')
+      params = params.sub(/,?\s*&\w+/, '')
     else
-      params.sub!(/\&(\w+)/, '\1')
+      params = params.sub(/\&(\w+)/, '\1')
     end
 
     params = params.gsub(/\s+/, '').split(',').reject(&:empty?)
@@ -265,7 +265,7 @@ class RDoc::AnyMethod < RDoc::MethodAttr https://github.com/ruby/ruby/blob/trunk/lib/rdoc/any_method.rb#L265
       params = params.sub(/(\|[^|]+\|)\s*\.\.\.\s*(end|\})/, '\1 \2')
     elsif @params then
       params = @params.gsub(/\s*\#.*/, '')
-      params = params.tr("\n", " ").squeeze(" ")
+      params = params.tr_s("\n ", " ")
       params = "(#{params})" unless params[0] == ?(
     else
       params = ''
@@ -274,11 +274,11 @@ class RDoc::AnyMethod < RDoc::MethodAttr https://github.com/ruby/ruby/blob/trunk/lib/rdoc/any_method.rb#L274
     if @block_params then
       # If this method has explicit block parameters, remove any explicit
       # &block
-      params.sub!(/,?\s*&\w+/, '')
+      params = params.sub(/,?\s*&\w+/, '')
 
-      block = @block_params.tr("\n", " ").squeeze(" ")
+      block = @block_params.tr_s("\n ", " ")
       if block[0] == ?(
-        block.sub!(/^\(/, '').sub!(/\)/, '')
+        block = block.sub(/^\(/, '').sub(/\)/, '')
       end
       params << " { |#{block}| ... }"
     end
Index: lib/rdoc/extend.rb
===================================================================
--- lib/rdoc/extend.rb	(revision 60919)
+++ lib/rdoc/extend.rb	(revision 60920)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/lib/rdoc/extend.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 ##
 # A Module extension to a class with \#extend
 #
Index: lib/rdoc/top_level.rb
===================================================================
--- lib/rdoc/top_level.rb	(revision 60919)
+++ lib/rdoc/top_level.rb	(revision 60920)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/lib/rdoc/top_level.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 ##
 # A TopLevel context is a representation of the contents of a single file
 
Index: lib/rdoc/token_stream.rb
===================================================================
--- lib/rdoc/token_stream.rb	(revision 60919)
+++ lib/rdoc/token_stream.rb	(revision 60920)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/lib/rdoc/token_stream.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 ##
 # A TokenStream is a list of tokens, gathered during the parse of some entity
 # (say a method). Entities populate these streams by being registered with the
@@ -14,6 +14,8 @@ module RDoc::TokenStream https://github.com/ruby/ruby/blob/trunk/lib/rdoc/token_stream.rb#L14
   # with the given class names. Other token types are not wrapped in spans.
 
   def self.to_html token_stream
+    starting_title = false
+
     token_stream.map do |t|
       next unless t
 
@@ -23,12 +25,8 @@ module RDoc::TokenStream https://github.com/ruby/ruby/blob/trunk/lib/rdoc/token_stream.rb#L25
               when :on_ivar    then 'ruby-ivar'
               when :on_cvar    then 'ruby-identifier'
               when :on_gvar    then 'ruby-identifier'
-              when '=' != t[:text] && :on_op then
-                if RDoc::RipperStateLex::EXPR_ARG == t[:state] then
-                                    'ruby-identifier'
-                else
-                                    'ruby-operator'
-                end
+              when '=' != t[:text] && :on_op
+                               then 'ruby-operator'
               when :on_tlambda then 'ruby-operator'
               when :on_ident   then 'ruby-identifier'
               when :on_label   then 'ruby-value'
@@ -53,6 +51,16 @@ module RDoc::TokenStream https://github.com/ruby/ruby/blob/trunk/lib/rdoc/token_stream.rb#L51
       else
         text = t[:text]
       end
+
+      if :on_ident == t[:kind] && starting_title
+        starting_title = false
+        style = 'ruby-identifier ruby-title'
+      end
+
+      if :on_kw == t[:kind] and 'def' == t[:text]
+        starting_title = true
+      end
+
       text = CGI.escapeHTML text
 
       if style then
Index: lib/rdoc/stats/verbose.rb
===================================================================
--- lib/rdoc/stats/verbose.rb	(revision 60919)
+++ lib/rdoc/stats/verbose.rb	(revision 60920)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/lib/rdoc/stats/verbose.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 ##
 # Stats printer that prints everything documented, including the documented
 # status
Index: lib/rdoc/stats/quiet.rb
===================================================================
--- lib/rdoc/stats/quiet.rb	(revision 60919)
+++ lib/rdoc/stats/quiet.rb	(revision 60920)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/lib/rdoc/stats/quiet.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 ##
 # Stats printer that prints nothing
 
Index: lib/rdoc/stats/normal.rb
===================================================================
--- lib/rdoc/stats/normal.rb	(revision 60919)
+++ lib/rdoc/stats/normal.rb	(revision 60920)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/lib/rdoc/stats/normal.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 begin
   require 'io/console/size'
 rescue LoadError
@@ -42,7 +42,7 @@ class RDoc::Stats::Normal < RDoc::Stats: https://github.com/ruby/ruby/blob/trunk/lib/rdoc/stats/normal.rb#L42
     if $stdout.tty?
       # Clean the line with whitespaces so that leftover output from the
       # previous line doesn't show up.
-      $stdout.print("\r" << (" " * @last_width) << ("\b" * @last_width) << "\r") if @last_width && @last_width > 0
+      $stdout.print("\r" + (" " * @last_width) + ("\b" * @last_width) + "\r") if @last_width && @last_width > 0
       @last_width = line.size
       $stdout.print("#{line}\r")
     else
Index: lib/rdoc/store.rb
===================================================================
--- lib/rdoc/store.rb	(revision 60919)
+++ lib/rdoc/store.rb	(revision 60920)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/lib/rdoc/store.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 require 'fileutils'
 
 ##
Index: lib/rdoc/markup/list.rb
===================================================================
--- lib/rdoc/markup/list.rb	(revision 60919)
+++ lib/rdoc/markup/list.rb	(revision 60920)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/lib/rdoc/markup/list.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 ##
 # A List is a homogeneous set of ListItems.
 #
Index: lib/rdoc/markup/to_label.rb
===================================================================
--- lib/rdoc/markup/to_label.rb	(revision 60919)
+++ lib/rdoc/markup/to_label.rb	(revision 60920)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/lib/rdoc/markup/to_label.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 require 'cgi'
 
 ##
Index: lib/rdoc/markup/hard_break.rb
===================================================================
--- lib/rdoc/markup/hard_break.rb	(revision 60919)
+++ lib/rdoc/markup/hard_break.rb	(revision 60920)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/lib/rdoc/markup/hard_break.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 ##
 # A hard-break in the middle of a paragraph.
 
Index: lib/rdoc/markup/include.rb
===================================================================
--- lib/rdoc/markup/include.rb	(revision 60919)
+++ lib/rdoc/markup/include.rb	(revision 60920)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/lib/rdoc/markup/include.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 ##
 # A file included at generation time.  Objects of this class are created by
 # RDoc::RD for an extension-less include.
Index: lib/rdoc/markup/pre_process.rb
===================================================================
--- lib/rdoc/markup/pre_process.rb	(revision 60919)
+++ lib/rdoc/markup/pre_process.rb	(revision 60920)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/lib/rdoc/markup/pre_process.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 ##
 # Handle common directives that can occur in a block of text:
 #
@@ -105,7 +105,7 @@ class RDoc::Markup::PreProcess https://github.com/ruby/ruby/blob/trunk/lib/rdoc/markup/pre_process.rb#L105
     # regexp helper (square brackets for optional)
     # $1      $2  $3        $4      $5
     # [prefix][\]:directive:[spaces][param]newline
-    text.gsub!(/^([ \t]*(?:#|\/?\*)?[ \t]*)(\\?):(\w+):([ \t]*)(.+)?(\r?\n|$)/) do
+    text = text.gsub(/^([ \t]*(?:#|\/?\*)?[ \t]*)(\\?):(\w+):([ \t]*)(.+)?(\r?\n|$)/) do
       # skip something like ':toto::'
       next $& if $4.empty? and $5 and $5[0, 1] == ':'
 
@@ -123,7 +123,11 @@ cl (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]