1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
hsbt 2017-11-27 10:45:24 +00:00
parent 2d9f20e1cf
commit 5551871086
195 changed files with 1631 additions and 1258 deletions

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
$DEBUG_RDOC = nil $DEBUG_RDOC = nil
# :main: README.rdoc # :main: README.rdoc
@ -65,7 +65,7 @@ module RDoc
## ##
# RDoc version you are using # RDoc version you are using
VERSION = '6.0.0.beta3' VERSION = '6.0.0.beta4'
## ##
# Method visibilities # Method visibilities

View file

@ -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 # Represent an alias, which is an old_name/new_name pair associated with a
# particular context # particular context

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# An anonymous class like: # An anonymous class like:
# #

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# AnyMethod is the base class for objects representing methods # AnyMethod is the base class for objects representing methods
@ -244,9 +244,9 @@ class RDoc::AnyMethod < RDoc::MethodAttr
if @block_params then if @block_params then
# If this method has explicit block parameters, remove any explicit # If this method has explicit block parameters, remove any explicit
# &block # &block
params.sub!(/,?\s*&\w+/, '') params = params.sub(/,?\s*&\w+/, '')
else else
params.sub!(/\&(\w+)/, '\1') params = params.sub(/\&(\w+)/, '\1')
end end
params = params.gsub(/\s+/, '').split(',').reject(&:empty?) params = params.gsub(/\s+/, '').split(',').reject(&:empty?)
@ -265,7 +265,7 @@ class RDoc::AnyMethod < RDoc::MethodAttr
params = params.sub(/(\|[^|]+\|)\s*\.\.\.\s*(end|\})/, '\1 \2') params = params.sub(/(\|[^|]+\|)\s*\.\.\.\s*(end|\})/, '\1 \2')
elsif @params then elsif @params then
params = @params.gsub(/\s*\#.*/, '') params = @params.gsub(/\s*\#.*/, '')
params = params.tr("\n", " ").squeeze(" ") params = params.tr_s("\n ", " ")
params = "(#{params})" unless params[0] == ?( params = "(#{params})" unless params[0] == ?(
else else
params = '' params = ''
@ -274,11 +274,11 @@ class RDoc::AnyMethod < RDoc::MethodAttr
if @block_params then if @block_params then
# If this method has explicit block parameters, remove any explicit # If this method has explicit block parameters, remove any explicit
# &block # &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] == ?( if block[0] == ?(
block.sub!(/^\(/, '').sub!(/\)/, '') block = block.sub(/^\(/, '').sub(/\)/, '')
end end
params << " { |#{block}| ... }" params << " { |#{block}| ... }"
end end

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# An attribute created by \#attr, \#attr_reader, \#attr_writer or # An attribute created by \#attr, \#attr_reader, \#attr_writer or
# \#attr_accessor # \#attr_accessor

View file

@ -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 # ClassModule is the base class for objects representing either a class or a
# module. # module.
@ -136,7 +136,9 @@ class RDoc::ClassModule < RDoc::Context
normalize_comment comment normalize_comment comment
end end
if location.parser == RDoc::Parser::C
@comment_location.delete_if { |(_, l)| l == location } @comment_location.delete_if { |(_, l)| l == location }
end
@comment_location << [comment, location] @comment_location << [comment, location]

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# Base class for the RDoc code tree. # Base class for the RDoc code tree.
# #
@ -144,7 +144,7 @@ class RDoc::CodeObject
# HACK correct fix is to have #initialize create @comment # HACK correct fix is to have #initialize create @comment
# with the correct encoding # with the correct encoding
if String === @comment and @comment.empty? then if String === @comment and @comment.empty? then
@comment.force_encoding comment.encoding @comment = RDoc::Encoding.change_encoding @comment, comment.encoding
end end
@comment @comment
end end

View file

@ -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 # This file was used to load all the RDoc::CodeObject subclasses at once. Now
# autoload handles this. # autoload handles this.

View file

@ -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 # 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. # 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 def initialize text = nil, location = nil
@location = location @location = location
@text = text @text = text.nil? ? nil : text.dup
@document = nil @document = nil
@format = 'rdoc' @format = 'rdoc'
@ -114,11 +114,15 @@ class RDoc::Comment
method.call_seq = seq.chomp method.call_seq = seq.chomp
elsif @text.sub!(/^\s*:?call-seq:(.*?)(^\s*$|\z)/m, '') then else
regexp = /^\s*:?call-seq:(.*?)(^\s*$|\z)/m
if regexp =~ @text then
@text = @text.sub(regexp, '')
seq = $1 seq = $1
seq.gsub!(/^\s*/, '') seq.gsub!(/^\s*/, '')
method.call_seq = seq method.call_seq = seq
end end
end
method method
end end
@ -133,8 +137,14 @@ class RDoc::Comment
## ##
# HACK dubious # HACK dubious
def force_encoding encoding def encode! encoding
@text.force_encoding 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 end
## ##
@ -200,7 +210,7 @@ class RDoc::Comment
def remove_private def remove_private
# Workaround for gsub encoding for Ruby 1.9.2 and earlier # Workaround for gsub encoding for Ruby 1.9.2 and earlier
empty = '' 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.gsub(%r%^\s*([#*]?)--.*?^\s*(\1)\+\+\n?%m, empty)
@text = @text.sub(%r%^\s*[#*]?--.*%m, '') @text = @text.sub(%r%^\s*[#*]?--.*%m, '')
@ -216,7 +226,7 @@ class RDoc::Comment
@text.nil? and @document @text.nil? and @document
@document = nil @document = nil
@text = text @text = text.nil? ? nil : text.dup
end end
## ##

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# A constant # A constant

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
require 'cgi' require 'cgi'
## ##
@ -239,7 +239,7 @@ class RDoc::Context < RDoc::CodeObject
if known then if known then
known.comment = attribute.comment if known.comment.empty? 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 RDoc::Attr === registered then
registered.rw = 'RW' registered.rw = 'RW'
else else
@ -249,7 +249,7 @@ class RDoc::Context < RDoc::CodeObject
end end
if attribute.rw.index 'W' then if attribute.rw.index 'W' then
key = attribute.pretty_name << '=' key = attribute.pretty_name + '='
known = @methods_hash[key] known = @methods_hash[key]
if known then if known then

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# A section of documentation like: # A section of documentation like:
# #
@ -43,7 +43,7 @@ class RDoc::Context::Section
@parent = parent @parent = parent
@title = title ? title.strip : title @title = title ? title.strip : title
@@sequence.succ! @@sequence = @@sequence.succ
@sequence = @@sequence.dup @sequence = @@sequence.dup
@comments = [] @comments = []

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# RDoc::CrossReference is a reusable way to create cross references for names. # RDoc::CrossReference is a reusable way to create cross references for names.

View file

@ -1,5 +1,5 @@
# coding: US-ASCII # 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 # 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/, '') utf8 = content.sub!(/\A\xef\xbb\xbf/, '')
RDoc::Encoding.set_encoding content content = RDoc::Encoding.set_encoding content
begin begin
encoding ||= Encoding.default_external encoding ||= Encoding.default_external
orig_encoding = content.encoding orig_encoding = content.encoding
if not orig_encoding.ascii_compatible? then if not orig_encoding.ascii_compatible? then
content.encode! encoding content = content.encode encoding
elsif utf8 then elsif utf8 then
content.force_encoding Encoding::UTF_8 content = RDoc::Encoding.change_encoding content, Encoding::UTF_8
content.encode! encoding content = content.encode encoding
else else
# assume the content is in our output encoding # assume the content is in our output encoding
content.force_encoding encoding content = RDoc::Encoding.change_encoding content, encoding
end end
unless content.valid_encoding? then unless content.valid_encoding? then
# revert and try to transcode # revert and try to transcode
content.force_encoding orig_encoding content = RDoc::Encoding.change_encoding content, orig_encoding
content.encode! encoding content = content.encode encoding
end end
unless content.valid_encoding? then unless content.valid_encoding? then
@ -52,9 +52,10 @@ module RDoc::Encoding
rescue Encoding::InvalidByteSequenceError, rescue Encoding::InvalidByteSequenceError,
Encoding::UndefinedConversionError => e Encoding::UndefinedConversionError => e
if force_transcode then if force_transcode then
content.force_encoding orig_encoding content = RDoc::Encoding.change_encoding content, orig_encoding
content.encode!(encoding, content = content.encode(encoding,
:invalid => :replace, :undef => :replace, :invalid => :replace,
:undef => :replace,
:replace => '?') :replace => '?')
return content return content
else else
@ -77,15 +78,17 @@ module RDoc::Encoding
first_line = $1 first_line = $1
if first_line =~ /\A# +frozen[-_]string[-_]literal[=:].+$/i if first_line =~ /\A# +frozen[-_]string[-_]literal[=:].+$/i
string.sub! first_line, '' string = string.sub first_line, ''
end end
string
end end
## ##
# Sets the encoding of +string+ based on the magic comment # Sets the encoding of +string+ based on the magic comment
def self.set_encoding string def self.set_encoding string
remove_frozen_string_literal string string = remove_frozen_string_literal string
string =~ /\A(?:#!.*\n)?(.*\n)/ string =~ /\A(?:#!.*\n)?(.*\n)/
@ -94,15 +97,34 @@ module RDoc::Encoding
name = case first_line name = case first_line
when /^<\?xml[^?]*encoding=(["'])(.*?)\1/ then $2 when /^<\?xml[^?]*encoding=(["'])(.*?)\1/ then $2
when /\b(?:en)?coding[=:]\s*([^\s;]+)/i then $1 when /\b(?:en)?coding[=:]\s*([^\s;]+)/i then $1
else return else return string
end 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 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
end end

View file

@ -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 # Allows an ERB template to be rendered in the context (binding) of an
# existing ERB template evaluation. # existing ERB template evaluation.

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
require 'erb' require 'erb'
## ##

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# A Module extension to a class with \#extend # A Module extension to a class with \#extend
# #

View file

@ -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 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 # RDoc::CodeObject tree into some form of output. RDoc comes with the HTML

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
# -*- mode: ruby; ruby-indent-level: 2; tab-width: 2 -*- # -*- mode: ruby; ruby-indent-level: 2; tab-width: 2 -*-
require 'erb' require 'erb'
@ -313,12 +313,16 @@ class RDoc::Generator::Darkfish
search_index_rel_prefix = rel_prefix search_index_rel_prefix = rel_prefix
search_index_rel_prefix += @asset_rel_path if @file_output search_index_rel_prefix += @asset_rel_path if @file_output
# suppress 1.9.3 warning asset_rel_prefix = rel_prefix + @asset_rel_path
asset_rel_prefix = asset_rel_prefix = rel_prefix + @asset_rel_path
@title = @options.title @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 rescue => e
error = RDoc::Error.new \ error = RDoc::Error.new \
"error generating index.html: #{e.message} (#{e.class})" "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 = rel_prefix
search_index_rel_prefix += @asset_rel_path if @file_output search_index_rel_prefix += @asset_rel_path if @file_output
# suppress 1.9.3 warning asset_rel_prefix = rel_prefix + @asset_rel_path
asset_rel_prefix = asset_rel_prefix = rel_prefix + @asset_rel_path svninfo = get_svninfo(current)
svninfo = svninfo = get_svninfo(current)
@title = "#{klass.type} #{klass.full_name} - #{@options.title}" @title = "#{klass.type} #{klass.full_name} - #{@options.title}"
debug_msg " rendering #{out_file}" 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 end
## ##
@ -416,8 +425,7 @@ class RDoc::Generator::Darkfish
search_index_rel_prefix = rel_prefix search_index_rel_prefix = rel_prefix
search_index_rel_prefix += @asset_rel_path if @file_output search_index_rel_prefix += @asset_rel_path if @file_output
# suppress 1.9.3 warning asset_rel_prefix = rel_prefix + @asset_rel_path
asset_rel_prefix = asset_rel_prefix = rel_prefix + @asset_rel_path
unless filepage_file then unless filepage_file then
if file.text? then if file.text? then
@ -434,7 +442,13 @@ class RDoc::Generator::Darkfish
@title += " - #{@options.title}" @title += " - #{@options.title}"
template_file ||= filepage_file 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 end
rescue => e rescue => e
error = error =
@ -458,14 +472,19 @@ class RDoc::Generator::Darkfish
search_index_rel_prefix = rel_prefix search_index_rel_prefix = rel_prefix
search_index_rel_prefix += @asset_rel_path if @file_output search_index_rel_prefix += @asset_rel_path if @file_output
# suppress 1.9.3 warning current = file
current = current = file asset_rel_prefix = rel_prefix + @asset_rel_path
asset_rel_prefix = asset_rel_prefix = rel_prefix + @asset_rel_path
@title = "#{file.page_name} - #{@options.title}" @title = "#{file.page_name} - #{@options.title}"
debug_msg " rendering #{out_file}" 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 end
## ##
@ -483,12 +502,16 @@ class RDoc::Generator::Darkfish
search_index_rel_prefix = rel_prefix search_index_rel_prefix = rel_prefix
search_index_rel_prefix += @asset_rel_path if @file_output 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' @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 rescue => e
error = RDoc::Error.new \ error = RDoc::Error.new \
"error generating servlet_not_found: #{e.message} (#{e.class})" "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 = rel_prefix
search_index_rel_prefix += @asset_rel_path if @file_output search_index_rel_prefix += @asset_rel_path if @file_output
# suppress 1.9.3 warning asset_rel_prefix = rel_prefix + @asset_rel_path
asset_rel_prefix = asset_rel_prefix = rel_prefix + @asset_rel_path
@title = "Table of Contents - #{@options.title}" @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 rescue => e
error = RDoc::Error.new \ error = RDoc::Error.new \
"error generating table_of_contents.html: #{e.message} (#{e.class})" "error generating table_of_contents.html: #{e.message} (#{e.class})"

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
require 'json' require 'json'
begin begin
require 'zlib' require 'zlib'
@ -161,7 +161,7 @@ class RDoc::Generator::JsonIndex
# Compress the search_index.js file using gzip # Compress the search_index.js file using gzip
def generate_gzipped def generate_gzipped
return unless defined?(Zlib) return if @options.dry_run or not defined?(Zlib)
debug_msg "Compressing generated JSON index" debug_msg "Compressing generated JSON index"
out_dir = @base_dir + @options.op_dir out_dir = @base_dir + @options.op_dir

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# Handle common RDoc::Markup tasks for various CodeObjects # Handle common RDoc::Markup tasks for various CodeObjects
# #

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# Generates a POT file. # Generates a POT file.
# #

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# Extracts message from RDoc::Store # Extracts message from RDoc::Store

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# Generates a PO format text # Generates a PO format text
@ -29,8 +29,8 @@ class RDoc::Generator::POT::PO
def to_s def to_s
po = '' po = ''
sort_entries.each do |entry| sort_entries.each do |entry|
po << "\n" unless po.empty? po += "\n" unless po.empty?
po << entry.to_s po += entry.to_s
end end
po po
end end

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# A PO entry in PO # A PO entry in PO
@ -40,11 +40,11 @@ class RDoc::Generator::POT::POEntry
def to_s def to_s
entry = '' entry = ''
entry << format_translator_comment entry += format_translator_comment
entry << format_extracted_comment entry += format_extracted_comment
entry << format_references entry += format_references
entry << format_flags entry += format_flags
entry << <<-ENTRY entry += <<-ENTRY
msgid #{format_message(@msgid)} msgid #{format_message(@msgid)}
msgstr #{format_message(@msgstr)} msgstr #{format_message(@msgstr)}
ENTRY ENTRY
@ -75,9 +75,9 @@ msgstr #{format_message(@msgstr)}
formatted_comment = '' formatted_comment = ''
comment.each_line do |line| comment.each_line do |line|
formatted_comment << "#{mark} #{line}" formatted_comment += "#{mark} #{line}"
end end
formatted_comment << "\n" unless formatted_comment.end_with?("\n") formatted_comment += "\n" unless formatted_comment.end_with?("\n")
formatted_comment formatted_comment
end end
@ -94,7 +94,7 @@ msgstr #{format_message(@msgstr)}
formatted_references = '' formatted_references = ''
@references.sort.each do |file, line| @references.sort.each do |file, line|
formatted_references << "\#: #{file}:#{line}\n" formatted_references += "\#: #{file}:#{line}\n"
end end
formatted_references formatted_references
end end
@ -111,8 +111,8 @@ msgstr #{format_message(@msgstr)}
formatted_message = '""' formatted_message = '""'
message.each_line do |line| message.each_line do |line|
formatted_message << "\n" formatted_message += "\n"
formatted_message << "\"#{escape(line)}\"" formatted_message += "\"#{escape(line)}\""
end end
formatted_message formatted_message
end end

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# Generates ri data files # Generates ri data files

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# GhostMethod represents a method referenced only by a comment # GhostMethod represents a method referenced only by a comment

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# This module provides i18n related features. # This module provides i18n related features.

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# A message container for a locale. # A message container for a locale.
# #

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# An i18n supported text. # An i18n supported text.
# #
@ -46,9 +46,9 @@ class RDoc::I18n::Text
parse do |part| parse do |part|
case part[:type] case part[:type]
when :paragraph when :paragraph
translated_text << locale.translate(part[:paragraph]) translated_text += locale.translate(part[:paragraph])
when :empty_line when :empty_line
translated_text << part[:line] translated_text += part[:line]
else else
raise "should not reach here: unexpected type: #{type}" raise "should not reach here: unexpected type: #{type}"
end end
@ -69,14 +69,14 @@ class RDoc::I18n::Text
if paragraph.empty? if paragraph.empty?
emit_empty_line_event(line, line_no, &block) emit_empty_line_event(line, line_no, &block)
else else
paragraph << line paragraph += line
emit_paragraph_event(paragraph, paragraph_start_line, line_no, emit_paragraph_event(paragraph, paragraph_start_line, line_no,
&block) &block)
paragraph = '' paragraph = ''
end end
else else
paragraph_start_line = line_no if paragraph.empty? paragraph_start_line = line_no if paragraph.empty?
paragraph << line paragraph += line
end end
end end

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# A Module included in a class with \#include # A Module included in a class with \#include
# #

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
module RDoc module RDoc
## ##

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# HTML entity name map for RDoc::Markdown # HTML entity name map for RDoc::Markdown

View file

@ -1,5 +1,4 @@
# coding: UTF-8 # coding: UTF-8
# frozen_string_literal: false
# :markup: markdown # :markup: markdown
## ##
@ -183,6 +182,7 @@ class RDoc::Markdown::Literals
return nil return nil
end end
if "".respond_to? :ord
def get_byte def get_byte
if @pos >= @string_size if @pos >= @string_size
return nil return nil
@ -192,6 +192,17 @@ class RDoc::Markdown::Literals
@pos += 1 @pos += 1
s s
end end
else
def get_byte
if @pos >= @string_size
return nil
end
s = @string[@pos]
@pos += 1
s
end
end
def parse(rule=nil) def parse(rule=nil)
# We invoke the rules indirectly via apply # We invoke the rules indirectly via apply

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# RDoc::Markup parses plain text documents and attempts to decompose them into # RDoc::Markup parses plain text documents and attempts to decompose them into
# their constituent parts. Some of these parts are high-level: paragraphs, # their constituent parts. Some of these parts are high-level: paragraphs,

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
class RDoc::Markup class RDoc::Markup
AttrChanger = Struct.new :turn_on, :turn_off # :nodoc: AttrChanger = Struct.new :turn_on, :turn_off # :nodoc:

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# An array of attributes which parallels the characters in a string. # An array of attributes which parallels the characters in a string.

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# Manages changes of attributes in a block of text # Manages changes of attributes in a block of text
@ -246,7 +246,7 @@ class RDoc::Markup::AttributeManager
# Processes +str+ converting attributes, HTML and specials # Processes +str+ converting attributes, HTML and specials
def flow str def flow str
@str = str @str = str.dup
mask_protected_sequences mask_protected_sequences

View file

@ -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 # We manage a set of attributes. Each attribute has a symbol name and a bit
# value. # value.

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# An empty line. This class is a singleton. # An empty line. This class is a singleton.

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# A quoted section which contains markup items. # A quoted section which contains markup items.

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# A Document containing lists, headings, paragraphs, etc. # A Document containing lists, headings, paragraphs, etc.

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# Base class for RDoc markup formatters # Base class for RDoc markup formatters
# #

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
require 'minitest/unit' require 'minitest/unit'
## ##

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# A hard-break in the middle of a paragraph. # A hard-break in the middle of a paragraph.

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# A heading with a level (1-6) and text # A heading with a level (1-6) and text

View file

@ -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 # A file included at generation time. Objects of this class are created by
# RDoc::RD for an extension-less include. # RDoc::RD for an extension-less include.

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# An Indented Paragraph of text # An Indented Paragraph of text

View file

@ -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 warn "requiring rdoc/markup/inline is deprecated and will be removed in RDoc 4." if $-w

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# A List is a homogeneous set of ListItems. # A List is a homogeneous set of ListItems.
# #

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# An item within a List that contains paragraphs, headings, etc. # An item within a List that contains paragraphs, headings, etc.
# #

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# A Paragraph of text # A Paragraph of text

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
require 'strscan' require 'strscan'
## ##
@ -249,7 +249,7 @@ class RDoc::Markup::Parser
min_indent = nil min_indent = nil
generate_leading_spaces = true generate_leading_spaces = true
line = '' line = ''.dup
until @tokens.empty? do until @tokens.empty? do
type, data, column, = get type, data, column, = get
@ -257,7 +257,7 @@ class RDoc::Markup::Parser
if type == :NEWLINE then if type == :NEWLINE then
line << data line << data
verbatim << line verbatim << line
line = '' line = ''.dup
generate_leading_spaces = true generate_leading_spaces = true
next next
end end

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# Handle common directives that can occur in a block of text: # 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) # regexp helper (square brackets for optional)
# $1 $2 $3 $4 $5 # $1 $2 $3 $4 $5
# [prefix][\]:directive:[spaces][param]newline # [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::' # skip something like ':toto::'
next $& if $4.empty? and $5 and $5[0, 1] == ':' 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 handle_directive $1, $3, $5, code_object, text.encoding, &block
end end
comment = text unless comment if comment then
comment.text = text
else
comment = text
end
self.class.post_processors.each do |handler| self.class.post_processors.each do |handler|
handler.call comment, code_object handler.call comment, code_object
@ -150,7 +154,7 @@ class RDoc::Markup::PreProcess
case directive case directive
when 'arg', 'args' then 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 code_object.params = param
@ -212,7 +216,7 @@ class RDoc::Markup::PreProcess
when 'yield', 'yields' then when 'yield', 'yields' then
return blankline unless code_object return blankline unless code_object
# remove parameter &block # 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 code_object.block_params = param

View file

@ -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 # A section of text that is added to the output document as-is

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# A horizontal rule with a weight # A horizontal rule with a weight

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# Hold details of a special sequence # Hold details of a special sequence

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# Test case for creating new plain-text RDoc::Markup formatters. See also # Test case for creating new plain-text RDoc::Markup formatters. See also
# RDoc::Markup::FormatterTestCase # RDoc::Markup::FormatterTestCase

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# Outputs RDoc markup with vibrant ANSI color! # Outputs RDoc markup with vibrant ANSI color!

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# Outputs RDoc markup with hot backspace action! You will probably need a # Outputs RDoc markup with hot backspace action! You will probably need a
# pager to use this output format. # pager to use this output format.

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
require 'cgi' require 'cgi'
## ##

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# Subclass of the RDoc::Markup::ToHtml class that supports looking up method # Subclass of the RDoc::Markup::ToHtml class that supports looking up method
# names, classes, etc to create links. RDoc::CrossReference is used to # names, classes, etc to create links. RDoc::CrossReference is used to

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# Outputs RDoc markup as paragraphs with inline markup only. # Outputs RDoc markup as paragraphs with inline markup only.

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# Joins the parts of an RDoc::Markup::Paragraph into a single String. # 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. # Converts the parts of +paragraph+ to a single entry.
def accept_paragraph paragraph def accept_paragraph paragraph
parts = [] parts = paragraph.parts.chunk do |part|
string = false String === part
end.map do |string, chunk|
paragraph.parts.each do |part| string ? chunk.join.rstrip : chunk
if String === part then end.flatten
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
paragraph.parts.replace parts paragraph.parts.replace parts
end end

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
require 'cgi' require 'cgi'
## ##

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
# :markup: markdown # :markup: markdown
## ##

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# Outputs RDoc markup as RDoc markup! (mostly) # Outputs RDoc markup as RDoc markup! (mostly)

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# Extracts just the RDoc::Markup::Heading elements from a # Extracts just the RDoc::Markup::Heading elements from a
# RDoc::Markup::Document to help build a table of contents # RDoc::Markup::Document to help build a table of contents

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# This Markup outputter is used for testing purposes. # This Markup outputter is used for testing purposes.

View file

@ -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 # Extracts sections of text enclosed in plus, tt or code. Used to discover
# undocumented parameters. # undocumented parameters.

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# A section of verbatim text # A section of verbatim text

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# MetaMethod represents a meta-programmed method # MetaMethod represents a meta-programmed method

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# Abstract class representing either a method or an attribute. # Abstract class representing either a method or an attribute.
@ -188,7 +188,7 @@ class RDoc::MethodAttr < RDoc::CodeObject
next if String === ancestor next if String === ancestor
next if parent == ancestor next if parent == ancestor
other = ancestor.find_method_named('#' << name) || other = ancestor.find_method_named('#' + name) ||
ancestor.find_attribute_named(name) ancestor.find_attribute_named(name)
return other if other return other if other

View file

@ -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 # A Mixin adds features from a module into another context. RDoc::Include and
# RDoc::Extend are both mixins. # RDoc::Extend are both mixins.

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# A normal class, neither singleton nor anonymous # A normal class, neither singleton nor anonymous
@ -47,9 +47,9 @@ class RDoc::NormalClass < RDoc::ClassModule
def to_s # :nodoc: def to_s # :nodoc:
display = "#{self.class.name} #{self.full_name}" display = "#{self.class.name} #{self.full_name}"
if superclass if superclass
display << ' < ' << (superclass.is_a?(String) ? superclass : superclass.full_name) display += ' < ' + (superclass.is_a?(String) ? superclass : superclass.full_name)
end end
display << ' -> ' << is_alias_for.to_s if is_alias_for display += ' -> ' + is_alias_for.to_s if is_alias_for
display display
end end

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# A normal module, like NormalClass # A normal module, like NormalClass

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
require 'optparse' require 'optparse'
require 'pathname' require 'pathname'
@ -624,16 +624,16 @@ Usage: #{opt.program_name} [options] [names...]
end end
parsers.sort.each do |parser, regexp| parsers.sort.each do |parser, regexp|
opt.banner << " - #{parser}: #{regexp.join ', '}\n" opt.banner += " - #{parser}: #{regexp.join ', '}\n"
end 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 name_length = DEPRECATED.keys.sort_by { |k| k.length }.last.length
DEPRECATED.sort_by { |k,| k }.each do |name, reason| 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 end
opt.accept Template do |template| opt.accept Template do |template|
@ -1087,7 +1087,7 @@ Usage: #{opt.program_name} [options] [names...]
unless quiet then unless quiet then
deprecated.each do |opt| deprecated.each do |opt|
$stderr.puts 'option ' << opt << ' is deprecated: ' << DEPRECATED[opt] $stderr.puts 'option ' + opt + ' is deprecated: ' + DEPRECATED[opt]
end end
end end

View file

@ -1,5 +1,5 @@
# -*- coding: us-ascii -*- # -*- coding: us-ascii -*-
# frozen_string_literal: false # frozen_string_literal: true
## ##
# A parser is simple a class that subclasses RDoc::Parser and implements #scan # A parser is simple a class that subclasses RDoc::Parser and implements #scan

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
require 'tsort' require 'tsort'
## ##
@ -865,8 +865,8 @@ class RDoc::Parser::C < RDoc::Parser
def handle_attr(var_name, attr_name, read, write) def handle_attr(var_name, attr_name, read, write)
rw = '' rw = ''
rw << 'R' if '1' == read rw += 'R' if '1' == read
rw << 'W' if '1' == write rw += 'W' if '1' == write
class_name = @known_classes[var_name] 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 if new_definition.empty? then # Default to literal C definition
new_definition = definition new_definition = definition
else else
new_definition.gsub!("\:", ":") new_definition = new_definition.gsub("\:", ":")
new_definition.gsub!("\\", '\\') new_definition = new_definition.gsub("\\", '\\')
end end
new_definition.sub!(/\A(\s+)/, '') new_definition.sub!(/\A(\s+)/, '')
@ -1237,7 +1237,7 @@ class RDoc::Parser::C < RDoc::Parser
# when scanning for classes and methods # when scanning for classes and methods
def remove_commented_out_lines def remove_commented_out_lines
@content.gsub!(%r%//.*rb_define_%, '//') @content = @content.gsub(%r%//.*rb_define_%, '//')
end end
## ##

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
require 'time' require 'time'
## ##
@ -29,13 +29,13 @@ class RDoc::Parser::ChangeLog < RDoc::Parser
if last =~ /\)\s*\z/ and continuation =~ /\A\(/ then if last =~ /\)\s*\z/ and continuation =~ /\A\(/ then
last.sub!(/\)\s*\z/, ',') last.sub!(/\)\s*\z/, ',')
continuation.sub!(/\A\(/, '') continuation = continuation.sub(/\A\(/, '')
end end
if last =~ /\s\z/ then if last =~ /\s\z/ then
last << continuation last << continuation
else else
last << ' ' << continuation last << ' ' + continuation
end end
end end
@ -162,12 +162,12 @@ class RDoc::Parser::ChangeLog < RDoc::Parser
entry_body = [] entry_body = []
when /^(\t| {8})?\*\s*(.*)/ then # "\t* file.c (func): ..." when /^(\t| {8})?\*\s*(.*)/ then # "\t* file.c (func): ..."
entry_body << $2 entry_body << $2.dup
when /^(\t| {8})?\s*(\(.*)/ then # "\t(func): ..." when /^(\t| {8})?\s*(\(.*)/ then # "\t(func): ..."
entry = $2 entry = $2
if entry_body.last =~ /:/ then if entry_body.last =~ /:/ then
entry_body << entry entry_body << entry.dup
else else
continue_entry_body entry_body, entry continue_entry_body entry_body, entry
end end

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# Parse a Markdown format file. The parsed RDoc::Markup::Document is attached # Parse a Markdown format file. The parsed RDoc::Markup::Document is attached
# as a file comment. # as a file comment.

View file

@ -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 # Parse a RD format file. The parsed RDoc::Markup::Document is attached as a
# file comment. # file comment.

View file

@ -1,6 +1,9 @@
require 'ripper' require 'ripper'
class RDoc::RipperStateLex 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_NONE = 0
EXPR_BEG = 1 EXPR_BEG = 1
EXPR_END = 2 EXPR_END = 2
@ -283,8 +286,23 @@ class RDoc::RipperStateLex
@callback = block @callback = block
parse parse
end end
end unless RIPPER_HAS_LEX_STATE
class InnerStateLex < Ripper::Filter
def initialize(code)
super(code)
end 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 def get_squashed_tk
if @buf.empty? if @buf.empty?
tk = @inner_lex_enumerator.next tk = @inner_lex_enumerator.next
@ -297,10 +315,10 @@ class RDoc::RipperStateLex
when :on_tstring_beg then when :on_tstring_beg then
tk = get_string_tk(tk) tk = get_string_tk(tk)
when :on_backtick then when :on_backtick then
if (EXPR_FNAME & tk[:state]) != 0 if (tk[:state] & (EXPR_FNAME | EXPR_ENDFN)) != 0
@inner_lex.lex_state = EXPR_ARG @inner_lex.lex_state = EXPR_ARG unless RIPPER_HAS_LEX_STATE
tk[:kind] = :on_ident 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 else
tk = get_string_tk(tk) tk = get_string_tk(tk)
end end
@ -310,7 +328,7 @@ class RDoc::RipperStateLex
tk = get_embdoc_tk(tk) tk = get_embdoc_tk(tk)
when :on_heredoc_beg then when :on_heredoc_beg then
@heredoc_queue << retrieve_heredoc_info(tk) @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 when :on_nl, :on_ignored_nl, :on_comment, :on_heredoc_end then
unless @heredoc_queue.empty? unless @heredoc_queue.empty?
get_heredoc_tk(*@heredoc_queue.shift) get_heredoc_tk(*@heredoc_queue.shift)
@ -540,10 +558,10 @@ class RDoc::RipperStateLex
private def get_op_tk(tk) private def get_op_tk(tk)
redefinable_operators = %w[! != !~ % & * ** + +@ - -@ / < << <= <=> == === =~ > >= >> [] []= ^ ` | ~] redefinable_operators = %w[! != !~ % & * ** + +@ - -@ / < << <= <=> == === =~ > >= >> [] []= ^ ` | ~]
if redefinable_operators.include?(tk[:text]) and EXPR_ARG == tk[:state] then if redefinable_operators.include?(tk[:text]) and tk[:state] == EXPR_ARG then
@inner_lex.lex_state = EXPR_ARG @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[:kind] = :on_ident
tk[:state] = @inner_lex.lex_state
elsif tk[:text] =~ /^[-+]$/ then elsif tk[:text] =~ /^[-+]$/ then
tk_ahead = get_squashed_tk tk_ahead = get_squashed_tk
case tk_ahead[:kind] case tk_ahead[:kind]

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# This file contains stuff stolen outright from: # This file contains stuff stolen outright from:
# #
@ -239,8 +239,8 @@ class RDoc::Parser::Ruby < RDoc::Parser
def collect_first_comment def collect_first_comment
skip_tkspace skip_tkspace
comment = '' comment = ''.dup
comment.force_encoding @encoding if @encoding comment = RDoc::Encoding.change_encoding comment, @encoding if @encoding
first_line = true first_line = true
first_comment_tk_kind = nil first_comment_tk_kind = nil
@ -318,8 +318,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
end end
## ##
# Looks for a true or false token. Returns false if TkFALSE or TkNIL are # Looks for a true or false token.
# found.
def get_bool def get_bool
skip_tkspace skip_tkspace
@ -342,7 +341,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
def get_class_or_module container, ignore_constants = false def get_class_or_module container, ignore_constants = false
skip_tkspace skip_tkspace
name_t = get_tk name_t = get_tk
given_name = '' given_name = ''.dup
# class ::A -> A is in the top level # class ::A -> A is in the top level
if :on_op == name_t[:kind] and '::' == name_t[:text] then # bug 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 if prev_container == container and !ignore_constants
given_name = name_t[:text] given_name = name_t[:text]
else else
given_name << '::' << name_t[:text] given_name << '::' + name_t[:text]
end end
end end
@ -574,27 +573,28 @@ class RDoc::Parser::Ruby < RDoc::Parser
# #
# This routine modifies its +comment+ parameter. # This routine modifies its +comment+ parameter.
def look_for_directives_in context, comment def look_for_directives_in container, comment
@preprocess.handle comment, context do |directive, param| @preprocess.handle comment, container do |directive, param|
case directive case directive
when 'method', 'singleton-method', when 'method', 'singleton-method',
'attr', 'attr_accessor', 'attr_reader', 'attr_writer' then 'attr', 'attr_accessor', 'attr_reader', 'attr_writer' then
false # handled elsewhere false # handled elsewhere
when 'section' then 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 = '' comment.text = ''
break break
end end
end end
remove_private_comments comment comment.remove_private
end end
## ##
# Adds useful info about the parser to +message+ # Adds useful info about the parser to +message+
def make_message message def make_message message
prefix = "#{@file_name}:" prefix = "#{@file_name}:".dup
tk = peek_tk tk = peek_tk
prefix << "#{tk[:line_no]}:#{tk[:char_no]}:" if tk prefix << "#{tk[:line_no]}:#{tk[:char_no]}:" if tk
@ -913,7 +913,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
return unless body return unless body
value.replace body con.value = body
record_location con record_location con
con.line = line_no con.line = line_no
read_documentation_modifiers con, RDoc::CONSTANT_MODIFIERS 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: def parse_constant_body container, constant, is_array_or_hash # :nodoc:
nest = 0 nest = 0
rhs_name = '' rhs_name = ''.dup
get_tkread get_tkread
@ -944,7 +944,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
elsif (:on_kw == tk[:kind] && 'def' == tk[:text]) then elsif (:on_kw == tk[:kind] && 'def' == tk[:text]) then
nest += 1 nest += 1
elsif (:on_kw == tk[:kind] && %w{do if unless case begin}.include?(tk[:text])) then 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 nest += 1
end end
elsif [:on_rparen, :on_rbrace, :on_rbracket].include?(tk[:kind]) || elsif [:on_rparen, :on_rbrace, :on_rbracket].include?(tk[:kind]) ||
@ -990,14 +990,13 @@ class RDoc::Parser::Ruby < RDoc::Parser
column = tk[:char_no] column = tk[:char_no]
line_no = tk[:line_no] line_no = tk[:line_no]
text = comment.text comment.text = comment.text.sub(/(^# +:?)(singleton-)(method:)/, '\1\3')
singleton = !!$~
singleton = !!text.sub!(/(^# +:?)(singleton-)(method:)/, '\1\3')
co = co =
if text.sub!(/^# +:?method: *(\S*).*?\n/i, '') then if (comment.text = comment.text.sub(/^# +:?method: *(\S*).*?\n/i, '')) && !!$~ then
parse_comment_ghost container, text, $1, column, line_no, comment parse_comment_ghost container, comment.text, $1, column, line_no, comment
elsif text.sub!(/# +:?(attr(_reader|_writer|_accessor)?): *(\S*).*?\n/i, '') then elsif (comment.text = comment.text.sub(/# +:?(attr(_reader|_writer|_accessor)?): *(\S*).*?\n/i, '')) && !!$~ then
parse_comment_attr container, $1, $3, comment parse_comment_attr container, $1, $3, comment
end end
@ -1194,7 +1193,9 @@ class RDoc::Parser::Ruby < RDoc::Parser
tmp = RDoc::CodeObject.new tmp = RDoc::CodeObject.new
read_documentation_modifiers tmp, RDoc::ATTR_MODIFIERS 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 rw = case $1
when 'attr_reader' then 'R' when 'attr_reader' then 'R'
when 'attr_writer' then 'W' when 'attr_writer' then 'W'
@ -1227,7 +1228,8 @@ class RDoc::Parser::Ruby < RDoc::Parser
skip_tkspace false 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 name = parse_meta_method_name comment, tk
@ -1290,6 +1292,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
token_listener meth do token_listener meth do
meth.params = '' meth.params = ''
look_for_directives_in meth, comment
comment.normalize comment.normalize
comment.extract_call_seq meth comment.extract_call_seq meth
@ -1336,6 +1339,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
return unless name return unless name
meth = RDoc::AnyMethod.new get_tkread, name meth = RDoc::AnyMethod.new get_tkread, name
look_for_directives_in meth, comment
meth.singleton = single == SINGLE ? true : singleton meth.singleton = single == SINGLE ? true : singleton
record_location meth record_location meth
@ -1458,8 +1462,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
name_t2 = get_tk name_t2 = get_tk
if (:on_kw == name_t[:kind] && 'self' == name_t[:text]) || (:on_op == name_t[:kind] && '%' == name_t[:text]) then 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 # NOTE: work around '[' being consumed early
# as a TkAREF
if :on_lbracket == name_t2[:kind] if :on_lbracket == name_t2[:kind]
get_tk get_tk
name = '[]' name = '[]'
@ -1535,7 +1538,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
when :on_comment, :on_embdoc then when :on_comment, :on_embdoc then
@read.pop @read.pop
if :on_nl == end_token[:kind] and "\n" == tk[:text][-1] and 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 if method && method.block_params.nil? then
unget_tk tk unget_tk tk
read_documentation_modifiers method, modifiers read_documentation_modifiers method, modifiers
@ -1642,7 +1645,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
def parse_statements(container, single = NORMAL, current_method = nil, def parse_statements(container, single = NORMAL, current_method = nil,
comment = new_comment('')) comment = new_comment(''))
raise 'no' unless RDoc::Comment === comment raise 'no' unless RDoc::Comment === comment
comment.force_encoding @encoding if @encoding comment = RDoc::Encoding.change_encoding comment, @encoding if @encoding
nest = 1 nest = 1
save_visibility = container.visibility save_visibility = container.visibility
@ -1685,12 +1688,12 @@ class RDoc::Parser::Ruby < RDoc::Parser
comment.empty? comment.empty?
comment = '' comment = ''
comment.force_encoding @encoding if @encoding comment = RDoc::Encoding.change_encoding comment, @encoding if @encoding
end end
while tk and (:on_comment == tk[:kind] or :on_embdoc == tk[:kind]) do while tk and (:on_comment == tk[:kind] or :on_embdoc == tk[:kind]) do
comment << tk[:text] comment += tk[:text]
comment << "\n" unless "\n" == tk[:text].chars.to_a.last comment += "\n" unless "\n" == tk[:text].chars.to_a.last
if tk[:text].size > 1 && "\n" == tk[:text].chars.to_a.last then if tk[:text].size > 1 && "\n" == tk[:text].chars.to_a.last then
skip_tkspace false # leading spaces skip_tkspace false # leading spaces
@ -1740,7 +1743,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
end end
when 'until', 'while' then when 'until', 'while' then
if (RDoc::RipperStateLex::EXPR_LABEL & tk[:state]) == 0 if (tk[:state] & RDoc::RipperStateLex::EXPR_LABEL) == 0
nest += 1 nest += 1
skip_optional_do_after_expression skip_optional_do_after_expression
end end
@ -1756,7 +1759,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
skip_optional_do_after_expression skip_optional_do_after_expression
when 'case', 'do', 'if', 'unless', 'begin' then 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 nest += 1
end end
@ -1809,7 +1812,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
unless keep_comment then unless keep_comment then
comment = new_comment '' comment = new_comment ''
comment.force_encoding @encoding if @encoding comment = RDoc::Encoding.change_encoding comment, @encoding if @encoding
container.params = nil container.params = nil
container.block_params = nil container.block_params = nil
end end
@ -2053,15 +2056,6 @@ class RDoc::Parser::Ruby < RDoc::Parser
container.record_location @top_level container.record_location @top_level
end end
##
# Removes private comments from +comment+
#--
# TODO remove
def remove_private_comments comment
comment.remove_private
end
## ##
# Scans this Ruby file for Ruby constructs # Scans this Ruby file for Ruby constructs

View file

@ -1,7 +1,6 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# Collection of methods for writing parsers against RDoc::RubyLex and # Collection of methods for writing parsers
# RDoc::RubyToken
module RDoc::Parser::RubyTools module RDoc::Parser::RubyTools

View file

@ -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 # Parse a non-source file. We basically take the whole thing as one big
# comment. # comment.
@ -19,7 +19,7 @@ class RDoc::Parser::Simple < RDoc::Parser
preprocess = RDoc::Markup::PreProcess.new @file_name, @options.rdoc_include preprocess = RDoc::Markup::PreProcess.new @file_name, @options.rdoc_include
preprocess.handle @content, @top_level @content = preprocess.handle @content, @top_level
end end
## ##
@ -52,7 +52,7 @@ class RDoc::Parser::Simple < RDoc::Parser
def remove_private_comment comment def remove_private_comment comment
# Workaround for gsub encoding for Ruby 1.9.2 and earlier # Workaround for gsub encoding for Ruby 1.9.2 and earlier
empty = '' empty = ''
empty.force_encoding comment.encoding empty = RDoc::Encoding.change_encoding empty, comment.encoding
comment = comment.gsub(%r%^--\n.*?^\+\+\n?%m, empty) comment = comment.gsub(%r%^--\n.*?^\+\+\n?%m, empty)
comment.sub(%r%^--\n.*%m, empty) comment.sub(%r%^--\n.*%m, empty)

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# Indicates this parser is text and doesn't contain code constructs. # Indicates this parser is text and doesn't contain code constructs.
# #

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# RDoc::RD implements the RD format from the rdtool gem. # RDoc::RD implements the RD format from the rdtool gem.
# #

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# Inline keeps track of markup and labels to create proper links. # Inline keeps track of markup and labels to create proper links.
@ -50,11 +50,11 @@ class RDoc::RD::Inline
def append more def append more
case more case more
when String then when String then
@reference << more @reference += more
@rdoc << more @rdoc += more
when RDoc::RD::Inline then when RDoc::RD::Inline then
@reference << more.reference @reference += more.reference
@rdoc << more.rdoc @rdoc += more.rdoc
else else
raise "unknown thingy #{more}" raise "unknown thingy #{more}"
end end

View file

@ -412,9 +412,9 @@ racc_action_default = [
racc_goto_table = [ racc_goto_table = [
126, 44, 125, 52, 144, 144, 160, 93, 97, 43, 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, 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, 35, 170, 58, 166, 167, 147, 170, 166, 37, nil,
150, nil, 166, 159, 4, 166, 4, nil, nil, nil, 150, nil, 166, 159, 4, 166, 4, nil, nil, nil,
nil, 155, nil, 156, 160, nil, nil, 4, 4, 4, nil, 155, nil, 156, 160, nil, nil, 4, 4, 4,
@ -430,9 +430,9 @@ racc_goto_table = [
racc_goto_check = [ racc_goto_check = [
22, 24, 21, 34, 36, 36, 37, 18, 16, 23, 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, 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, 1, 33, 1, 35, 29, 32, 33, 35, 15, nil,
41, nil, 35, 22, 4, 35, 4, nil, nil, nil, 41, nil, 35, 22, 4, 35, 4, nil, nil, nil,
nil, 16, nil, 18, 37, nil, nil, 4, 4, 4, nil, 16, nil, 18, 37, nil, nil, 4, 4, 4,
@ -448,8 +448,8 @@ racc_goto_check = [
racc_goto_pointer = [ racc_goto_pointer = [
nil, 23, nil, 29, 54, 74, 109, 117, 127, nil, nil, 23, nil, 29, 54, 74, 109, 117, 127, nil,
nil, 135, nil, 2, -17, 30, -30, -3, -29, -5, nil, 135, nil, 2, -17, 30, -30, -3, -29, -4,
-4, -40, -42, -9, -17, -28, nil, nil, -120, -83, -5, -40, -42, -9, -17, -28, nil, nil, -120, -83,
nil, nil, -7, -101, -15, -116, -40, -91, 8, 2, nil, nil, -7, -101, -15, -116, -40, -91, 8, 2,
nil, -9, -29 ] nil, -9, -29 ]

File diff suppressed because one or more lines are too long

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
require 'rdoc' require 'rdoc'
require 'find' require 'find'
@ -521,6 +521,10 @@ The internal error was:
# by the RDoc options # by the RDoc options
def generate def generate
if @options.dry_run then
# do nothing
@generator.generate
else
Dir.chdir @options.op_dir do Dir.chdir @options.op_dir do
unless @options.quiet then unless @options.quiet then
$stderr.puts "\nGenerating #{@generator.class.name.sub(/^.*::/, '')} format into #{Dir.pwd}..." $stderr.puts "\nGenerating #{@generator.class.name.sub(/^.*::/, '')} format into #{Dir.pwd}..."
@ -530,6 +534,7 @@ The internal error was:
update_output_dir '.', @start_time, @last_modified update_output_dir '.', @start_time, @last_modified
end end
end end
end
## ##
# Removes a siginfo handler and replaces the previous # Removes a siginfo handler and replaces the previous

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# A file loaded by \#require # A file loaded by \#require

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
require 'rdoc' require 'rdoc'
## ##

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
require 'abbrev' require 'abbrev'
require 'optparse' require 'optparse'

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
## ##
# For RubyGems backwards compatibility # For RubyGems backwards compatibility

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
require 'rdoc/ri' require 'rdoc/ri'
## ##

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
module RDoc::RI module RDoc::RI
Store = RDoc::Store # :nodoc: Store = RDoc::Store # :nodoc:

View file

@ -1,4 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: true
begin begin
gem 'rdoc' gem 'rdoc'
rescue Gem::LoadError rescue Gem::LoadError

Some files were not shown because too many files have changed in this diff Show more