From 55518710865bd7258422807524403c91347519a2 Mon Sep 17 00:00:00 2001 From: hsbt Date: Mon, 27 Nov 2017 10:45:24 +0000 Subject: Merge rdoc-6.0.0.beta4 from upstream. It version applied `frozen_string_literal: true` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rdoc/alias.rb | 2 +- lib/rdoc/anon_class.rb | 2 +- lib/rdoc/any_method.rb | 14 +- lib/rdoc/attr.rb | 2 +- lib/rdoc/class_module.rb | 6 +- lib/rdoc/code_object.rb | 4 +- lib/rdoc/code_objects.rb | 2 +- lib/rdoc/comment.rb | 30 +- lib/rdoc/constant.rb | 2 +- lib/rdoc/context.rb | 6 +- lib/rdoc/context/section.rb | 4 +- lib/rdoc/cross_reference.rb | 2 +- lib/rdoc/encoding.rb | 58 +- lib/rdoc/erb_partial.rb | 2 +- lib/rdoc/erbio.rb | 2 +- lib/rdoc/extend.rb | 2 +- lib/rdoc/generator.rb | 2 +- lib/rdoc/generator/darkfish.rb | 69 +- lib/rdoc/generator/json_index.rb | 4 +- lib/rdoc/generator/markup.rb | 2 +- lib/rdoc/generator/pot.rb | 2 +- lib/rdoc/generator/pot/message_extractor.rb | 2 +- lib/rdoc/generator/pot/po.rb | 6 +- lib/rdoc/generator/pot/po_entry.rb | 22 +- lib/rdoc/generator/ri.rb | 2 +- lib/rdoc/ghost_method.rb | 2 +- lib/rdoc/i18n.rb | 2 +- lib/rdoc/i18n/locale.rb | 2 +- lib/rdoc/i18n/text.rb | 10 +- lib/rdoc/include.rb | 2 +- lib/rdoc/known_classes.rb | 2 +- lib/rdoc/markdown.rb | 1364 +++++++++++++++------------ lib/rdoc/markdown/entities.rb | 2 +- lib/rdoc/markdown/literals.rb | 25 +- lib/rdoc/markup.rb | 2 +- lib/rdoc/markup/attr_changer.rb | 2 +- lib/rdoc/markup/attr_span.rb | 2 +- lib/rdoc/markup/attribute_manager.rb | 4 +- lib/rdoc/markup/attributes.rb | 2 +- lib/rdoc/markup/blank_line.rb | 2 +- lib/rdoc/markup/block_quote.rb | 2 +- lib/rdoc/markup/document.rb | 2 +- lib/rdoc/markup/formatter.rb | 2 +- lib/rdoc/markup/formatter_test_case.rb | 2 +- lib/rdoc/markup/hard_break.rb | 2 +- lib/rdoc/markup/heading.rb | 2 +- lib/rdoc/markup/include.rb | 2 +- lib/rdoc/markup/indented_paragraph.rb | 2 +- lib/rdoc/markup/inline.rb | 2 +- lib/rdoc/markup/list.rb | 2 +- lib/rdoc/markup/list_item.rb | 2 +- lib/rdoc/markup/paragraph.rb | 2 +- lib/rdoc/markup/parser.rb | 6 +- lib/rdoc/markup/pre_process.rb | 14 +- lib/rdoc/markup/raw.rb | 2 +- lib/rdoc/markup/rule.rb | 2 +- lib/rdoc/markup/special.rb | 2 +- lib/rdoc/markup/text_formatter_test_case.rb | 2 +- lib/rdoc/markup/to_ansi.rb | 2 +- lib/rdoc/markup/to_bs.rb | 2 +- lib/rdoc/markup/to_html.rb | 2 +- lib/rdoc/markup/to_html_crossref.rb | 2 +- lib/rdoc/markup/to_html_snippet.rb | 2 +- lib/rdoc/markup/to_joined_paragraph.rb | 38 +- lib/rdoc/markup/to_label.rb | 2 +- lib/rdoc/markup/to_markdown.rb | 2 +- lib/rdoc/markup/to_rdoc.rb | 2 +- lib/rdoc/markup/to_table_of_contents.rb | 2 +- lib/rdoc/markup/to_test.rb | 2 +- lib/rdoc/markup/to_tt_only.rb | 2 +- lib/rdoc/markup/verbatim.rb | 2 +- lib/rdoc/meta_method.rb | 2 +- lib/rdoc/method_attr.rb | 4 +- lib/rdoc/mixin.rb | 2 +- lib/rdoc/normal_class.rb | 6 +- lib/rdoc/normal_module.rb | 2 +- lib/rdoc/options.rb | 12 +- lib/rdoc/parser.rb | 2 +- lib/rdoc/parser/c.rb | 12 +- lib/rdoc/parser/changelog.rb | 10 +- lib/rdoc/parser/markdown.rb | 2 +- lib/rdoc/parser/rd.rb | 2 +- lib/rdoc/parser/ripper_state_lex.rb | 34 +- lib/rdoc/parser/ruby.rb | 78 +- lib/rdoc/parser/ruby_tools.rb | 5 +- lib/rdoc/parser/simple.rb | 6 +- lib/rdoc/parser/text.rb | 2 +- lib/rdoc/rd.rb | 2 +- lib/rdoc/rd/block_parser.rb | 120 +-- lib/rdoc/rd/inline.rb | 10 +- lib/rdoc/rd/inline_parser.rb | 108 +-- lib/rdoc/rdoc.gemspec | 6 +- lib/rdoc/rdoc.rb | 19 +- lib/rdoc/require.rb | 2 +- lib/rdoc/ri.rb | 2 +- lib/rdoc/ri/driver.rb | 2 +- lib/rdoc/ri/formatter.rb | 2 +- lib/rdoc/ri/paths.rb | 2 +- lib/rdoc/ri/store.rb | 2 +- lib/rdoc/ri/task.rb | 2 +- lib/rdoc/rubygems_hook.rb | 2 +- lib/rdoc/servlet.rb | 4 +- lib/rdoc/single_class.rb | 2 +- lib/rdoc/stats.rb | 2 +- lib/rdoc/stats/normal.rb | 4 +- lib/rdoc/stats/quiet.rb | 2 +- lib/rdoc/stats/verbose.rb | 2 +- lib/rdoc/store.rb | 2 +- lib/rdoc/task.rb | 2 +- lib/rdoc/test_case.rb | 7 +- lib/rdoc/text.rb | 14 +- lib/rdoc/token_stream.rb | 22 +- lib/rdoc/tom_doc.rb | 4 +- lib/rdoc/top_level.rb | 2 +- 114 files changed, 1278 insertions(+), 1043 deletions(-) (limited to 'lib/rdoc') diff --git a/lib/rdoc/alias.rb b/lib/rdoc/alias.rb index 1e06fb96e5..858e053049 100644 --- a/lib/rdoc/alias.rb +++ b/lib/rdoc/alias.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # Represent an alias, which is an old_name/new_name pair associated with a # particular context diff --git a/lib/rdoc/anon_class.rb b/lib/rdoc/anon_class.rb index 098bfdfcf9..d02a38c2cf 100644 --- a/lib/rdoc/anon_class.rb +++ b/lib/rdoc/anon_class.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # An anonymous class like: # diff --git a/lib/rdoc/any_method.rb b/lib/rdoc/any_method.rb index c5cb9c079a..9b0d309653 100644 --- a/lib/rdoc/any_method.rb +++ b/lib/rdoc/any_method.rb @@ -1,4 +1,4 @@ -# 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 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 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 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 diff --git a/lib/rdoc/attr.rb b/lib/rdoc/attr.rb index f77a5c04a7..f780b3b976 100644 --- a/lib/rdoc/attr.rb +++ b/lib/rdoc/attr.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # An attribute created by \#attr, \#attr_reader, \#attr_writer or # \#attr_accessor diff --git a/lib/rdoc/class_module.rb b/lib/rdoc/class_module.rb index 5881d6cf24..fdd56e236b 100644 --- a/lib/rdoc/class_module.rb +++ b/lib/rdoc/class_module.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # ClassModule is the base class for objects representing either a class or a # module. @@ -136,7 +136,9 @@ class RDoc::ClassModule < RDoc::Context normalize_comment comment end - @comment_location.delete_if { |(_, l)| l == location } + if location.parser == RDoc::Parser::C + @comment_location.delete_if { |(_, l)| l == location } + end @comment_location << [comment, location] diff --git a/lib/rdoc/code_object.rb b/lib/rdoc/code_object.rb index 11c682b7fa..aeb4b4762e 100644 --- a/lib/rdoc/code_object.rb +++ b/lib/rdoc/code_object.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # Base class for the RDoc code tree. # @@ -144,7 +144,7 @@ class RDoc::CodeObject # HACK correct fix is to have #initialize create @comment # with the correct encoding if String === @comment and @comment.empty? then - @comment.force_encoding comment.encoding + @comment = RDoc::Encoding.change_encoding @comment, comment.encoding end @comment end diff --git a/lib/rdoc/code_objects.rb b/lib/rdoc/code_objects.rb index 564849e1d1..434a25ac7f 100644 --- a/lib/rdoc/code_objects.rb +++ b/lib/rdoc/code_objects.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true # This file was used to load all the RDoc::CodeObject subclasses at once. Now # autoload handles this. diff --git a/lib/rdoc/comment.rb b/lib/rdoc/comment.rb index c655763b3e..134f6440a0 100644 --- a/lib/rdoc/comment.rb +++ b/lib/rdoc/comment.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # A comment holds the text comment for a RDoc::CodeObject and provides a # unified way of cleaning it up and parsing it into an RDoc::Markup::Document. @@ -45,7 +45,7 @@ class RDoc::Comment def initialize text = nil, location = nil @location = location - @text = text + @text = text.nil? ? nil : text.dup @document = nil @format = 'rdoc' @@ -114,10 +114,14 @@ class RDoc::Comment method.call_seq = seq.chomp - elsif @text.sub!(/^\s*:?call-seq:(.*?)(^\s*$|\z)/m, '') then - seq = $1 - seq.gsub!(/^\s*/, '') - method.call_seq = seq + else + regexp = /^\s*:?call-seq:(.*?)(^\s*$|\z)/m + if regexp =~ @text then + @text = @text.sub(regexp, '') + seq = $1 + seq.gsub!(/^\s*/, '') + method.call_seq = seq + end end method @@ -133,8 +137,14 @@ class RDoc::Comment ## # HACK dubious - def force_encoding encoding - @text.force_encoding encoding + def encode! encoding + # TODO: Remove this condition after Ruby 2.2 EOL + if RUBY_VERSION < '2.3.0' + @text = @text.force_encoding encoding + else + @text = String.new @text, encoding: encoding + end + self end ## @@ -200,7 +210,7 @@ class RDoc::Comment def remove_private # Workaround for gsub encoding for Ruby 1.9.2 and earlier empty = '' - empty.force_encoding @text.encoding + empty = RDoc::Encoding.change_encoding empty, @text.encoding @text = @text.gsub(%r%^\s*([#*]?)--.*?^\s*(\1)\+\+\n?%m, empty) @text = @text.sub(%r%^\s*[#*]?--.*%m, '') @@ -216,7 +226,7 @@ class RDoc::Comment @text.nil? and @document @document = nil - @text = text + @text = text.nil? ? nil : text.dup end ## diff --git a/lib/rdoc/constant.rb b/lib/rdoc/constant.rb index 7e1e10da72..0c3d7505a1 100644 --- a/lib/rdoc/constant.rb +++ b/lib/rdoc/constant.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # A constant diff --git a/lib/rdoc/context.rb b/lib/rdoc/context.rb index 3294b2561c..58b1c54269 100644 --- a/lib/rdoc/context.rb +++ b/lib/rdoc/context.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'cgi' ## @@ -239,7 +239,7 @@ class RDoc::Context < RDoc::CodeObject 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 end if attribute.rw.index 'W' then - key = attribute.pretty_name << '=' + key = attribute.pretty_name + '=' known = @methods_hash[key] if known then diff --git a/lib/rdoc/context/section.rb b/lib/rdoc/context/section.rb index 7c3c8c603d..11f9ceaf87 100644 --- a/lib/rdoc/context/section.rb +++ b/lib/rdoc/context/section.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # A section of documentation like: # @@ -43,7 +43,7 @@ class RDoc::Context::Section @parent = parent @title = title ? title.strip : title - @@sequence.succ! + @@sequence = @@sequence.succ @sequence = @@sequence.dup @comments = [] diff --git a/lib/rdoc/cross_reference.rb b/lib/rdoc/cross_reference.rb index 0e40d23159..d76ebaf2d0 100644 --- a/lib/rdoc/cross_reference.rb +++ b/lib/rdoc/cross_reference.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # RDoc::CrossReference is a reusable way to create cross references for names. diff --git a/lib/rdoc/encoding.rb b/lib/rdoc/encoding.rb index 44881d043c..54ecd89816 100644 --- a/lib/rdoc/encoding.rb +++ b/lib/rdoc/encoding.rb @@ -1,5 +1,5 @@ # 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 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 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 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 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 diff --git a/lib/rdoc/erb_partial.rb b/lib/rdoc/erb_partial.rb index d17dda20a9..8dc2c46013 100644 --- a/lib/rdoc/erb_partial.rb +++ b/lib/rdoc/erb_partial.rb @@ -1,4 +1,4 @@ -# 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. diff --git a/lib/rdoc/erbio.rb b/lib/rdoc/erbio.rb index a2aaa90e67..42ce895fb3 100644 --- a/lib/rdoc/erbio.rb +++ b/lib/rdoc/erbio.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'erb' ## diff --git a/lib/rdoc/extend.rb b/lib/rdoc/extend.rb index 30b51a1dbd..e1b182902e 100644 --- a/lib/rdoc/extend.rb +++ b/lib/rdoc/extend.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # A Module extension to a class with \#extend # diff --git a/lib/rdoc/generator.rb b/lib/rdoc/generator.rb index 6efc5e4474..340dcbf7ae 100644 --- a/lib/rdoc/generator.rb +++ b/lib/rdoc/generator.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # RDoc uses generators to turn parsed source code in the form of an # RDoc::CodeObject tree into some form of output. RDoc comes with the HTML diff --git a/lib/rdoc/generator/darkfish.rb b/lib/rdoc/generator/darkfish.rb index e961518fcc..bf4eb1f530 100644 --- a/lib/rdoc/generator/darkfish.rb +++ b/lib/rdoc/generator/darkfish.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true # -*- mode: ruby; ruby-indent-level: 2; tab-width: 2 -*- require 'erb' @@ -313,12 +313,16 @@ class RDoc::Generator::Darkfish search_index_rel_prefix = rel_prefix search_index_rel_prefix += @asset_rel_path if @file_output - # suppress 1.9.3 warning - asset_rel_prefix = asset_rel_prefix = rel_prefix + @asset_rel_path + asset_rel_prefix = rel_prefix + @asset_rel_path @title = @options.title - render_template template_file, out_file do |io| binding end + render_template template_file, out_file do |io| + here = binding + # suppress 1.9.3 warning + here.local_variable_set(:asset_rel_prefix, asset_rel_prefix) + here + end rescue => e error = RDoc::Error.new \ "error generating index.html: #{e.message} (#{e.class})" @@ -343,14 +347,19 @@ class RDoc::Generator::Darkfish search_index_rel_prefix = rel_prefix search_index_rel_prefix += @asset_rel_path if @file_output - # suppress 1.9.3 warning - asset_rel_prefix = asset_rel_prefix = rel_prefix + @asset_rel_path - svninfo = svninfo = get_svninfo(current) + asset_rel_prefix = rel_prefix + @asset_rel_path + svninfo = get_svninfo(current) @title = "#{klass.type} #{klass.full_name} - #{@options.title}" debug_msg " rendering #{out_file}" - render_template template_file, out_file do |io| binding end + render_template template_file, out_file do |io| + here = binding + # suppress 1.9.3 warning + here.local_variable_set(:asset_rel_prefix, asset_rel_prefix) + here.local_variable_set(:svninfo, svninfo) + here + end end ## @@ -416,8 +425,7 @@ class RDoc::Generator::Darkfish search_index_rel_prefix = rel_prefix search_index_rel_prefix += @asset_rel_path if @file_output - # suppress 1.9.3 warning - asset_rel_prefix = asset_rel_prefix = rel_prefix + @asset_rel_path + asset_rel_prefix = rel_prefix + @asset_rel_path unless filepage_file then if file.text? then @@ -434,7 +442,13 @@ class RDoc::Generator::Darkfish @title += " - #{@options.title}" template_file ||= filepage_file - render_template template_file, out_file do |io| binding end + render_template template_file, out_file do |io| + here = binding + # suppress 1.9.3 warning + here.local_variable_set(:asset_rel_prefix, asset_rel_prefix) + here.local_variable_set(:current, current) + here + end end rescue => e error = @@ -458,14 +472,19 @@ class RDoc::Generator::Darkfish search_index_rel_prefix = rel_prefix search_index_rel_prefix += @asset_rel_path if @file_output - # suppress 1.9.3 warning - current = current = file - asset_rel_prefix = asset_rel_prefix = rel_prefix + @asset_rel_path + current = file + asset_rel_prefix = rel_prefix + @asset_rel_path @title = "#{file.page_name} - #{@options.title}" debug_msg " rendering #{out_file}" - render_template template_file, out_file do |io| binding end + render_template template_file, out_file do |io| + here = binding + # suppress 1.9.3 warning + here.local_variable_set(:current, current) + here.local_variable_set(:asset_rel_prefix, asset_rel_prefix) + here + end end ## @@ -483,12 +502,16 @@ class RDoc::Generator::Darkfish search_index_rel_prefix = rel_prefix search_index_rel_prefix += @asset_rel_path if @file_output - # suppress 1.9.3 warning - asset_rel_prefix = asset_rel_prefix = '' + asset_rel_prefix = '' @title = 'Not Found' - render_template template_file do |io| binding end + render_template template_file do |io| + here = binding + # suppress 1.9.3 warning + here.local_variable_set(:asset_rel_prefix, asset_rel_prefix) + here + end rescue => e error = RDoc::Error.new \ "error generating servlet_not_found: #{e.message} (#{e.class})" @@ -540,12 +563,16 @@ class RDoc::Generator::Darkfish search_index_rel_prefix = rel_prefix search_index_rel_prefix += @asset_rel_path if @file_output - # suppress 1.9.3 warning - asset_rel_prefix = asset_rel_prefix = rel_prefix + @asset_rel_path + asset_rel_prefix = rel_prefix + @asset_rel_path @title = "Table of Contents - #{@options.title}" - render_template template_file, out_file do |io| binding end + render_template template_file, out_file do |io| + here = binding + # suppress 1.9.3 warning + here.local_variable_set(:asset_rel_prefix, asset_rel_prefix) + here + end rescue => e error = RDoc::Error.new \ "error generating table_of_contents.html: #{e.message} (#{e.class})" diff --git a/lib/rdoc/generator/json_index.rb b/lib/rdoc/generator/json_index.rb index ea9384e6d3..e4cfe967c6 100644 --- a/lib/rdoc/generator/json_index.rb +++ b/lib/rdoc/generator/json_index.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'json' begin require 'zlib' @@ -161,7 +161,7 @@ class RDoc::Generator::JsonIndex # Compress the search_index.js file using gzip def generate_gzipped - return unless defined?(Zlib) + return if @options.dry_run or not defined?(Zlib) debug_msg "Compressing generated JSON index" out_dir = @base_dir + @options.op_dir diff --git a/lib/rdoc/generator/markup.rb b/lib/rdoc/generator/markup.rb index 3ca423bb69..fef982d378 100644 --- a/lib/rdoc/generator/markup.rb +++ b/lib/rdoc/generator/markup.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # Handle common RDoc::Markup tasks for various CodeObjects # diff --git a/lib/rdoc/generator/pot.rb b/lib/rdoc/generator/pot.rb index e2cf22d730..8a1e0b4bd0 100644 --- a/lib/rdoc/generator/pot.rb +++ b/lib/rdoc/generator/pot.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # Generates a POT file. # diff --git a/lib/rdoc/generator/pot/message_extractor.rb b/lib/rdoc/generator/pot/message_extractor.rb index 0dd2497c26..313dfd2dc7 100644 --- a/lib/rdoc/generator/pot/message_extractor.rb +++ b/lib/rdoc/generator/pot/message_extractor.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # Extracts message from RDoc::Store diff --git a/lib/rdoc/generator/pot/po.rb b/lib/rdoc/generator/pot/po.rb index 60e14db831..37d45e5258 100644 --- a/lib/rdoc/generator/pot/po.rb +++ b/lib/rdoc/generator/pot/po.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # Generates a PO format text @@ -29,8 +29,8 @@ class RDoc::Generator::POT::PO def to_s po = '' sort_entries.each do |entry| - po << "\n" unless po.empty? - po << entry.to_s + po += "\n" unless po.empty? + po += entry.to_s end po end diff --git a/lib/rdoc/generator/pot/po_entry.rb b/lib/rdoc/generator/pot/po_entry.rb index 515d02b48d..3c278826f4 100644 --- a/lib/rdoc/generator/pot/po_entry.rb +++ b/lib/rdoc/generator/pot/po_entry.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # A PO entry in PO @@ -40,11 +40,11 @@ class RDoc::Generator::POT::POEntry def to_s entry = '' - entry << format_translator_comment - entry << format_extracted_comment - entry << format_references - entry << format_flags - entry << <<-ENTRY + entry += format_translator_comment + entry += format_extracted_comment + entry += format_references + entry += format_flags + entry += <<-ENTRY msgid #{format_message(@msgid)} msgstr #{format_message(@msgstr)} ENTRY @@ -75,9 +75,9 @@ msgstr #{format_message(@msgstr)} formatted_comment = '' comment.each_line do |line| - formatted_comment << "#{mark} #{line}" + formatted_comment += "#{mark} #{line}" end - formatted_comment << "\n" unless formatted_comment.end_with?("\n") + formatted_comment += "\n" unless formatted_comment.end_with?("\n") formatted_comment end @@ -94,7 +94,7 @@ msgstr #{format_message(@msgstr)} formatted_references = '' @references.sort.each do |file, line| - formatted_references << "\#: #{file}:#{line}\n" + formatted_references += "\#: #{file}:#{line}\n" end formatted_references end @@ -111,8 +111,8 @@ msgstr #{format_message(@msgstr)} formatted_message = '""' message.each_line do |line| - formatted_message << "\n" - formatted_message << "\"#{escape(line)}\"" + formatted_message += "\n" + formatted_message += "\"#{escape(line)}\"" end formatted_message end diff --git a/lib/rdoc/generator/ri.rb b/lib/rdoc/generator/ri.rb index 830777e587..0eef1d03f5 100644 --- a/lib/rdoc/generator/ri.rb +++ b/lib/rdoc/generator/ri.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # Generates ri data files diff --git a/lib/rdoc/ghost_method.rb b/lib/rdoc/ghost_method.rb index a1f75bfe4b..2488feb9d7 100644 --- a/lib/rdoc/ghost_method.rb +++ b/lib/rdoc/ghost_method.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # GhostMethod represents a method referenced only by a comment diff --git a/lib/rdoc/i18n.rb b/lib/rdoc/i18n.rb index 14a3739c1c..4cb5986155 100644 --- a/lib/rdoc/i18n.rb +++ b/lib/rdoc/i18n.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # This module provides i18n related features. diff --git a/lib/rdoc/i18n/locale.rb b/lib/rdoc/i18n/locale.rb index 4d55f6965d..6a70d6c986 100644 --- a/lib/rdoc/i18n/locale.rb +++ b/lib/rdoc/i18n/locale.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # A message container for a locale. # diff --git a/lib/rdoc/i18n/text.rb b/lib/rdoc/i18n/text.rb index fcfe7611bc..7ea6664442 100644 --- a/lib/rdoc/i18n/text.rb +++ b/lib/rdoc/i18n/text.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # An i18n supported text. # @@ -46,9 +46,9 @@ class RDoc::I18n::Text parse do |part| case part[:type] when :paragraph - translated_text << locale.translate(part[:paragraph]) + translated_text += locale.translate(part[:paragraph]) when :empty_line - translated_text << part[:line] + translated_text += part[:line] else raise "should not reach here: unexpected type: #{type}" end @@ -69,14 +69,14 @@ class RDoc::I18n::Text if paragraph.empty? emit_empty_line_event(line, line_no, &block) else - paragraph << line + paragraph += line emit_paragraph_event(paragraph, paragraph_start_line, line_no, &block) paragraph = '' end else paragraph_start_line = line_no if paragraph.empty? - paragraph << line + paragraph += line end end diff --git a/lib/rdoc/include.rb b/lib/rdoc/include.rb index efce43bffb..b3ad610649 100644 --- a/lib/rdoc/include.rb +++ b/lib/rdoc/include.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # A Module included in a class with \#include # diff --git a/lib/rdoc/known_classes.rb b/lib/rdoc/known_classes.rb index 8d9421255b..4d7f4aa995 100644 --- a/lib/rdoc/known_classes.rb +++ b/lib/rdoc/known_classes.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true module RDoc ## diff --git a/lib/rdoc/markdown.rb b/lib/rdoc/markdown.rb index a7f1bb0c24..44dd50b0f7 100644 --- a/lib/rdoc/markdown.rb +++ b/lib/rdoc/markdown.rb @@ -81,6 +81,18 @@ # : A little insect that is known # to enjoy picnics # +# ### Strike +# +# Example: +# +# ``` +# This is ~~striked~~. +# ``` +# +# Produces: +# +# This is ~~striked~~. +# # ### Github # # The #github extension enables a partial set of [Github Flavored Markdown] @@ -540,6 +552,7 @@ class RDoc::Markdown :github, :html, :notes, + :strike, ] # :section: Extensions @@ -590,6 +603,11 @@ class RDoc::Markdown extension :notes + ## + # Enables the strike extension + + extension :strike + # :section: ## @@ -678,7 +696,7 @@ class RDoc::Markdown # with the linking `text` (usually whitespace). def link_to content, label = content, text = nil - raise 'enable notes extension' if + raise ParseError, 'enable notes extension' if content.start_with? '^' and label.equal? content if ref = @references[label] then @@ -814,6 +832,17 @@ class RDoc::Markdown end end + ## + # Wraps `text` in strike markup for rdoc inline formatting + + def strike text + if text =~ /\A[a-z\d.\/-]+\z/i then + "~#{text}~" + else + "#{text}" + end + end + # :stopdoc: def setup_foreign_grammar @@ -1005,7 +1034,7 @@ class RDoc::Markdown return _tmp end - # AtxInline = !@Newline !(@Sp? /#*/ @Sp @Newline) Inline + # AtxInline = !@Newline !(@Sp /#*/ @Sp @Newline) Inline def _AtxInline _save = self.pos @@ -1022,12 +1051,7 @@ class RDoc::Markdown _save3 = self.pos while true # sequence - _save4 = self.pos _tmp = _Sp() - unless _tmp - _tmp = true - self.pos = _save4 - end unless _tmp self.pos = _save3 break @@ -1092,7 +1116,7 @@ class RDoc::Markdown return _tmp end - # AtxHeading = AtxStart:s @Sp? AtxInline+:a (@Sp? /#*/ @Sp)? @Newline { RDoc::Markup::Heading.new(s, a.join) } + # AtxHeading = AtxStart:s @Sp AtxInline+:a (@Sp /#*/ @Sp)? @Newline { RDoc::Markup::Heading.new(s, a.join) } def _AtxHeading _save = self.pos @@ -1103,17 +1127,12 @@ class RDoc::Markdown self.pos = _save break end - _save1 = self.pos _tmp = _Sp() - unless _tmp - _tmp = true - self.pos = _save1 - end unless _tmp self.pos = _save break end - _save2 = self.pos + _save1 = self.pos _ary = [] _tmp = apply(:_AtxInline) if _tmp @@ -1126,42 +1145,37 @@ class RDoc::Markdown _tmp = true @result = _ary else - self.pos = _save2 + self.pos = _save1 end a = @result unless _tmp self.pos = _save break end - _save3 = self.pos + _save2 = self.pos - _save4 = self.pos + _save3 = self.pos while true # sequence - _save5 = self.pos _tmp = _Sp() unless _tmp - _tmp = true - self.pos = _save5 - end - unless _tmp - self.pos = _save4 + self.pos = _save3 break end _tmp = scan(/\A(?-mix:#*)/) unless _tmp - self.pos = _save4 + self.pos = _save3 break end _tmp = _Sp() unless _tmp - self.pos = _save4 + self.pos = _save3 end break end # end sequence unless _tmp _tmp = true - self.pos = _save3 + self.pos = _save2 end unless _tmp self.pos = _save @@ -1202,12 +1216,12 @@ class RDoc::Markdown return _tmp end - # SetextBottom1 = /={3,}/ @Newline + # SetextBottom1 = /={1,}/ @Newline def _SetextBottom1 _save = self.pos while true # sequence - _tmp = scan(/\A(?-mix:={3,})/) + _tmp = scan(/\A(?-mix:={1,})/) unless _tmp self.pos = _save break @@ -1223,12 +1237,12 @@ class RDoc::Markdown return _tmp end - # SetextBottom2 = /-{3,}/ @Newline + # SetextBottom2 = /-{1,}/ @Newline def _SetextBottom2 _save = self.pos while true # sequence - _tmp = scan(/\A(?-mix:-{3,})/) + _tmp = scan(/\A(?-mix:-{1,})/) unless _tmp self.pos = _save break @@ -1244,7 +1258,7 @@ class RDoc::Markdown return _tmp end - # SetextHeading1 = &(@RawLine SetextBottom1) @StartList:a (!@Endline Inline:b { a << b })+ @Sp? @Newline SetextBottom1 { RDoc::Markup::Heading.new(1, a.join) } + # SetextHeading1 = &(@RawLine SetextBottom1) @StartList:a (!@Endline Inline:b { a << b })+ @Sp @Newline SetextBottom1 { RDoc::Markup::Heading.new(1, a.join) } def _SetextHeading1 _save = self.pos @@ -1339,12 +1353,7 @@ class RDoc::Markdown self.pos = _save break end - _save8 = self.pos _tmp = _Sp() - unless _tmp - _tmp = true - self.pos = _save8 - end unless _tmp self.pos = _save break @@ -1371,7 +1380,7 @@ class RDoc::Markdown return _tmp end - # SetextHeading2 = &(@RawLine SetextBottom2) @StartList:a (!@Endline Inline:b { a << b })+ @Sp? @Newline SetextBottom2 { RDoc::Markup::Heading.new(2, a.join) } + # SetextHeading2 = &(@RawLine SetextBottom2) @StartList:a (!@Endline Inline:b { a << b })+ @Sp @Newline SetextBottom2 { RDoc::Markup::Heading.new(2, a.join) } def _SetextHeading2 _save = self.pos @@ -1466,12 +1475,7 @@ class RDoc::Markdown self.pos = _save break end - _save8 = self.pos _tmp = _Sp() - unless _tmp - _tmp = true - self.pos = _save8 - end unless _tmp self.pos = _save break @@ -8446,7 +8450,162 @@ class RDoc::Markdown return _tmp end - # HtmlBlockInTags = (HtmlAnchor | HtmlBlockAddress | HtmlBlockBlockquote | HtmlBlockCenter | HtmlBlockDir | HtmlBlockDiv | HtmlBlockDl | HtmlBlockFieldset | HtmlBlockForm | HtmlBlockH1 | HtmlBlockH2 | HtmlBlockH3 | HtmlBlockH4 | HtmlBlockH5 | HtmlBlockH6 | HtmlBlockMenu | HtmlBlockNoframes | HtmlBlockNoscript | HtmlBlockOl | HtmlBlockP | HtmlBlockPre | HtmlBlockTable | HtmlBlockUl | HtmlBlockDd | HtmlBlockDt | HtmlBlockFrameset | HtmlBlockLi | HtmlBlockTbody | HtmlBlockTd | HtmlBlockTfoot | HtmlBlockTh | HtmlBlockThead | HtmlBlockTr | HtmlBlockScript) + # HtmlBlockOpenHead = "<" Spnl ("head" | "HEAD") Spnl HtmlAttribute* ">" + def _HtmlBlockOpenHead + + _save = self.pos + while true # sequence + _tmp = match_string("<") + unless _tmp + self.pos = _save + break + end + _tmp = apply(:_Spnl) + unless _tmp + self.pos = _save + break + end + + _save1 = self.pos + while true # choice + _tmp = match_string("head") + break if _tmp + self.pos = _save1 + _tmp = match_string("HEAD") + break if _tmp + self.pos = _save1 + break + end # end choice + + unless _tmp + self.pos = _save + break + end + _tmp = apply(:_Spnl) + unless _tmp + self.pos = _save + break + end + while true + _tmp = apply(:_HtmlAttribute) + break unless _tmp + end + _tmp = true + unless _tmp + self.pos = _save + break + end + _tmp = match_string(">") + unless _tmp + self.pos = _save + end + break + end # end sequence + + set_failed_rule :_HtmlBlockOpenHead unless _tmp + return _tmp + end + + # HtmlBlockCloseHead = "<" Spnl "/" ("head" | "HEAD") Spnl ">" + def _HtmlBlockCloseHead + + _save = self.pos + while true # sequence + _tmp = match_string("<") + unless _tmp + self.pos = _save + break + end + _tmp = apply(:_Spnl) + unless _tmp + self.pos = _save + break + end + _tmp = match_string("/") + unless _tmp + self.pos = _save + break + end + + _save1 = self.pos + while true # choice + _tmp = match_string("head") + break if _tmp + self.pos = _save1 + _tmp = match_string("HEAD") + break if _tmp + self.pos = _save1 + break + end # end choice + + unless _tmp + self.pos = _save + break + end + _tmp = apply(:_Spnl) + unless _tmp + self.pos = _save + break + end + _tmp = match_string(">") + unless _tmp + self.pos = _save + end + break + end # end sequence + + set_failed_rule :_HtmlBlockCloseHead unless _tmp + return _tmp + end + + # HtmlBlockHead = HtmlBlockOpenHead (!HtmlBlockCloseHead .)* HtmlBlockCloseHead + def _HtmlBlockHead + + _save = self.pos + while true # sequence + _tmp = apply(:_HtmlBlockOpenHead) + unless _tmp + self.pos = _save + break + end + while true + + _save2 = self.pos + while true # sequence + _save3 = self.pos + _tmp = apply(:_HtmlBlockCloseHead) + _tmp = _tmp ? nil : true + self.pos = _save3 + unless _tmp + self.pos = _save2 + break + end + _tmp = get_byte + unless _tmp + self.pos = _save2 + end + break + end # end sequence + + break unless _tmp + end + _tmp = true + unless _tmp + self.pos = _save + break + end + _tmp = apply(:_HtmlBlockCloseHead) + unless _tmp + self.pos = _save + end + break + end # end sequence + + set_failed_rule :_HtmlBlockHead unless _tmp + return _tmp + end + + # HtmlBlockInTags = (HtmlAnchor | HtmlBlockAddress | HtmlBlockBlockquote | HtmlBlockCenter | HtmlBlockDir | HtmlBlockDiv | HtmlBlockDl | HtmlBlockFieldset | HtmlBlockForm | HtmlBlockH1 | HtmlBlockH2 | HtmlBlockH3 | HtmlBlockH4 | HtmlBlockH5 | HtmlBlockH6 | HtmlBlockMenu | HtmlBlockNoframes | HtmlBlockNoscript | HtmlBlockOl | HtmlBlockP | HtmlBlockPre | HtmlBlockTable | HtmlBlockUl | HtmlBlockDd | HtmlBlockDt | HtmlBlockFrameset | HtmlBlockLi | HtmlBlockTbody | HtmlBlockTd | HtmlBlockTfoot | HtmlBlockTh | HtmlBlockThead | HtmlBlockTr | HtmlBlockScript | HtmlBlockHead) def _HtmlBlockInTags _save = self.pos @@ -8553,6 +8712,9 @@ class RDoc::Markdown _tmp = apply(:_HtmlBlockScript) break if _tmp self.pos = _save + _tmp = apply(:_HtmlBlockHead) + break if _tmp + self.pos = _save break end # end choice @@ -9320,7 +9482,7 @@ class RDoc::Markdown return _tmp end - # Inline = (Str | @Endline | UlOrStarLine | @Space | Strong | Emph | Image | Link | NoteReference | InlineNote | Code | RawHtml | Entity | EscapedChar | Symbol) + # Inline = (Str | @Endline | UlOrStarLine | @Space | Strong | Emph | Strike | Image | Link | NoteReference | InlineNote | Code | RawHtml | Entity | EscapedChar | Symbol) def _Inline _save = self.pos @@ -9343,6 +9505,9 @@ class RDoc::Markdown _tmp = apply(:_Emph) break if _tmp self.pos = _save + _tmp = apply(:_Strike) + break if _tmp + self.pos = _save _tmp = apply(:_Image) break if _tmp self.pos = _save @@ -9669,7 +9834,7 @@ class RDoc::Markdown return _tmp end - # NormalEndline = @Sp @Newline !@BlankLine !">" !AtxStart !(Line /={3,}|-{3,}=/ @Newline) { "\n" } + # NormalEndline = @Sp @Newline !@BlankLine !">" !AtxStart !(Line /={1,}|-{1,}/ @Newline) { "\n" } def _NormalEndline _save = self.pos @@ -9717,7 +9882,7 @@ class RDoc::Markdown self.pos = _save5 break end - _tmp = scan(/\A(?-mix:={3,}|-{3,}=)/) + _tmp = scan(/\A(?-mix:={1,}|-{1,})/) unless _tmp self.pos = _save5 break @@ -10032,147 +10197,166 @@ class RDoc::Markdown return _tmp end - # OneStarOpen = !StarLine "*" !@Spacechar !@Newline - def _OneStarOpen + # Whitespace = (@Spacechar | @Newline) + def _Whitespace _save = self.pos - while true # sequence - _save1 = self.pos - _tmp = apply(:_StarLine) - _tmp = _tmp ? nil : true - self.pos = _save1 - unless _tmp - self.pos = _save - break - end - _tmp = match_string("*") - unless _tmp - self.pos = _save - break - end - _save2 = self.pos + while true # choice _tmp = _Spacechar() - _tmp = _tmp ? nil : true - self.pos = _save2 - unless _tmp - self.pos = _save - break - end - _save3 = self.pos + break if _tmp + self.pos = _save _tmp = _Newline() - _tmp = _tmp ? nil : true - self.pos = _save3 - unless _tmp - self.pos = _save - end + break if _tmp + self.pos = _save break - end # end sequence + end # end choice - set_failed_rule :_OneStarOpen unless _tmp + set_failed_rule :_Whitespace unless _tmp return _tmp end - # OneStarClose = !@Spacechar !@Newline Inline:a "*" { a } - def _OneStarClose + # EmphStar = "*" !@Whitespace @StartList:a (!"*" Inline:b { a << b } | StrongStar:b { a << b })+ "*" { emphasis a.join } + def _EmphStar _save = self.pos while true # sequence - _save1 = self.pos - _tmp = _Spacechar() - _tmp = _tmp ? nil : true - self.pos = _save1 + _tmp = match_string("*") unless _tmp self.pos = _save break end - _save2 = self.pos - _tmp = _Newline() + _save1 = self.pos + _tmp = _Whitespace() _tmp = _tmp ? nil : true - self.pos = _save2 + self.pos = _save1 unless _tmp self.pos = _save break end - _tmp = apply(:_Inline) + _tmp = _StartList() a = @result unless _tmp self.pos = _save break end - _tmp = match_string("*") - unless _tmp - self.pos = _save - break - end - @result = begin; a ; end - _tmp = true - unless _tmp - self.pos = _save - end - break - end # end sequence - - set_failed_rule :_OneStarClose unless _tmp - return _tmp - end - - # EmphStar = OneStarOpen @StartList:a (!OneStarClose Inline:l { a << l })* OneStarClose:l { a << l } { emphasis a.join } - def _EmphStar + _save2 = self.pos - _save = self.pos - while true # sequence - _tmp = apply(:_OneStarOpen) - unless _tmp - self.pos = _save - break - end - _tmp = _StartList() - a = @result - unless _tmp - self.pos = _save - break - end - while true + _save3 = self.pos + while true # choice - _save2 = self.pos + _save4 = self.pos while true # sequence - _save3 = self.pos - _tmp = apply(:_OneStarClose) + _save5 = self.pos + _tmp = match_string("*") _tmp = _tmp ? nil : true - self.pos = _save3 + self.pos = _save5 unless _tmp - self.pos = _save2 + self.pos = _save4 break end _tmp = apply(:_Inline) - l = @result + b = @result unless _tmp - self.pos = _save2 + self.pos = _save4 break end - @result = begin; a << l ; end + @result = begin; a << b ; end _tmp = true unless _tmp - self.pos = _save2 + self.pos = _save4 end break end # end sequence - break unless _tmp - end - _tmp = true - unless _tmp - self.pos = _save + break if _tmp + self.pos = _save3 + + _save6 = self.pos + while true # sequence + _tmp = apply(:_StrongStar) + b = @result + unless _tmp + self.pos = _save6 + break + end + @result = begin; a << b ; end + _tmp = true + unless _tmp + self.pos = _save6 + end + break + end # end sequence + + break if _tmp + self.pos = _save3 break + end # end choice + + if _tmp + while true + + _save7 = self.pos + while true # choice + + _save8 = self.pos + while true # sequence + _save9 = self.pos + _tmp = match_string("*") + _tmp = _tmp ? nil : true + self.pos = _save9 + unless _tmp + self.pos = _save8 + break + end + _tmp = apply(:_Inline) + b = @result + unless _tmp + self.pos = _save8 + break + end + @result = begin; a << b ; end + _tmp = true + unless _tmp + self.pos = _save8 + end + break + end # end sequence + + break if _tmp + self.pos = _save7 + + _save10 = self.pos + while true # sequence + _tmp = apply(:_StrongStar) + b = @result + unless _tmp + self.pos = _save10 + break + end + @result = begin; a << b ; end + _tmp = true + unless _tmp + self.pos = _save10 + end + break + end # end sequence + + break if _tmp + self.pos = _save7 + break + end # end choice + + break unless _tmp + end + _tmp = true + else + self.pos = _save2 end - _tmp = apply(:_OneStarClose) - l = @result unless _tmp self.pos = _save break end - @result = begin; a << l ; end - _tmp = true + _tmp = match_string("*") unless _tmp self.pos = _save break @@ -10189,254 +10373,153 @@ class RDoc::Markdown return _tmp end - # OneUlOpen = !UlLine "_" !@Spacechar !@Newline - def _OneUlOpen + # EmphUl = "_" !@Whitespace @StartList:a (!"_" Inline:b { a << b } | StrongUl:b { a << b })+ "_" { emphasis a.join } + def _EmphUl _save = self.pos while true # sequence - _save1 = self.pos - _tmp = apply(:_UlLine) - _tmp = _tmp ? nil : true - self.pos = _save1 - unless _tmp - self.pos = _save - break - end _tmp = match_string("_") unless _tmp self.pos = _save break end - _save2 = self.pos - _tmp = _Spacechar() - _tmp = _tmp ? nil : true - self.pos = _save2 - unless _tmp - self.pos = _save - break - end - _save3 = self.pos - _tmp = _Newline() - _tmp = _tmp ? nil : true - self.pos = _save3 - unless _tmp - self.pos = _save - end - break - end # end sequence - - set_failed_rule :_OneUlOpen unless _tmp - return _tmp - end - - # OneUlClose = !@Spacechar !@Newline Inline:a "_" { a } - def _OneUlClose - - _save = self.pos - while true # sequence _save1 = self.pos - _tmp = _Spacechar() + _tmp = _Whitespace() _tmp = _tmp ? nil : true self.pos = _save1 unless _tmp self.pos = _save break end - _save2 = self.pos - _tmp = _Newline() - _tmp = _tmp ? nil : true - self.pos = _save2 - unless _tmp - self.pos = _save - break - end - _tmp = apply(:_Inline) - a = @result - unless _tmp - self.pos = _save - break - end - _tmp = match_string("_") - unless _tmp - self.pos = _save - break - end - @result = begin; a ; end - _tmp = true - unless _tmp - self.pos = _save - end - break - end # end sequence - - set_failed_rule :_OneUlClose unless _tmp - return _tmp - end - - # EmphUl = OneUlOpen @StartList:a (!OneUlClose Inline:l { a << l })* OneUlClose:l { a << l } { emphasis a.join } - def _EmphUl - - _save = self.pos - while true # sequence - _tmp = apply(:_OneUlOpen) - unless _tmp - self.pos = _save - break - end _tmp = _StartList() a = @result unless _tmp self.pos = _save break end - while true + _save2 = self.pos - _save2 = self.pos + _save3 = self.pos + while true # choice + + _save4 = self.pos while true # sequence - _save3 = self.pos - _tmp = apply(:_OneUlClose) + _save5 = self.pos + _tmp = match_string("_") _tmp = _tmp ? nil : true - self.pos = _save3 + self.pos = _save5 unless _tmp - self.pos = _save2 + self.pos = _save4 break end _tmp = apply(:_Inline) - l = @result + b = @result unless _tmp - self.pos = _save2 + self.pos = _save4 break end - @result = begin; a << l ; end + @result = begin; a << b ; end _tmp = true unless _tmp - self.pos = _save2 + self.pos = _save4 end break end # end sequence - break unless _tmp - end - _tmp = true - unless _tmp - self.pos = _save - break - end - _tmp = apply(:_OneUlClose) - l = @result - unless _tmp - self.pos = _save - break - end - @result = begin; a << l ; end - _tmp = true - unless _tmp - self.pos = _save - break - end - @result = begin; emphasis a.join ; end - _tmp = true - unless _tmp - self.pos = _save - end - break - end # end sequence - - set_failed_rule :_EmphUl unless _tmp - return _tmp - end + break if _tmp + self.pos = _save3 - # Strong = (StrongStar | StrongUl) - def _Strong + _save6 = self.pos + while true # sequence + _tmp = apply(:_StrongUl) + b = @result + unless _tmp + self.pos = _save6 + break + end + @result = begin; a << b ; end + _tmp = true + unless _tmp + self.pos = _save6 + end + break + end # end sequence - _save = self.pos - while true # choice - _tmp = apply(:_StrongStar) - break if _tmp - self.pos = _save - _tmp = apply(:_StrongUl) - break if _tmp - self.pos = _save - break - end # end choice + break if _tmp + self.pos = _save3 + break + end # end choice - set_failed_rule :_Strong unless _tmp - return _tmp - end + if _tmp + while true - # TwoStarOpen = !StarLine "**" !@Spacechar !@Newline - def _TwoStarOpen + _save7 = self.pos + while true # choice - _save = self.pos - while true # sequence - _save1 = self.pos - _tmp = apply(:_StarLine) - _tmp = _tmp ? nil : true - self.pos = _save1 - unless _tmp - self.pos = _save - break - end - _tmp = match_string("**") - unless _tmp - self.pos = _save - break - end - _save2 = self.pos - _tmp = _Spacechar() - _tmp = _tmp ? nil : true - self.pos = _save2 - unless _tmp - self.pos = _save - break - end - _save3 = self.pos - _tmp = _Newline() - _tmp = _tmp ? nil : true - self.pos = _save3 - unless _tmp - self.pos = _save - end - break - end # end sequence + _save8 = self.pos + while true # sequence + _save9 = self.pos + _tmp = match_string("_") + _tmp = _tmp ? nil : true + self.pos = _save9 + unless _tmp + self.pos = _save8 + break + end + _tmp = apply(:_Inline) + b = @result + unless _tmp + self.pos = _save8 + break + end + @result = begin; a << b ; end + _tmp = true + unless _tmp + self.pos = _save8 + end + break + end # end sequence - set_failed_rule :_TwoStarOpen unless _tmp - return _tmp - end + break if _tmp + self.pos = _save7 - # TwoStarClose = !@Spacechar !@Newline Inline:a "**" { a } - def _TwoStarClose + _save10 = self.pos + while true # sequence + _tmp = apply(:_StrongUl) + b = @result + unless _tmp + self.pos = _save10 + break + end + @result = begin; a << b ; end + _tmp = true + unless _tmp + self.pos = _save10 + end + break + end # end sequence - _save = self.pos - while true # sequence - _save1 = self.pos - _tmp = _Spacechar() - _tmp = _tmp ? nil : true - self.pos = _save1 - unless _tmp - self.pos = _save - break - end - _save2 = self.pos - _tmp = _Newline() - _tmp = _tmp ? nil : true - self.pos = _save2 - unless _tmp - self.pos = _save - break + break if _tmp + self.pos = _save7 + break + end # end choice + + break unless _tmp + end + _tmp = true + else + self.pos = _save2 end - _tmp = apply(:_Inline) - a = @result unless _tmp self.pos = _save break end - _tmp = match_string("**") + _tmp = match_string("_") unless _tmp self.pos = _save break end - @result = begin; a ; end + @result = begin; emphasis a.join ; end _tmp = true unless _tmp self.pos = _save @@ -10444,16 +10527,42 @@ class RDoc::Markdown break end # end sequence - set_failed_rule :_TwoStarClose unless _tmp + set_failed_rule :_EmphUl unless _tmp + return _tmp + end + + # Strong = (StrongStar | StrongUl) + def _Strong + + _save = self.pos + while true # choice + _tmp = apply(:_StrongStar) + break if _tmp + self.pos = _save + _tmp = apply(:_StrongUl) + break if _tmp + self.pos = _save + break + end # end choice + + set_failed_rule :_Strong unless _tmp return _tmp end - # StrongStar = TwoStarOpen @StartList:a (!TwoStarClose Inline:l { a << l })* TwoStarClose:l { a << l } { strong a.join } + # StrongStar = "**" !@Whitespace @StartList:a (!"**" Inline:b { a << b })+ "**" { strong a.join } def _StrongStar _save = self.pos while true # sequence - _tmp = apply(:_TwoStarOpen) + _tmp = match_string("**") + unless _tmp + self.pos = _save + break + end + _save1 = self.pos + _tmp = _Whitespace() + _tmp = _tmp ? nil : true + self.pos = _save1 unless _tmp self.pos = _save break @@ -10464,47 +10573,70 @@ class RDoc::Markdown self.pos = _save break end - while true + _save2 = self.pos - _save2 = self.pos - while true # sequence - _save3 = self.pos - _tmp = apply(:_TwoStarClose) - _tmp = _tmp ? nil : true + _save3 = self.pos + while true # sequence + _save4 = self.pos + _tmp = match_string("**") + _tmp = _tmp ? nil : true + self.pos = _save4 + unless _tmp self.pos = _save3 - unless _tmp - self.pos = _save2 - break - end - _tmp = apply(:_Inline) - l = @result - unless _tmp - self.pos = _save2 - break - end - @result = begin; a << l ; end - _tmp = true - unless _tmp - self.pos = _save2 - end break - end # end sequence - - break unless _tmp - end - _tmp = true - unless _tmp - self.pos = _save + end + _tmp = apply(:_Inline) + b = @result + unless _tmp + self.pos = _save3 + break + end + @result = begin; a << b ; end + _tmp = true + unless _tmp + self.pos = _save3 + end break + end # end sequence + + if _tmp + while true + + _save5 = self.pos + while true # sequence + _save6 = self.pos + _tmp = match_string("**") + _tmp = _tmp ? nil : true + self.pos = _save6 + unless _tmp + self.pos = _save5 + break + end + _tmp = apply(:_Inline) + b = @result + unless _tmp + self.pos = _save5 + break + end + @result = begin; a << b ; end + _tmp = true + unless _tmp + self.pos = _save5 + end + break + end # end sequence + + break unless _tmp + end + _tmp = true + else + self.pos = _save2 end - _tmp = apply(:_TwoStarClose) - l = @result unless _tmp self.pos = _save break end - @result = begin; a << l ; end - _tmp = true + _tmp = match_string("**") unless _tmp self.pos = _save break @@ -10521,69 +10653,89 @@ class RDoc::Markdown return _tmp end - # TwoUlOpen = !UlLine "__" !@Spacechar !@Newline - def _TwoUlOpen + # StrongUl = "__" !@Whitespace @StartList:a (!"__" Inline:b { a << b })+ "__" { strong a.join } + def _StrongUl _save = self.pos while true # sequence - _save1 = self.pos - _tmp = apply(:_UlLine) - _tmp = _tmp ? nil : true - self.pos = _save1 - unless _tmp - self.pos = _save - break - end _tmp = match_string("__") unless _tmp self.pos = _save break end - _save2 = self.pos - _tmp = _Spacechar() + _save1 = self.pos + _tmp = _Whitespace() _tmp = _tmp ? nil : true - self.pos = _save2 + self.pos = _save1 unless _tmp self.pos = _save break end - _save3 = self.pos - _tmp = _Newline() - _tmp = _tmp ? nil : true - self.pos = _save3 - unless _tmp - self.pos = _save - end - break - end # end sequence - - set_failed_rule :_TwoUlOpen unless _tmp - return _tmp - end - - # TwoUlClose = !@Spacechar !@Newline Inline:a "__" { a } - def _TwoUlClose - - _save = self.pos - while true # sequence - _save1 = self.pos - _tmp = _Spacechar() - _tmp = _tmp ? nil : true - self.pos = _save1 + _tmp = _StartList() + a = @result unless _tmp self.pos = _save break end _save2 = self.pos - _tmp = _Newline() - _tmp = _tmp ? nil : true - self.pos = _save2 - unless _tmp - self.pos = _save + + _save3 = self.pos + while true # sequence + _save4 = self.pos + _tmp = match_string("__") + _tmp = _tmp ? nil : true + self.pos = _save4 + unless _tmp + self.pos = _save3 + break + end + _tmp = apply(:_Inline) + b = @result + unless _tmp + self.pos = _save3 + break + end + @result = begin; a << b ; end + _tmp = true + unless _tmp + self.pos = _save3 + end break + end # end sequence + + if _tmp + while true + + _save5 = self.pos + while true # sequence + _save6 = self.pos + _tmp = match_string("__") + _tmp = _tmp ? nil : true + self.pos = _save6 + unless _tmp + self.pos = _save5 + break + end + _tmp = apply(:_Inline) + b = @result + unless _tmp + self.pos = _save5 + break + end + @result = begin; a << b ; end + _tmp = true + unless _tmp + self.pos = _save5 + end + break + end # end sequence + + break unless _tmp + end + _tmp = true + else + self.pos = _save2 end - _tmp = apply(:_Inline) - a = @result unless _tmp self.pos = _save break @@ -10593,7 +10745,7 @@ class RDoc::Markdown self.pos = _save break end - @result = begin; a ; end + @result = begin; strong a.join ; end _tmp = true unless _tmp self.pos = _save @@ -10601,72 +10753,110 @@ class RDoc::Markdown break end # end sequence - set_failed_rule :_TwoUlClose unless _tmp + set_failed_rule :_StrongUl unless _tmp return _tmp end - # StrongUl = TwoUlOpen @StartList:a (!TwoUlClose Inline:i { a << i })* TwoUlClose:l { a << l } { strong a.join } - def _StrongUl + # Strike = &{ strike? } "~~" !@Whitespace @StartList:a (!"~~" Inline:b { a << b })+ "~~" { strike a.join } + def _Strike _save = self.pos while true # sequence - _tmp = apply(:_TwoUlOpen) + _save1 = self.pos + _tmp = begin; strike? ; end + self.pos = _save1 unless _tmp self.pos = _save break end - _tmp = _StartList() - a = @result + _tmp = match_string("~~") unless _tmp self.pos = _save break end - while true - - _save2 = self.pos - while true # sequence - _save3 = self.pos - _tmp = apply(:_TwoUlClose) - _tmp = _tmp ? nil : true - self.pos = _save3 - unless _tmp - self.pos = _save2 - break - end - _tmp = apply(:_Inline) - i = @result - unless _tmp - self.pos = _save2 - break - end - @result = begin; a << i ; end - _tmp = true - unless _tmp - self.pos = _save2 - end - break - end # end sequence - - break unless _tmp + _save2 = self.pos + _tmp = _Whitespace() + _tmp = _tmp ? nil : true + self.pos = _save2 + unless _tmp + self.pos = _save + break end - _tmp = true + _tmp = _StartList() + a = @result unless _tmp self.pos = _save break end - _tmp = apply(:_TwoUlClose) - l = @result + _save3 = self.pos + + _save4 = self.pos + while true # sequence + _save5 = self.pos + _tmp = match_string("~~") + _tmp = _tmp ? nil : true + self.pos = _save5 + unless _tmp + self.pos = _save4 + break + end + _tmp = apply(:_Inline) + b = @result + unless _tmp + self.pos = _save4 + break + end + @result = begin; a << b ; end + _tmp = true + unless _tmp + self.pos = _save4 + end + break + end # end sequence + + if _tmp + while true + + _save6 = self.pos + while true # sequence + _save7 = self.pos + _tmp = match_string("~~") + _tmp = _tmp ? nil : true + self.pos = _save7 + unless _tmp + self.pos = _save6 + break + end + _tmp = apply(:_Inline) + b = @result + unless _tmp + self.pos = _save6 + break + end + @result = begin; a << b ; end + _tmp = true + unless _tmp + self.pos = _save6 + end + break + end # end sequence + + break unless _tmp + end + _tmp = true + else + self.pos = _save3 + end unless _tmp self.pos = _save break end - @result = begin; a << l ; end - _tmp = true + _tmp = match_string("~~") unless _tmp self.pos = _save break end - @result = begin; strong a.join ; end + @result = begin; strike a.join ; end _tmp = true unless _tmp self.pos = _save @@ -10674,7 +10864,7 @@ class RDoc::Markdown break end # end sequence - set_failed_rule :_StrongUl unless _tmp + set_failed_rule :_Strike unless _tmp return _tmp end @@ -10853,7 +11043,7 @@ class RDoc::Markdown return _tmp end - # ExplicitLink = Label:l Spnl "(" @Sp Source:s Spnl Title @Sp ")" { "{#{l}}[#{s}]" } + # ExplicitLink = Label:l "(" @Sp Source:s Spnl Title @Sp ")" { "{#{l}}[#{s}]" } def _ExplicitLink _save = self.pos @@ -10864,11 +11054,6 @@ class RDoc::Markdown self.pos = _save break end - _tmp = apply(:_Spnl) - unless _tmp - self.pos = _save - break - end _tmp = match_string("(") unless _tmp self.pos = _save @@ -10977,130 +11162,119 @@ class RDoc::Markdown return _tmp end - # SourceContents = (((!"(" !")" !">" Nonspacechar)+ | "(" SourceContents ")")* | "") + # SourceContents = ((!"(" !")" !">" Nonspacechar)+ | "(" SourceContents ")")* def _SourceContents + while true - _save = self.pos - while true # choice - while true - + _save1 = self.pos + while true # choice _save2 = self.pos - while true # choice - _save3 = self.pos + _save3 = self.pos + while true # sequence _save4 = self.pos - while true # sequence - _save5 = self.pos - _tmp = match_string("(") - _tmp = _tmp ? nil : true - self.pos = _save5 - unless _tmp - self.pos = _save4 - break - end - _save6 = self.pos - _tmp = match_string(")") - _tmp = _tmp ? nil : true - self.pos = _save6 - unless _tmp - self.pos = _save4 - break - end - _save7 = self.pos - _tmp = match_string(">") - _tmp = _tmp ? nil : true - self.pos = _save7 - unless _tmp - self.pos = _save4 - break - end - _tmp = apply(:_Nonspacechar) - unless _tmp - self.pos = _save4 - end + _tmp = match_string("(") + _tmp = _tmp ? nil : true + self.pos = _save4 + unless _tmp + self.pos = _save3 break - end # end sequence + end + _save5 = self.pos + _tmp = match_string(")") + _tmp = _tmp ? nil : true + self.pos = _save5 + unless _tmp + self.pos = _save3 + break + end + _save6 = self.pos + _tmp = match_string(">") + _tmp = _tmp ? nil : true + self.pos = _save6 + unless _tmp + self.pos = _save3 + break + end + _tmp = apply(:_Nonspacechar) + unless _tmp + self.pos = _save3 + end + break + end # end sequence - if _tmp - while true + if _tmp + while true + _save7 = self.pos + while true # sequence _save8 = self.pos - while true # sequence - _save9 = self.pos - _tmp = match_string("(") - _tmp = _tmp ? nil : true - self.pos = _save9 - unless _tmp - self.pos = _save8 - break - end - _save10 = self.pos - _tmp = match_string(")") - _tmp = _tmp ? nil : true - self.pos = _save10 - unless _tmp - self.pos = _save8 - break - end - _save11 = self.pos - _tmp = match_string(">") - _tmp = _tmp ? nil : true - self.pos = _save11 - unless _tmp - self.pos = _save8 - break - end - _tmp = apply(:_Nonspacechar) - unless _tmp - self.pos = _save8 - end + _tmp = match_string("(") + _tmp = _tmp ? nil : true + self.pos = _save8 + unless _tmp + self.pos = _save7 break - end # end sequence + end + _save9 = self.pos + _tmp = match_string(")") + _tmp = _tmp ? nil : true + self.pos = _save9 + unless _tmp + self.pos = _save7 + break + end + _save10 = self.pos + _tmp = match_string(">") + _tmp = _tmp ? nil : true + self.pos = _save10 + unless _tmp + self.pos = _save7 + break + end + _tmp = apply(:_Nonspacechar) + unless _tmp + self.pos = _save7 + end + break + end # end sequence - break unless _tmp - end - _tmp = true - else - self.pos = _save3 + break unless _tmp end - break if _tmp + _tmp = true + else self.pos = _save2 + end + break if _tmp + self.pos = _save1 - _save12 = self.pos - while true # sequence - _tmp = match_string("(") - unless _tmp - self.pos = _save12 - break - end - _tmp = apply(:_SourceContents) - unless _tmp - self.pos = _save12 - break - end - _tmp = match_string(")") - unless _tmp - self.pos = _save12 - end + _save11 = self.pos + while true # sequence + _tmp = match_string("(") + unless _tmp + self.pos = _save11 break - end # end sequence - - break if _tmp - self.pos = _save2 + end + _tmp = apply(:_SourceContents) + unless _tmp + self.pos = _save11 + break + end + _tmp = match_string(")") + unless _tmp + self.pos = _save11 + end break - end # end choice + end # end sequence - break unless _tmp - end - _tmp = true - break if _tmp - self.pos = _save - _tmp = match_string("") - break if _tmp - self.pos = _save - break - end # end choice + break if _tmp + self.pos = _save1 + break + end # end choice + break unless _tmp + end + _tmp = true set_failed_rule :_SourceContents unless _tmp return _tmp end @@ -14357,12 +14531,12 @@ class RDoc::Markdown return _tmp end - # SpecialChar = (/[*_`&\[\]() { text.length }") - Rules[:_AtxHeading] = rule_info("AtxHeading", "AtxStart:s @Sp? AtxInline+:a (@Sp? /\#*/ @Sp)? @Newline { RDoc::Markup::Heading.new(s, a.join) }") + Rules[:_AtxHeading] = rule_info("AtxHeading", "AtxStart:s @Sp AtxInline+:a (@Sp /\#*/ @Sp)? @Newline { RDoc::Markup::Heading.new(s, a.join) }") Rules[:_SetextHeading] = rule_info("SetextHeading", "(SetextHeading1 | SetextHeading2)") - Rules[:_SetextBottom1] = rule_info("SetextBottom1", "/={3,}/ @Newline") - Rules[:_SetextBottom2] = rule_info("SetextBottom2", "/-{3,}/ @Newline") - Rules[:_SetextHeading1] = rule_info("SetextHeading1", "&(@RawLine SetextBottom1) @StartList:a (!@Endline Inline:b { a << b })+ @Sp? @Newline SetextBottom1 { RDoc::Markup::Heading.new(1, a.join) }") - Rules[:_SetextHeading2] = rule_info("SetextHeading2", "&(@RawLine SetextBottom2) @StartList:a (!@Endline Inline:b { a << b })+ @Sp? @Newline SetextBottom2 { RDoc::Markup::Heading.new(2, a.join) }") + Rules[:_SetextBottom1] = rule_info("SetextBottom1", "/={1,}/ @Newline") + Rules[:_SetextBottom2] = rule_info("SetextBottom2", "/-{1,}/ @Newline") + Rules[:_SetextHeading1] = rule_info("SetextHeading1", "&(@RawLine SetextBottom1) @StartList:a (!@Endline Inline:b { a << b })+ @Sp @Newline SetextBottom1 { RDoc::Markup::Heading.new(1, a.join) }") + Rules[:_SetextHeading2] = rule_info("SetextHeading2", "&(@RawLine SetextBottom2) @StartList:a (!@Endline Inline:b { a << b })+ @Sp @Newline SetextBottom2 { RDoc::Markup::Heading.new(2, a.join) }") Rules[:_Heading] = rule_info("Heading", "(SetextHeading | AtxHeading)") Rules[:_BlockQuote] = rule_info("BlockQuote", "BlockQuoteRaw:a { RDoc::Markup::BlockQuote.new(*a) }") Rules[:_BlockQuoteRaw] = rule_info("BlockQuoteRaw", "@StartList:a (\">\" \" \"? Line:l { a << l } (!\">\" !@BlankLine Line:c { a << c })* (@BlankLine:n { a << n })*)+ { inner_parse a.join }") @@ -16010,7 +16176,10 @@ class RDoc::Markdown Rules[:_HtmlBlockOpenScript] = rule_info("HtmlBlockOpenScript", "\"<\" Spnl (\"script\" | \"SCRIPT\") Spnl HtmlAttribute* \">\"") Rules[:_HtmlBlockCloseScript] = rule_info("HtmlBlockCloseScript", "\"<\" Spnl \"/\" (\"script\" | \"SCRIPT\") Spnl \">\"") Rules[:_HtmlBlockScript] = rule_info("HtmlBlockScript", "HtmlBlockOpenScript (!HtmlBlockCloseScript .)* HtmlBlockCloseScript") - Rules[:_HtmlBlockInTags] = rule_info("HtmlBlockInTags", "(HtmlAnchor | HtmlBlockAddress | HtmlBlockBlockquote | HtmlBlockCenter | HtmlBlockDir | HtmlBlockDiv | HtmlBlockDl | HtmlBlockFieldset | HtmlBlockForm | HtmlBlockH1 | HtmlBlockH2 | HtmlBlockH3 | HtmlBlockH4 | HtmlBlockH5 | HtmlBlockH6 | HtmlBlockMenu | HtmlBlockNoframes | HtmlBlockNoscript | HtmlBlockOl | HtmlBlockP | HtmlBlockPre | HtmlBlockTable | HtmlBlockUl | HtmlBlockDd | HtmlBlockDt | HtmlBlockFrameset | HtmlBlockLi | HtmlBlockTbody | HtmlBlockTd | HtmlBlockTfoot | HtmlBlockTh | HtmlBlockThead | HtmlBlockTr | HtmlBlockScript)") + Rules[:_HtmlBlockOpenHead] = rule_info("HtmlBlockOpenHead", "\"<\" Spnl (\"head\" | \"HEAD\") Spnl HtmlAttribute* \">\"") + Rules[:_HtmlBlockCloseHead] = rule_info("HtmlBlockCloseHead", "\"<\" Spnl \"/\" (\"head\" | \"HEAD\") Spnl \">\"") + Rules[:_HtmlBlockHead] = rule_info("HtmlBlockHead", "HtmlBlockOpenHead (!HtmlBlockCloseHead .)* HtmlBlockCloseHead") + Rules[:_HtmlBlockInTags] = rule_info("HtmlBlockInTags", "(HtmlAnchor | HtmlBlockAddress | HtmlBlockBlockquote | HtmlBlockCenter | HtmlBlockDir | HtmlBlockDiv | HtmlBlockDl | HtmlBlockFieldset | HtmlBlockForm | HtmlBlockH1 | HtmlBlockH2 | HtmlBlockH3 | HtmlBlockH4 | HtmlBlockH5 | HtmlBlockH6 | HtmlBlockMenu | HtmlBlockNoframes | HtmlBlockNoscript | HtmlBlockOl | HtmlBlockP | HtmlBlockPre | HtmlBlockTable | HtmlBlockUl | HtmlBlockDd | HtmlBlockDt | HtmlBlockFrameset | HtmlBlockLi | HtmlBlockTbody | HtmlBlockTd | HtmlBlockTfoot | HtmlBlockTh | HtmlBlockThead | HtmlBlockTr | HtmlBlockScript | HtmlBlockHead)") Rules[:_HtmlBlock] = rule_info("HtmlBlock", "< (HtmlBlockInTags | HtmlComment | HtmlBlockSelfClosing | HtmlUnclosed) > @BlankLine+ { if html? then RDoc::Markup::Raw.new text end }") Rules[:_HtmlUnclosed] = rule_info("HtmlUnclosed", "\"<\" Spnl HtmlUnclosedType Spnl HtmlAttribute* Spnl \">\"") Rules[:_HtmlUnclosedType] = rule_info("HtmlUnclosedType", "(\"HR\" | \"hr\")") @@ -16021,14 +16190,14 @@ class RDoc::Markdown Rules[:_InStyleTags] = rule_info("InStyleTags", "StyleOpen (!StyleClose .)* StyleClose") Rules[:_StyleBlock] = rule_info("StyleBlock", "< InStyleTags > @BlankLine* { if css? then RDoc::Markup::Raw.new text end }") Rules[:_Inlines] = rule_info("Inlines", "(!@Endline Inline:i { i } | @Endline:c &Inline { c })+:chunks @Endline? { chunks }") - Rules[:_Inline] = rule_info("Inline", "(Str | @Endline | UlOrStarLine | @Space | Strong | Emph | Image | Link | NoteReference | InlineNote | Code | RawHtml | Entity | EscapedChar | Symbol)") + Rules[:_Inline] = rule_info("Inline", "(Str | @Endline | UlOrStarLine | @Space | Strong | Emph | Strike | Image | Link | NoteReference | InlineNote | Code | RawHtml | Entity | EscapedChar | Symbol)") Rules[:_Space] = rule_info("Space", "@Spacechar+ { \" \" }") Rules[:_Str] = rule_info("Str", "@StartList:a < @NormalChar+ > { a = text } (StrChunk:c { a << c })* { a }") Rules[:_StrChunk] = rule_info("StrChunk", "< (@NormalChar | /_+/ &Alphanumeric)+ > { text }") Rules[:_EscapedChar] = rule_info("EscapedChar", "\"\\\\\" !@Newline < /[:\\\\`|*_{}\\[\\]()\#+.!><-]/ > { text }") Rules[:_Entity] = rule_info("Entity", "(HexEntity | DecEntity | CharEntity):a { a }") Rules[:_Endline] = rule_info("Endline", "(@LineBreak | @TerminalEndline | @NormalEndline)") - Rules[:_NormalEndline] = rule_info("NormalEndline", "@Sp @Newline !@BlankLine !\">\" !AtxStart !(Line /={3,}|-{3,}=/ @Newline) { \"\\n\" }") + Rules[:_NormalEndline] = rule_info("NormalEndline", "@Sp @Newline !@BlankLine !\">\" !AtxStart !(Line /={1,}|-{1,}/ @Newline) { \"\\n\" }") Rules[:_TerminalEndline] = rule_info("TerminalEndline", "@Sp @Newline @Eof") Rules[:_LineBreak] = rule_info("LineBreak", "\" \" @NormalEndline { RDoc::Markup::HardBreak.new }") Rules[:_Symbol] = rule_info("Symbol", "< @SpecialChar > { text }") @@ -16036,27 +16205,21 @@ class RDoc::Markdown Rules[:_StarLine] = rule_info("StarLine", "(< /\\*{4,}/ > { text } | < @Spacechar /\\*+/ &@Spacechar > { text })") Rules[:_UlLine] = rule_info("UlLine", "(< /_{4,}/ > { text } | < @Spacechar /_+/ &@Spacechar > { text })") Rules[:_Emph] = rule_info("Emph", "(EmphStar | EmphUl)") - Rules[:_OneStarOpen] = rule_info("OneStarOpen", "!StarLine \"*\" !@Spacechar !@Newline") - Rules[:_OneStarClose] = rule_info("OneStarClose", "!@Spacechar !@Newline Inline:a \"*\" { a }") - Rules[:_EmphStar] = rule_info("EmphStar", "OneStarOpen @StartList:a (!OneStarClose Inline:l { a << l })* OneStarClose:l { a << l } { emphasis a.join }") - Rules[:_OneUlOpen] = rule_info("OneUlOpen", "!UlLine \"_\" !@Spacechar !@Newline") - Rules[:_OneUlClose] = rule_info("OneUlClose", "!@Spacechar !@Newline Inline:a \"_\" { a }") - Rules[:_EmphUl] = rule_info("EmphUl", "OneUlOpen @StartList:a (!OneUlClose Inline:l { a << l })* OneUlClose:l { a << l } { emphasis a.join }") + Rules[:_Whitespace] = rule_info("Whitespace", "(@Spacechar | @Newline)") + Rules[:_EmphStar] = rule_info("EmphStar", "\"*\" !@Whitespace @StartList:a (!\"*\" Inline:b { a << b } | StrongStar:b { a << b })+ \"*\" { emphasis a.join }") + Rules[:_EmphUl] = rule_info("EmphUl", "\"_\" !@Whitespace @StartList:a (!\"_\" Inline:b { a << b } | StrongUl:b { a << b })+ \"_\" { emphasis a.join }") Rules[:_Strong] = rule_info("Strong", "(StrongStar | StrongUl)") - Rules[:_TwoStarOpen] = rule_info("TwoStarOpen", "!StarLine \"**\" !@Spacechar !@Newline") - Rules[:_TwoStarClose] = rule_info("TwoStarClose", "!@Spacechar !@Newline Inline:a \"**\" { a }") - Rules[:_StrongStar] = rule_info("StrongStar", "TwoStarOpen @StartList:a (!TwoStarClose Inline:l { a << l })* TwoStarClose:l { a << l } { strong a.join }") - Rules[:_TwoUlOpen] = rule_info("TwoUlOpen", "!UlLine \"__\" !@Spacechar !@Newline") - Rules[:_TwoUlClose] = rule_info("TwoUlClose", "!@Spacechar !@Newline Inline:a \"__\" { a }") - Rules[:_StrongUl] = rule_info("StrongUl", "TwoUlOpen @StartList:a (!TwoUlClose Inline:i { a << i })* TwoUlClose:l { a << l } { strong a.join }") + Rules[:_StrongStar] = rule_info("StrongStar", "\"**\" !@Whitespace @StartList:a (!\"**\" Inline:b { a << b })+ \"**\" { strong a.join }") + Rules[:_StrongUl] = rule_info("StrongUl", "\"__\" !@Whitespace @StartList:a (!\"__\" Inline:b { a << b })+ \"__\" { strong a.join }") + Rules[:_Strike] = rule_info("Strike", "&{ strike? } \"~~\" !@Whitespace @StartList:a (!\"~~\" Inline:b { a << b })+ \"~~\" { strike a.join }") Rules[:_Image] = rule_info("Image", "\"!\" (ExplicitLink | ReferenceLink):a { \"rdoc-image:\#{a[/\\[(.*)\\]/, 1]}\" }") Rules[:_Link] = rule_info("Link", "(ExplicitLink | ReferenceLink | AutoLink)") Rules[:_ReferenceLink] = rule_info("ReferenceLink", "(ReferenceLinkDouble | ReferenceLinkSingle)") Rules[:_ReferenceLinkDouble] = rule_info("ReferenceLinkDouble", "Label:content < Spnl > !\"[]\" Label:label { link_to content, label, text }") Rules[:_ReferenceLinkSingle] = rule_info("ReferenceLinkSingle", "Label:content < (Spnl \"[]\")? > { link_to content, content, text }") - Rules[:_ExplicitLink] = rule_info("ExplicitLink", "Label:l Spnl \"(\" @Sp Source:s Spnl Title @Sp \")\" { \"{\#{l}}[\#{s}]\" }") + Rules[:_ExplicitLink] = rule_info("ExplicitLink", "Label:l \"(\" @Sp Source:s Spnl Title @Sp \")\" { \"{\#{l}}[\#{s}]\" }") Rules[:_Source] = rule_info("Source", "(\"<\" < SourceContents > \">\" | < SourceContents >) { text }") - Rules[:_SourceContents] = rule_info("SourceContents", "(((!\"(\" !\")\" !\">\" Nonspacechar)+ | \"(\" SourceContents \")\")* | \"\")") + Rules[:_SourceContents] = rule_info("SourceContents", "((!\"(\" !\")\" !\">\" Nonspacechar)+ | \"(\" SourceContents \")\")*") Rules[:_Title] = rule_info("Title", "(TitleSingle | TitleDouble | \"\"):a { a }") Rules[:_TitleSingle] = rule_info("TitleSingle", "\"'\" (!(\"'\" @Sp (\")\" | @Newline)) .)* \"'\"") Rules[:_TitleDouble] = rule_info("TitleDouble", "\"\\\"\" (!(\"\\\"\" @Sp (\")\" | @Newline)) .)* \"\\\"\"") @@ -16088,14 +16251,13 @@ class RDoc::Markdown Rules[:_Nonspacechar] = rule_info("Nonspacechar", "!@Spacechar !@Newline .") Rules[:_Sp] = rule_info("Sp", "@Spacechar*") Rules[:_Spnl] = rule_info("Spnl", "@Sp (@Newline @Sp)?") - Rules[:_SpecialChar] = rule_info("SpecialChar", "(/[*_`&\\[\\]() \";\" { [text.to_i(16)].pack 'U' }") Rules[:_DecEntity] = rule_info("DecEntity", "\"&\#\" < /[0-9]+/ > \";\" { [text.to_i].pack 'U' }") @@ -16112,7 +16274,7 @@ class RDoc::Markdown Rules[:_NoteReference] = rule_info("NoteReference", "&{ notes? } RawNoteReference:ref { note_for ref }") Rules[:_RawNoteReference] = rule_info("RawNoteReference", "\"[^\" < (!@Newline !\"]\" .)+ > \"]\" { text }") Rules[:_Note] = rule_info("Note", "&{ notes? } @NonindentSpace RawNoteReference:ref \":\" @Sp @StartList:a RawNoteBlock:i { a.concat i } (&Indent RawNoteBlock:i { a.concat i })* { @footnotes[ref] = paragraph a nil }") - Rules[:_InlineNote] = rule_info("InlineNote", "&{ notes? } \"^[\" @StartList:a (!\"]\" Inline:l { a << l })+ \"]\" { ref = [:inline, @note_order.length] @footnotes[ref] = paragraph a note_for ref }") + Rules[:_InlineNote] = rule_info("InlineNote", "&{ notes? } \"^[\" @StartList:a (!\"]\" Inline:l { a << l })+ \"]\" { ref = [:inline, @note_order.length] @footnotes[ref] = paragraph a note_for ref }") Rules[:_Notes] = rule_info("Notes", "(Note | SkipBlock)*") Rules[:_RawNoteBlock] = rule_info("RawNoteBlock", "@StartList:a (!@BlankLine OptionallyIndentedLine:l { a << l })+ < @BlankLine* > { a << text } { a }") Rules[:_CodeFence] = rule_info("CodeFence", "&{ github? } Ticks3 (@Sp StrChunk:format)? Spnl < ((!\"`\" Nonspacechar)+ | !Ticks3 /`+/ | Spacechar | @Newline)+ > Ticks3 @Sp @Newline* { verbatim = RDoc::Markup::Verbatim.new text verbatim.format = format.intern if format.instance_of?(String) verbatim }") diff --git a/lib/rdoc/markdown/entities.rb b/lib/rdoc/markdown/entities.rb index d32ae51053..d2cf610293 100644 --- a/lib/rdoc/markdown/entities.rb +++ b/lib/rdoc/markdown/entities.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # HTML entity name map for RDoc::Markdown diff --git a/lib/rdoc/markdown/literals.rb b/lib/rdoc/markdown/literals.rb index b6bb89e0c6..cd4cb52335 100644 --- a/lib/rdoc/markdown/literals.rb +++ b/lib/rdoc/markdown/literals.rb @@ -1,5 +1,4 @@ # coding: UTF-8 -# frozen_string_literal: false # :markup: markdown ## @@ -183,14 +182,26 @@ class RDoc::Markdown::Literals return nil end - def get_byte - if @pos >= @string_size - return nil + if "".respond_to? :ord + def get_byte + if @pos >= @string_size + return nil + end + + s = @string[@pos].ord + @pos += 1 + s end + else + def get_byte + if @pos >= @string_size + return nil + end - s = @string[@pos].ord - @pos += 1 - s + s = @string[@pos] + @pos += 1 + s + end end def parse(rule=nil) diff --git a/lib/rdoc/markup.rb b/lib/rdoc/markup.rb index 982bc13e88..08ecc6f7df 100644 --- a/lib/rdoc/markup.rb +++ b/lib/rdoc/markup.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # RDoc::Markup parses plain text documents and attempts to decompose them into # their constituent parts. Some of these parts are high-level: paragraphs, diff --git a/lib/rdoc/markup/attr_changer.rb b/lib/rdoc/markup/attr_changer.rb index 9a1a9c8c66..4c4bc6479e 100644 --- a/lib/rdoc/markup/attr_changer.rb +++ b/lib/rdoc/markup/attr_changer.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true class RDoc::Markup AttrChanger = Struct.new :turn_on, :turn_off # :nodoc: diff --git a/lib/rdoc/markup/attr_span.rb b/lib/rdoc/markup/attr_span.rb index 4d9e5b0217..63aace60d2 100644 --- a/lib/rdoc/markup/attr_span.rb +++ b/lib/rdoc/markup/attr_span.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # An array of attributes which parallels the characters in a string. diff --git a/lib/rdoc/markup/attribute_manager.rb b/lib/rdoc/markup/attribute_manager.rb index 3296d17af2..a10f731615 100644 --- a/lib/rdoc/markup/attribute_manager.rb +++ b/lib/rdoc/markup/attribute_manager.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # Manages changes of attributes in a block of text @@ -246,7 +246,7 @@ class RDoc::Markup::AttributeManager # Processes +str+ converting attributes, HTML and specials def flow str - @str = str + @str = str.dup mask_protected_sequences diff --git a/lib/rdoc/markup/attributes.rb b/lib/rdoc/markup/attributes.rb index 8776c4ed29..ec30160d3d 100644 --- a/lib/rdoc/markup/attributes.rb +++ b/lib/rdoc/markup/attributes.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # We manage a set of attributes. Each attribute has a symbol name and a bit # value. diff --git a/lib/rdoc/markup/blank_line.rb b/lib/rdoc/markup/blank_line.rb index 2b1ab91b47..3129ab5e7f 100644 --- a/lib/rdoc/markup/blank_line.rb +++ b/lib/rdoc/markup/blank_line.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # An empty line. This class is a singleton. diff --git a/lib/rdoc/markup/block_quote.rb b/lib/rdoc/markup/block_quote.rb index 3be022f9dd..7a4b3e36b0 100644 --- a/lib/rdoc/markup/block_quote.rb +++ b/lib/rdoc/markup/block_quote.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # A quoted section which contains markup items. diff --git a/lib/rdoc/markup/document.rb b/lib/rdoc/markup/document.rb index 0692c3522f..f3a5de1fc3 100644 --- a/lib/rdoc/markup/document.rb +++ b/lib/rdoc/markup/document.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # A Document containing lists, headings, paragraphs, etc. diff --git a/lib/rdoc/markup/formatter.rb b/lib/rdoc/markup/formatter.rb index 197ff003e3..5dc71d2242 100644 --- a/lib/rdoc/markup/formatter.rb +++ b/lib/rdoc/markup/formatter.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # Base class for RDoc markup formatters # diff --git a/lib/rdoc/markup/formatter_test_case.rb b/lib/rdoc/markup/formatter_test_case.rb index a5b4933de4..076b7c81bb 100644 --- a/lib/rdoc/markup/formatter_test_case.rb +++ b/lib/rdoc/markup/formatter_test_case.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'minitest/unit' ## diff --git a/lib/rdoc/markup/hard_break.rb b/lib/rdoc/markup/hard_break.rb index 5898bfb644..046068d5c2 100644 --- a/lib/rdoc/markup/hard_break.rb +++ b/lib/rdoc/markup/hard_break.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # A hard-break in the middle of a paragraph. diff --git a/lib/rdoc/markup/heading.rb b/lib/rdoc/markup/heading.rb index 5229287d5b..233774c5c4 100644 --- a/lib/rdoc/markup/heading.rb +++ b/lib/rdoc/markup/heading.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # A heading with a level (1-6) and text diff --git a/lib/rdoc/markup/include.rb b/lib/rdoc/markup/include.rb index 891be71b85..ad7c4a9640 100644 --- a/lib/rdoc/markup/include.rb +++ b/lib/rdoc/markup/include.rb @@ -1,4 +1,4 @@ -# 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. diff --git a/lib/rdoc/markup/indented_paragraph.rb b/lib/rdoc/markup/indented_paragraph.rb index 56a96bd3c9..d42b2e52b8 100644 --- a/lib/rdoc/markup/indented_paragraph.rb +++ b/lib/rdoc/markup/indented_paragraph.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # An Indented Paragraph of text diff --git a/lib/rdoc/markup/inline.rb b/lib/rdoc/markup/inline.rb index 58072fef06..aba7ec21ce 100644 --- a/lib/rdoc/markup/inline.rb +++ b/lib/rdoc/markup/inline.rb @@ -1,2 +1,2 @@ -# frozen_string_literal: false +# frozen_string_literal: true warn "requiring rdoc/markup/inline is deprecated and will be removed in RDoc 4." if $-w diff --git a/lib/rdoc/markup/list.rb b/lib/rdoc/markup/list.rb index bcaea7d7c1..05c3609202 100644 --- a/lib/rdoc/markup/list.rb +++ b/lib/rdoc/markup/list.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # A List is a homogeneous set of ListItems. # diff --git a/lib/rdoc/markup/list_item.rb b/lib/rdoc/markup/list_item.rb index 115ec0412c..d22554ee73 100644 --- a/lib/rdoc/markup/list_item.rb +++ b/lib/rdoc/markup/list_item.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # An item within a List that contains paragraphs, headings, etc. # diff --git a/lib/rdoc/markup/paragraph.rb b/lib/rdoc/markup/paragraph.rb index fefa12f9ef..a2e45ef009 100644 --- a/lib/rdoc/markup/paragraph.rb +++ b/lib/rdoc/markup/paragraph.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # A Paragraph of text diff --git a/lib/rdoc/markup/parser.rb b/lib/rdoc/markup/parser.rb index 22cca20420..f08587e676 100644 --- a/lib/rdoc/markup/parser.rb +++ b/lib/rdoc/markup/parser.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'strscan' ## @@ -249,7 +249,7 @@ class RDoc::Markup::Parser min_indent = nil generate_leading_spaces = true - line = '' + line = ''.dup until @tokens.empty? do type, data, column, = get @@ -257,7 +257,7 @@ class RDoc::Markup::Parser if type == :NEWLINE then line << data verbatim << line - line = '' + line = ''.dup generate_leading_spaces = true next end diff --git a/lib/rdoc/markup/pre_process.rb b/lib/rdoc/markup/pre_process.rb index 6ce523be89..0ac7a41934 100644 --- a/lib/rdoc/markup/pre_process.rb +++ b/lib/rdoc/markup/pre_process.rb @@ -1,4 +1,4 @@ -# 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 # 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 @@ class RDoc::Markup::PreProcess handle_directive $1, $3, $5, code_object, text.encoding, &block end - comment = text unless comment + if comment then + comment.text = text + else + comment = text + end self.class.post_processors.each do |handler| handler.call comment, code_object @@ -150,7 +154,7 @@ class RDoc::Markup::PreProcess case directive when 'arg', 'args' then - return "#{prefix}:#{directive}: #{param}\n" unless code_object + return "#{prefix}:#{directive}: #{param}\n" unless code_object && code_object.kind_of?(RDoc::AnyMethod) code_object.params = param @@ -212,7 +216,7 @@ class RDoc::Markup::PreProcess when 'yield', 'yields' then return blankline unless code_object # remove parameter &block - code_object.params.sub!(/,?\s*&\w+/, '') if code_object.params + code_object.params = code_object.params.sub(/,?\s*&\w+/, '') if code_object.params code_object.block_params = param diff --git a/lib/rdoc/markup/raw.rb b/lib/rdoc/markup/raw.rb index 8012d2cea6..85e2c8b825 100644 --- a/lib/rdoc/markup/raw.rb +++ b/lib/rdoc/markup/raw.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # A section of text that is added to the output document as-is diff --git a/lib/rdoc/markup/rule.rb b/lib/rdoc/markup/rule.rb index b96d4fb293..38c1dc7f56 100644 --- a/lib/rdoc/markup/rule.rb +++ b/lib/rdoc/markup/rule.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # A horizontal rule with a weight diff --git a/lib/rdoc/markup/special.rb b/lib/rdoc/markup/special.rb index 4d834b9e37..57261b44a7 100644 --- a/lib/rdoc/markup/special.rb +++ b/lib/rdoc/markup/special.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # Hold details of a special sequence diff --git a/lib/rdoc/markup/text_formatter_test_case.rb b/lib/rdoc/markup/text_formatter_test_case.rb index 1c8882aa36..22a762b5f0 100644 --- a/lib/rdoc/markup/text_formatter_test_case.rb +++ b/lib/rdoc/markup/text_formatter_test_case.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # Test case for creating new plain-text RDoc::Markup formatters. See also # RDoc::Markup::FormatterTestCase diff --git a/lib/rdoc/markup/to_ansi.rb b/lib/rdoc/markup/to_ansi.rb index 56cd1fe446..6cc3b70e93 100644 --- a/lib/rdoc/markup/to_ansi.rb +++ b/lib/rdoc/markup/to_ansi.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # Outputs RDoc markup with vibrant ANSI color! diff --git a/lib/rdoc/markup/to_bs.rb b/lib/rdoc/markup/to_bs.rb index 9a1c7c6ccd..fea017e89d 100644 --- a/lib/rdoc/markup/to_bs.rb +++ b/lib/rdoc/markup/to_bs.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # Outputs RDoc markup with hot backspace action! You will probably need a # pager to use this output format. diff --git a/lib/rdoc/markup/to_html.rb b/lib/rdoc/markup/to_html.rb index d2c9a23a79..c5e1f073f8 100644 --- a/lib/rdoc/markup/to_html.rb +++ b/lib/rdoc/markup/to_html.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'cgi' ## diff --git a/lib/rdoc/markup/to_html_crossref.rb b/lib/rdoc/markup/to_html_crossref.rb index 3f03c65898..2911aee954 100644 --- a/lib/rdoc/markup/to_html_crossref.rb +++ b/lib/rdoc/markup/to_html_crossref.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # Subclass of the RDoc::Markup::ToHtml class that supports looking up method # names, classes, etc to create links. RDoc::CrossReference is used to diff --git a/lib/rdoc/markup/to_html_snippet.rb b/lib/rdoc/markup/to_html_snippet.rb index 75c1df94d9..24aa1d32d9 100644 --- a/lib/rdoc/markup/to_html_snippet.rb +++ b/lib/rdoc/markup/to_html_snippet.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # Outputs RDoc markup as paragraphs with inline markup only. diff --git a/lib/rdoc/markup/to_joined_paragraph.rb b/lib/rdoc/markup/to_joined_paragraph.rb index 293258c092..795f3f62ee 100644 --- a/lib/rdoc/markup/to_joined_paragraph.rb +++ b/lib/rdoc/markup/to_joined_paragraph.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # Joins the parts of an RDoc::Markup::Paragraph into a single String. # @@ -23,37 +23,11 @@ class RDoc::Markup::ToJoinedParagraph < RDoc::Markup::Formatter # Converts the parts of +paragraph+ to a single entry. def accept_paragraph paragraph - parts = [] - string = false - - paragraph.parts.each do |part| - if String === part then - if string then - string << part - else - parts << part - string = part - end - else - parts << part - string = false - end - end - - parts = parts.map do |part| - if String === part then - part.rstrip - else - part - end - end - - # TODO use Enumerable#chunk when Ruby 1.8 support is dropped - #parts = paragraph.parts.chunk do |part| - # String === part - #end.map do |string, chunk| - # string ? chunk.join.rstrip : chunk - #end.flatten + parts = paragraph.parts.chunk do |part| + String === part + end.map do |string, chunk| + string ? chunk.join.rstrip : chunk + end.flatten paragraph.parts.replace parts end diff --git a/lib/rdoc/markup/to_label.rb b/lib/rdoc/markup/to_label.rb index bdf08b7aee..9f179013f2 100644 --- a/lib/rdoc/markup/to_label.rb +++ b/lib/rdoc/markup/to_label.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'cgi' ## diff --git a/lib/rdoc/markup/to_markdown.rb b/lib/rdoc/markup/to_markdown.rb index 9074547b4c..d471032f9f 100644 --- a/lib/rdoc/markup/to_markdown.rb +++ b/lib/rdoc/markup/to_markdown.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true # :markup: markdown ## diff --git a/lib/rdoc/markup/to_rdoc.rb b/lib/rdoc/markup/to_rdoc.rb index a40c09859f..1cb4d6bab2 100644 --- a/lib/rdoc/markup/to_rdoc.rb +++ b/lib/rdoc/markup/to_rdoc.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # Outputs RDoc markup as RDoc markup! (mostly) diff --git a/lib/rdoc/markup/to_table_of_contents.rb b/lib/rdoc/markup/to_table_of_contents.rb index eae7c59d94..f68b90bcf6 100644 --- a/lib/rdoc/markup/to_table_of_contents.rb +++ b/lib/rdoc/markup/to_table_of_contents.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # Extracts just the RDoc::Markup::Heading elements from a # RDoc::Markup::Document to help build a table of contents diff --git a/lib/rdoc/markup/to_test.rb b/lib/rdoc/markup/to_test.rb index 7b1fa8c630..61d3cffaf0 100644 --- a/lib/rdoc/markup/to_test.rb +++ b/lib/rdoc/markup/to_test.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # This Markup outputter is used for testing purposes. diff --git a/lib/rdoc/markup/to_tt_only.rb b/lib/rdoc/markup/to_tt_only.rb index ba20fcdd00..4f43546e3d 100644 --- a/lib/rdoc/markup/to_tt_only.rb +++ b/lib/rdoc/markup/to_tt_only.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # Extracts sections of text enclosed in plus, tt or code. Used to discover # undocumented parameters. diff --git a/lib/rdoc/markup/verbatim.rb b/lib/rdoc/markup/verbatim.rb index a0b1d05928..7f1bc29a09 100644 --- a/lib/rdoc/markup/verbatim.rb +++ b/lib/rdoc/markup/verbatim.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # A section of verbatim text diff --git a/lib/rdoc/meta_method.rb b/lib/rdoc/meta_method.rb index 408c089dd1..7927a9ce9c 100644 --- a/lib/rdoc/meta_method.rb +++ b/lib/rdoc/meta_method.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # MetaMethod represents a meta-programmed method diff --git a/lib/rdoc/method_attr.rb b/lib/rdoc/method_attr.rb index 50eab141be..3cef78c4a5 100644 --- a/lib/rdoc/method_attr.rb +++ b/lib/rdoc/method_attr.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # Abstract class representing either a method or an attribute. @@ -188,7 +188,7 @@ class RDoc::MethodAttr < RDoc::CodeObject next if String === ancestor next if parent == ancestor - other = ancestor.find_method_named('#' << name) || + other = ancestor.find_method_named('#' + name) || ancestor.find_attribute_named(name) return other if other diff --git a/lib/rdoc/mixin.rb b/lib/rdoc/mixin.rb index 14f04c15e7..379d7cc526 100644 --- a/lib/rdoc/mixin.rb +++ b/lib/rdoc/mixin.rb @@ -1,4 +1,4 @@ -# 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. diff --git a/lib/rdoc/normal_class.rb b/lib/rdoc/normal_class.rb index eb53e964dd..6729b18448 100644 --- a/lib/rdoc/normal_class.rb +++ b/lib/rdoc/normal_class.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # A normal class, neither singleton nor anonymous @@ -47,9 +47,9 @@ class RDoc::NormalClass < RDoc::ClassModule def to_s # :nodoc: display = "#{self.class.name} #{self.full_name}" if superclass - display << ' < ' << (superclass.is_a?(String) ? superclass : superclass.full_name) + display += ' < ' + (superclass.is_a?(String) ? superclass : superclass.full_name) end - display << ' -> ' << is_alias_for.to_s if is_alias_for + display += ' -> ' + is_alias_for.to_s if is_alias_for display end diff --git a/lib/rdoc/normal_module.rb b/lib/rdoc/normal_module.rb index d046c8cbfe..8f364be41c 100644 --- a/lib/rdoc/normal_module.rb +++ b/lib/rdoc/normal_module.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # A normal module, like NormalClass diff --git a/lib/rdoc/options.rb b/lib/rdoc/options.rb index 60cfb5e553..17bbca81fe 100644 --- a/lib/rdoc/options.rb +++ b/lib/rdoc/options.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'optparse' require 'pathname' @@ -624,16 +624,16 @@ Usage: #{opt.program_name} [options] [names...] end parsers.sort.each do |parser, regexp| - opt.banner << " - #{parser}: #{regexp.join ', '}\n" + opt.banner += " - #{parser}: #{regexp.join ', '}\n" end - opt.banner << " - TomDoc: Only in ruby files\n" + opt.banner += " - TomDoc: Only in ruby files\n" - opt.banner << "\n The following options are deprecated:\n\n" + opt.banner += "\n The following options are deprecated:\n\n" name_length = DEPRECATED.keys.sort_by { |k| k.length }.last.length DEPRECATED.sort_by { |k,| k }.each do |name, reason| - opt.banner << " %*1$2$s %3$s\n" % [-name_length, name, reason] + opt.banner += " %*1$2$s %3$s\n" % [-name_length, name, reason] end opt.accept Template do |template| @@ -1087,7 +1087,7 @@ Usage: #{opt.program_name} [options] [names...] unless quiet then deprecated.each do |opt| - $stderr.puts 'option ' << opt << ' is deprecated: ' << DEPRECATED[opt] + $stderr.puts 'option ' + opt + ' is deprecated: ' + DEPRECATED[opt] end end diff --git a/lib/rdoc/parser.rb b/lib/rdoc/parser.rb index 823a6d014c..2b826d9284 100644 --- a/lib/rdoc/parser.rb +++ b/lib/rdoc/parser.rb @@ -1,5 +1,5 @@ # -*- coding: us-ascii -*- -# frozen_string_literal: false +# frozen_string_literal: true ## # A parser is simple a class that subclasses RDoc::Parser and implements #scan diff --git a/lib/rdoc/parser/c.rb b/lib/rdoc/parser/c.rb index 5c940ab28e..183538d54b 100644 --- a/lib/rdoc/parser/c.rb +++ b/lib/rdoc/parser/c.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'tsort' ## @@ -865,8 +865,8 @@ class RDoc::Parser::C < RDoc::Parser def handle_attr(var_name, attr_name, read, write) rw = '' - rw << 'R' if '1' == read - rw << 'W' if '1' == write + rw += 'R' if '1' == read + rw += 'W' if '1' == write class_name = @known_classes[var_name] @@ -982,8 +982,8 @@ class RDoc::Parser::C < RDoc::Parser if new_definition.empty? then # Default to literal C definition new_definition = definition else - new_definition.gsub!("\:", ":") - new_definition.gsub!("\\", '\\') + new_definition = new_definition.gsub("\:", ":") + new_definition = new_definition.gsub("\\", '\\') end new_definition.sub!(/\A(\s+)/, '') @@ -1237,7 +1237,7 @@ class RDoc::Parser::C < RDoc::Parser # when scanning for classes and methods def remove_commented_out_lines - @content.gsub!(%r%//.*rb_define_%, '//') + @content = @content.gsub(%r%//.*rb_define_%, '//') end ## diff --git a/lib/rdoc/parser/changelog.rb b/lib/rdoc/parser/changelog.rb index c6c2d2bb23..167892f543 100644 --- a/lib/rdoc/parser/changelog.rb +++ b/lib/rdoc/parser/changelog.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'time' ## @@ -29,13 +29,13 @@ class RDoc::Parser::ChangeLog < RDoc::Parser if last =~ /\)\s*\z/ and continuation =~ /\A\(/ then last.sub!(/\)\s*\z/, ',') - continuation.sub!(/\A\(/, '') + continuation = continuation.sub(/\A\(/, '') end if last =~ /\s\z/ then last << continuation else - last << ' ' << continuation + last << ' ' + continuation end end @@ -162,12 +162,12 @@ class RDoc::Parser::ChangeLog < RDoc::Parser entry_body = [] when /^(\t| {8})?\*\s*(.*)/ then # "\t* file.c (func): ..." - entry_body << $2 + entry_body << $2.dup when /^(\t| {8})?\s*(\(.*)/ then # "\t(func): ..." entry = $2 if entry_body.last =~ /:/ then - entry_body << entry + entry_body << entry.dup else continue_entry_body entry_body, entry end diff --git a/lib/rdoc/parser/markdown.rb b/lib/rdoc/parser/markdown.rb index feffb26ced..9ff478f872 100644 --- a/lib/rdoc/parser/markdown.rb +++ b/lib/rdoc/parser/markdown.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # Parse a Markdown format file. The parsed RDoc::Markup::Document is attached # as a file comment. diff --git a/lib/rdoc/parser/rd.rb b/lib/rdoc/parser/rd.rb index e6693b9ac8..25f5711731 100644 --- a/lib/rdoc/parser/rd.rb +++ b/lib/rdoc/parser/rd.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # Parse a RD format file. The parsed RDoc::Markup::Document is attached as a # file comment. diff --git a/lib/rdoc/parser/ripper_state_lex.rb b/lib/rdoc/parser/ripper_state_lex.rb index c9a0f5a21e..b7cec84bfc 100644 --- a/lib/rdoc/parser/ripper_state_lex.rb +++ b/lib/rdoc/parser/ripper_state_lex.rb @@ -1,6 +1,9 @@ require 'ripper' class RDoc::RipperStateLex + # TODO: Remove this constants after Ruby 2.4 EOL + RIPPER_HAS_LEX_STATE = Ripper::Filter.method_defined?(:state) + EXPR_NONE = 0 EXPR_BEG = 1 EXPR_END = 2 @@ -283,7 +286,22 @@ class RDoc::RipperStateLex @callback = block parse end - end + end unless RIPPER_HAS_LEX_STATE + + class InnerStateLex < Ripper::Filter + def initialize(code) + super(code) + end + + def on_default(event, tok, data) + @callback.call({ :line_no => lineno, :char_no => column, :kind => event, :text => tok, :state => state}) + end + + def each(&block) + @callback = block + parse + end + end if RIPPER_HAS_LEX_STATE def get_squashed_tk if @buf.empty? @@ -297,10 +315,10 @@ class RDoc::RipperStateLex when :on_tstring_beg then tk = get_string_tk(tk) when :on_backtick then - if (EXPR_FNAME & tk[:state]) != 0 - @inner_lex.lex_state = EXPR_ARG + if (tk[:state] & (EXPR_FNAME | EXPR_ENDFN)) != 0 + @inner_lex.lex_state = EXPR_ARG unless RIPPER_HAS_LEX_STATE tk[:kind] = :on_ident - tk[:state] = @inner_lex.lex_state + tk[:state] = Ripper::Lexer.const_defined?(:State) ? Ripper::Lexer::State.new(EXPR_ARG) : EXPR_ARG else tk = get_string_tk(tk) end @@ -310,7 +328,7 @@ class RDoc::RipperStateLex tk = get_embdoc_tk(tk) when :on_heredoc_beg then @heredoc_queue << retrieve_heredoc_info(tk) - @inner_lex.lex_state = EXPR_END + @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? get_heredoc_tk(*@heredoc_queue.shift) @@ -540,10 +558,10 @@ class RDoc::RipperStateLex private def get_op_tk(tk) redefinable_operators = %w[! != !~ % & * ** + +@ - -@ / < << <= <=> == === =~ > >= >> [] []= ^ ` | ~] - if redefinable_operators.include?(tk[:text]) and EXPR_ARG == tk[:state] then - @inner_lex.lex_state = EXPR_ARG + if redefinable_operators.include?(tk[:text]) and tk[:state] == EXPR_ARG then + @inner_lex.lex_state = EXPR_ARG unless RIPPER_HAS_LEX_STATE + tk[:state] = Ripper::Lexer.const_defined?(:State) ? Ripper::Lexer::State.new(EXPR_ARG) : EXPR_ARG tk[:kind] = :on_ident - tk[:state] = @inner_lex.lex_state elsif tk[:text] =~ /^[-+]$/ then tk_ahead = get_squashed_tk case tk_ahead[:kind] diff --git a/lib/rdoc/parser/ruby.rb b/lib/rdoc/parser/ruby.rb index c81f152b56..f1856acce8 100644 --- a/lib/rdoc/parser/ruby.rb +++ b/lib/rdoc/parser/ruby.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # This file contains stuff stolen outright from: # @@ -239,8 +239,8 @@ class RDoc::Parser::Ruby < RDoc::Parser def collect_first_comment skip_tkspace - comment = '' - comment.force_encoding @encoding if @encoding + comment = ''.dup + comment = RDoc::Encoding.change_encoding comment, @encoding if @encoding first_line = true first_comment_tk_kind = nil @@ -318,8 +318,7 @@ class RDoc::Parser::Ruby < RDoc::Parser end ## - # Looks for a true or false token. Returns false if TkFALSE or TkNIL are - # found. + # Looks for a true or false token. def get_bool skip_tkspace @@ -342,7 +341,7 @@ class RDoc::Parser::Ruby < RDoc::Parser def get_class_or_module container, ignore_constants = false skip_tkspace name_t = get_tk - given_name = '' + given_name = ''.dup # class ::A -> A is in the top level if :on_op == name_t[:kind] and '::' == name_t[:text] then # bug @@ -379,7 +378,7 @@ class RDoc::Parser::Ruby < RDoc::Parser if prev_container == container and !ignore_constants given_name = name_t[:text] else - given_name << '::' << name_t[:text] + given_name << '::' + name_t[:text] end end @@ -574,27 +573,28 @@ class RDoc::Parser::Ruby < RDoc::Parser # # This routine modifies its +comment+ parameter. - def look_for_directives_in context, comment - @preprocess.handle comment, context do |directive, param| + def look_for_directives_in container, comment + @preprocess.handle comment, container do |directive, param| case directive when 'method', 'singleton-method', 'attr', 'attr_accessor', 'attr_reader', 'attr_writer' then false # handled elsewhere when 'section' then - context.set_current_section param, comment.dup + break unless container.kind_of?(RDoc::Context) + container.set_current_section param, comment.dup comment.text = '' break end end - remove_private_comments comment + comment.remove_private end ## # Adds useful info about the parser to +message+ def make_message message - prefix = "#{@file_name}:" + prefix = "#{@file_name}:".dup tk = peek_tk prefix << "#{tk[:line_no]}:#{tk[:char_no]}:" if tk @@ -913,7 +913,7 @@ class RDoc::Parser::Ruby < RDoc::Parser return unless body - value.replace body + con.value = body record_location con con.line = line_no read_documentation_modifiers con, RDoc::CONSTANT_MODIFIERS @@ -928,7 +928,7 @@ class RDoc::Parser::Ruby < RDoc::Parser def parse_constant_body container, constant, is_array_or_hash # :nodoc: nest = 0 - rhs_name = '' + rhs_name = ''.dup get_tkread @@ -944,7 +944,7 @@ class RDoc::Parser::Ruby < RDoc::Parser elsif (:on_kw == tk[:kind] && 'def' == tk[:text]) then nest += 1 elsif (:on_kw == tk[:kind] && %w{do if unless case begin}.include?(tk[:text])) then - if (RDoc::RipperStateLex::EXPR_LABEL & tk[:state]) == 0 + if (tk[:state] & RDoc::RipperStateLex::EXPR_LABEL) == 0 nest += 1 end elsif [:on_rparen, :on_rbrace, :on_rbracket].include?(tk[:kind]) || @@ -990,14 +990,13 @@ class RDoc::Parser::Ruby < RDoc::Parser column = tk[:char_no] line_no = tk[:line_no] - text = comment.text - - singleton = !!text.sub!(/(^# +:?)(singleton-)(method:)/, '\1\3') + comment.text = comment.text.sub(/(^# +:?)(singleton-)(method:)/, '\1\3') + singleton = !!$~ co = - if text.sub!(/^# +:?method: *(\S*).*?\n/i, '') then - parse_comment_ghost container, text, $1, column, line_no, comment - elsif text.sub!(/# +:?(attr(_reader|_writer|_accessor)?): *(\S*).*?\n/i, '') then + if (comment.text = comment.text.sub(/^# +:?method: *(\S*).*?\n/i, '')) && !!$~ then + parse_comment_ghost container, comment.text, $1, column, line_no, comment + elsif (comment.text = comment.text.sub(/# +:?(attr(_reader|_writer|_accessor)?): *(\S*).*?\n/i, '')) && !!$~ then parse_comment_attr container, $1, $3, comment end @@ -1194,7 +1193,9 @@ class RDoc::Parser::Ruby < RDoc::Parser tmp = RDoc::CodeObject.new read_documentation_modifiers tmp, RDoc::ATTR_MODIFIERS - if comment.text.sub!(/^# +:?(attr(_reader|_writer|_accessor)?): *(\S*).*?\n/i, '') then + regexp = /^# +:?(attr(_reader|_writer|_accessor)?): *(\S*).*?\n/i + if regexp =~ comment.text then + comment.text = comment.text.sub(regexp, '') rw = case $1 when 'attr_reader' then 'R' when 'attr_writer' then 'W' @@ -1227,7 +1228,8 @@ class RDoc::Parser::Ruby < RDoc::Parser skip_tkspace false - singleton = !!comment.text.sub!(/(^# +:?)(singleton-)(method:)/, '\1\3') + comment.text = comment.text.sub(/(^# +:?)(singleton-)(method:)/, '\1\3') + singleton = !!$~ name = parse_meta_method_name comment, tk @@ -1290,6 +1292,7 @@ class RDoc::Parser::Ruby < RDoc::Parser token_listener meth do meth.params = '' + look_for_directives_in meth, comment comment.normalize comment.extract_call_seq meth @@ -1336,6 +1339,7 @@ class RDoc::Parser::Ruby < RDoc::Parser return unless name meth = RDoc::AnyMethod.new get_tkread, name + look_for_directives_in meth, comment meth.singleton = single == SINGLE ? true : singleton record_location meth @@ -1458,8 +1462,7 @@ class RDoc::Parser::Ruby < RDoc::Parser name_t2 = get_tk if (:on_kw == name_t[:kind] && 'self' == name_t[:text]) || (:on_op == name_t[:kind] && '%' == name_t[:text]) then - # NOTE: work around '[' being consumed early and not being re-tokenized - # as a TkAREF + # NOTE: work around '[' being consumed early if :on_lbracket == name_t2[:kind] get_tk name = '[]' @@ -1535,7 +1538,7 @@ class RDoc::Parser::Ruby < RDoc::Parser when :on_comment, :on_embdoc then @read.pop if :on_nl == end_token[:kind] and "\n" == tk[:text][-1] and - (!continue or (RDoc::RipperStateLex::EXPR_LABEL & tk[:state]) != 0) then + (!continue or (tk[:state] & RDoc::RipperStateLex::EXPR_LABEL) != 0) then if method && method.block_params.nil? then unget_tk tk read_documentation_modifiers method, modifiers @@ -1642,7 +1645,7 @@ class RDoc::Parser::Ruby < RDoc::Parser def parse_statements(container, single = NORMAL, current_method = nil, comment = new_comment('')) raise 'no' unless RDoc::Comment === comment - comment.force_encoding @encoding if @encoding + comment = RDoc::Encoding.change_encoding comment, @encoding if @encoding nest = 1 save_visibility = container.visibility @@ -1685,12 +1688,12 @@ class RDoc::Parser::Ruby < RDoc::Parser comment.empty? comment = '' - comment.force_encoding @encoding if @encoding + comment = RDoc::Encoding.change_encoding comment, @encoding if @encoding end while tk and (:on_comment == tk[:kind] or :on_embdoc == tk[:kind]) do - comment << tk[:text] - comment << "\n" unless "\n" == tk[:text].chars.to_a.last + comment += tk[:text] + comment += "\n" unless "\n" == tk[:text].chars.to_a.last if tk[:text].size > 1 && "\n" == tk[:text].chars.to_a.last then skip_tkspace false # leading spaces @@ -1740,7 +1743,7 @@ class RDoc::Parser::Ruby < RDoc::Parser end when 'until', 'while' then - if (RDoc::RipperStateLex::EXPR_LABEL & tk[:state]) == 0 + if (tk[:state] & RDoc::RipperStateLex::EXPR_LABEL) == 0 nest += 1 skip_optional_do_after_expression end @@ -1756,7 +1759,7 @@ class RDoc::Parser::Ruby < RDoc::Parser skip_optional_do_after_expression when 'case', 'do', 'if', 'unless', 'begin' then - if (RDoc::RipperStateLex::EXPR_LABEL & tk[:state]) == 0 + if (tk[:state] & RDoc::RipperStateLex::EXPR_LABEL) == 0 nest += 1 end @@ -1809,7 +1812,7 @@ class RDoc::Parser::Ruby < RDoc::Parser unless keep_comment then comment = new_comment '' - comment.force_encoding @encoding if @encoding + comment = RDoc::Encoding.change_encoding comment, @encoding if @encoding container.params = nil container.block_params = nil end @@ -2053,15 +2056,6 @@ class RDoc::Parser::Ruby < RDoc::Parser container.record_location @top_level end - ## - # Removes private comments from +comment+ - #-- - # TODO remove - - def remove_private_comments comment - comment.remove_private - end - ## # Scans this Ruby file for Ruby constructs diff --git a/lib/rdoc/parser/ruby_tools.rb b/lib/rdoc/parser/ruby_tools.rb index 0a566827a5..1f621cd32e 100644 --- a/lib/rdoc/parser/ruby_tools.rb +++ b/lib/rdoc/parser/ruby_tools.rb @@ -1,7 +1,6 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## -# Collection of methods for writing parsers against RDoc::RubyLex and -# RDoc::RubyToken +# Collection of methods for writing parsers module RDoc::Parser::RubyTools diff --git a/lib/rdoc/parser/simple.rb b/lib/rdoc/parser/simple.rb index f2ab27a92e..b1dabad0f8 100644 --- a/lib/rdoc/parser/simple.rb +++ b/lib/rdoc/parser/simple.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # Parse a non-source file. We basically take the whole thing as one big # comment. @@ -19,7 +19,7 @@ class RDoc::Parser::Simple < RDoc::Parser preprocess = RDoc::Markup::PreProcess.new @file_name, @options.rdoc_include - preprocess.handle @content, @top_level + @content = preprocess.handle @content, @top_level end ## @@ -52,7 +52,7 @@ class RDoc::Parser::Simple < RDoc::Parser def remove_private_comment comment # Workaround for gsub encoding for Ruby 1.9.2 and earlier empty = '' - empty.force_encoding comment.encoding + empty = RDoc::Encoding.change_encoding empty, comment.encoding comment = comment.gsub(%r%^--\n.*?^\+\+\n?%m, empty) comment.sub(%r%^--\n.*%m, empty) diff --git a/lib/rdoc/parser/text.rb b/lib/rdoc/parser/text.rb index 1a13fd1186..01de0cc595 100644 --- a/lib/rdoc/parser/text.rb +++ b/lib/rdoc/parser/text.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # Indicates this parser is text and doesn't contain code constructs. # diff --git a/lib/rdoc/rd.rb b/lib/rdoc/rd.rb index 39af3294f5..0d3d3cea85 100644 --- a/lib/rdoc/rd.rb +++ b/lib/rdoc/rd.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # RDoc::RD implements the RD format from the rdtool gem. # diff --git a/lib/rdoc/rd/block_parser.rb b/lib/rdoc/rd/block_parser.rb index 3f4941168f..8ac7cad996 100644 --- a/lib/rdoc/rd/block_parser.rb +++ b/lib/rdoc/rd/block_parser.rb @@ -677,54 +677,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 +732,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 +766,7 @@ def _reduce_17(val, _values, result) # imform to lexer. @in_verbatim = false - + result end @@ -777,25 +777,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 +803,7 @@ def _reduce_22(val, _values, result) result = val # inform to lexer. @in_verbatim = true - + result end @@ -817,89 +817,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 +907,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 +991,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.rb b/lib/rdoc/rd/inline.rb index 011ec67e33..e5cb545728 100644 --- a/lib/rdoc/rd/inline.rb +++ b/lib/rdoc/rd/inline.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # Inline keeps track of markup and labels to create proper links. @@ -50,11 +50,11 @@ class RDoc::RD::Inline def append more case more when String then - @reference << more - @rdoc << more + @reference += more + @rdoc += more when RDoc::RD::Inline then - @reference << more.reference - @rdoc << more.rdoc + @reference += more.reference + @rdoc += more.rdoc else raise "unknown thingy #{more}" end diff --git a/lib/rdoc/rd/inline_parser.rb b/lib/rdoc/rd/inline_parser.rb index cc63ea6f70..41b5263088 100644 --- a/lib/rdoc/rd/inline_parser.rb +++ b/lib/rdoc/rd/inline_parser.rb @@ -412,9 +412,9 @@ racc_action_default = [ racc_goto_table = [ 126, 44, 125, 52, 144, 144, 160, 93, 97, 43, - 166, 82, 144, 40, 41, 39, 138, 146, 169, 90, + 166, 82, 144, 41, 40, 39, 138, 146, 169, 90, 36, 52, 44, 1, 52, 129, 169, 94, 59, 83, - 123, 30, 151, 92, 120, 121, 31, 32, 33, 34, + 123, 30, 151, 92, 121, 120, 31, 32, 33, 34, 35, 170, 58, 166, 167, 147, 170, 166, 37, nil, 150, nil, 166, 159, 4, 166, 4, nil, nil, nil, nil, 155, nil, 156, 160, nil, nil, 4, 4, 4, @@ -430,9 +430,9 @@ racc_goto_table = [ racc_goto_check = [ 22, 24, 21, 34, 36, 36, 37, 18, 16, 23, - 35, 41, 36, 19, 20, 17, 25, 25, 28, 14, + 35, 41, 36, 20, 19, 17, 25, 25, 28, 14, 13, 34, 24, 1, 34, 24, 28, 23, 38, 39, - 23, 3, 42, 17, 19, 20, 1, 1, 1, 1, + 23, 3, 42, 17, 20, 19, 1, 1, 1, 1, 1, 33, 1, 35, 29, 32, 33, 35, 15, nil, 41, nil, 35, 22, 4, 35, 4, nil, nil, nil, nil, 16, nil, 18, 37, nil, nil, 4, 4, 4, @@ -448,8 +448,8 @@ racc_goto_check = [ racc_goto_pointer = [ nil, 23, nil, 29, 54, 74, 109, 117, 127, nil, - nil, 135, nil, 2, -17, 30, -30, -3, -29, -5, - -4, -40, -42, -9, -17, -28, nil, nil, -120, -83, + nil, 135, nil, 2, -17, 30, -30, -3, -29, -4, + -5, -40, -42, -9, -17, -28, nil, nil, -120, -83, nil, nil, -7, -101, -15, -116, -40, -91, 8, 2, nil, -9, -29 ] @@ -732,12 +732,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 +762,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 +791,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 +805,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 +820,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 +847,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 +940,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 +984,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 +1009,7 @@ end def _reduce_62(val, _values, result) result << val[1] - + result end @@ -1017,7 +1017,7 @@ end def _reduce_64(val, _values, result) result << val[1] - + result end @@ -1048,7 +1048,7 @@ end # reduce 77 omitted def _reduce_78(val, _values, result) - result << val[1] + result << val[1] result end @@ -1099,13 +1099,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 +1122,7 @@ end # reduce 108 omitted def _reduce_109(val, _values, result) - result << val[1] + result << val[1] result end @@ -1130,24 +1130,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 +1192,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 2787f07654..1ccfddfc7a 100644 --- a/lib/rdoc/rdoc.gemspec +++ b/lib/rdoc/rdoc.gemspec @@ -8,7 +8,7 @@ end Gem::Specification.new do |s| s.name = "rdoc" s.version = RDoc::VERSION - s.date = "2017-10-10" + s.date = "2017-11-27" s.authors = [ "Eric Hodel", @@ -33,9 +33,9 @@ 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/markdown/literals.rb", "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/test_case.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" + s.files << "lib/rdoc/rd/block_parser.rb" << "lib/rdoc/rd/inline_parser.rb" << "lib/rdoc/markdown.rb" << "lib/rdoc/markdown/literals.rb" s.rdoc_options = ["--main", "README.rdoc"] s.extra_rdoc_files += %w[ diff --git a/lib/rdoc/rdoc.rb b/lib/rdoc/rdoc.rb index adcb65b13b..68775c8be1 100644 --- a/lib/rdoc/rdoc.rb +++ b/lib/rdoc/rdoc.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc' require 'find' @@ -521,13 +521,18 @@ The internal error was: # by the RDoc options def generate - Dir.chdir @options.op_dir do - unless @options.quiet then - $stderr.puts "\nGenerating #{@generator.class.name.sub(/^.*::/, '')} format into #{Dir.pwd}..." - end - + if @options.dry_run then + # do nothing @generator.generate - update_output_dir '.', @start_time, @last_modified + else + Dir.chdir @options.op_dir do + unless @options.quiet then + $stderr.puts "\nGenerating #{@generator.class.name.sub(/^.*::/, '')} format into #{Dir.pwd}..." + end + + @generator.generate + update_output_dir '.', @start_time, @last_modified + end end end diff --git a/lib/rdoc/require.rb b/lib/rdoc/require.rb index f565ffad78..91f9c24e5d 100644 --- a/lib/rdoc/require.rb +++ b/lib/rdoc/require.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # A file loaded by \#require diff --git a/lib/rdoc/ri.rb b/lib/rdoc/ri.rb index 388cb12c70..c798c1fc49 100644 --- a/lib/rdoc/ri.rb +++ b/lib/rdoc/ri.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc' ## diff --git a/lib/rdoc/ri/driver.rb b/lib/rdoc/ri/driver.rb index 51d633be58..fa0e040a42 100644 --- a/lib/rdoc/ri/driver.rb +++ b/lib/rdoc/ri/driver.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'abbrev' require 'optparse' diff --git a/lib/rdoc/ri/formatter.rb b/lib/rdoc/ri/formatter.rb index d0c85dbe6b..832a101e6c 100644 --- a/lib/rdoc/ri/formatter.rb +++ b/lib/rdoc/ri/formatter.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # For RubyGems backwards compatibility diff --git a/lib/rdoc/ri/paths.rb b/lib/rdoc/ri/paths.rb index 94db2216a2..d41e610591 100644 --- a/lib/rdoc/ri/paths.rb +++ b/lib/rdoc/ri/paths.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc/ri' ## diff --git a/lib/rdoc/ri/store.rb b/lib/rdoc/ri/store.rb index 66e234f521..9f4b03734a 100644 --- a/lib/rdoc/ri/store.rb +++ b/lib/rdoc/ri/store.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true module RDoc::RI Store = RDoc::Store # :nodoc: diff --git a/lib/rdoc/ri/task.rb b/lib/rdoc/ri/task.rb index cc0a85d4b7..6a6ea572bf 100644 --- a/lib/rdoc/ri/task.rb +++ b/lib/rdoc/ri/task.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true begin gem 'rdoc' rescue Gem::LoadError diff --git a/lib/rdoc/rubygems_hook.rb b/lib/rdoc/rubygems_hook.rb index e9351b7280..90b0541fcf 100644 --- a/lib/rdoc/rubygems_hook.rb +++ b/lib/rdoc/rubygems_hook.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rubygems/user_interaction' require 'fileutils' require 'rdoc' diff --git a/lib/rdoc/servlet.rb b/lib/rdoc/servlet.rb index dfc71436b8..f2d6dd5adc 100644 --- a/lib/rdoc/servlet.rb +++ b/lib/rdoc/servlet.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rdoc' require 'time' require 'json' @@ -111,7 +111,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.sub!(/^#{Regexp.escape @mount_path}/o, '') if @mount_path + req.path = req.path.sub(/^#{Regexp.escape @mount_path}/o, '') if @mount_path case req.path when '/' then diff --git a/lib/rdoc/single_class.rb b/lib/rdoc/single_class.rb index 7affa027e1..6a7b67deb3 100644 --- a/lib/rdoc/single_class.rb +++ b/lib/rdoc/single_class.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # A singleton class diff --git a/lib/rdoc/stats.rb b/lib/rdoc/stats.rb index 354e904b19..bd6c0ef23a 100644 --- a/lib/rdoc/stats.rb +++ b/lib/rdoc/stats.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # RDoc statistics collector which prints a summary and report of a project's # documentation totals. diff --git a/lib/rdoc/stats/normal.rb b/lib/rdoc/stats/normal.rb index 9f7ca59c34..a3a6ff377e 100644 --- a/lib/rdoc/stats/normal.rb +++ b/lib/rdoc/stats/normal.rb @@ -1,4 +1,4 @@ -# 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::Quiet 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 diff --git a/lib/rdoc/stats/quiet.rb b/lib/rdoc/stats/quiet.rb index 561c272ef7..bc4161b2d4 100644 --- a/lib/rdoc/stats/quiet.rb +++ b/lib/rdoc/stats/quiet.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # Stats printer that prints nothing diff --git a/lib/rdoc/stats/verbose.rb b/lib/rdoc/stats/verbose.rb index e04edade52..6ace8937a2 100644 --- a/lib/rdoc/stats/verbose.rb +++ b/lib/rdoc/stats/verbose.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # Stats printer that prints everything documented, including the documented # status diff --git a/lib/rdoc/store.rb b/lib/rdoc/store.rb index aaefff8f13..999aa76f92 100644 --- a/lib/rdoc/store.rb +++ b/lib/rdoc/store.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'fileutils' ## diff --git a/lib/rdoc/task.rb b/lib/rdoc/task.rb index 1074de0197..323d00eabc 100644 --- a/lib/rdoc/task.rb +++ b/lib/rdoc/task.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true #-- # Copyright (c) 2003, 2004 Jim Weirich, 2009 Eric Hodel # diff --git a/lib/rdoc/test_case.rb b/lib/rdoc/test_case.rb index 594fb31272..22d3f14219 100644 --- a/lib/rdoc/test_case.rb +++ b/lib/rdoc/test_case.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true begin gem 'minitest', '~> 4.0' unless defined?(Test::Unit) rescue NoMethodError, Gem::LoadError @@ -139,9 +139,8 @@ class RDoc::TestCase < MiniTest::Unit::TestCase # Enables pretty-print output def mu_pp obj # :nodoc: - s = '' - s = PP.pp obj, s - s = s.force_encoding Encoding.default_external + s = obj.pretty_inspect + s = RDoc::Encoding.change_encoding s, Encoding.default_external s.chomp end diff --git a/lib/rdoc/text.rb b/lib/rdoc/text.rb index 88ff255f01..7e714be0ad 100644 --- a/lib/rdoc/text.rb +++ b/lib/rdoc/text.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # For RDoc::Text#to_html @@ -60,7 +60,7 @@ module RDoc::Text 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 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 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 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 # 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] diff --git a/lib/rdoc/token_stream.rb b/lib/rdoc/token_stream.rb index 2b69e943cd..05fb46e89a 100644 --- a/lib/rdoc/token_stream.rb +++ b/lib/rdoc/token_stream.rb @@ -1,4 +1,4 @@ -# 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 # 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 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 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 diff --git a/lib/rdoc/tom_doc.rb b/lib/rdoc/tom_doc.rb index d760849938..2b594b7d84 100644 --- a/lib/rdoc/tom_doc.rb +++ b/lib/rdoc/tom_doc.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true # :markup: tomdoc # A parser for TomDoc based on TomDoc 1.0.0-rc1 (02adef9b5a) @@ -222,7 +222,7 @@ class RDoc::TomDoc < RDoc::Markup::Parser # Returns self. def tokenize text - text.sub!(/\A(Public|Internal|Deprecated):\s+/, '') + text = text.sub(/\A(Public|Internal|Deprecated):\s+/, '') setup_scanner text diff --git a/lib/rdoc/top_level.rb b/lib/rdoc/top_level.rb index 38be646ad0..6186722772 100644 --- a/lib/rdoc/top_level.rb +++ b/lib/rdoc/top_level.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # A TopLevel context is a representation of the contents of a single file -- cgit v1.2.3