Merge RDoc 6.0.3 from upstream.

It fixed the several bugs that was found after RDoc 6 releasing.

From: SHIBATA Hiroshi <hsbt@ruby-lang.org>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62924 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
hsbt 2018-03-26 05:56:26 +00:00
Родитель ee83dc3fe4
Коммит 98c7058bf7
94 изменённых файлов: 983 добавлений и 466 удалений

Просмотреть файл

@ -65,7 +65,7 @@ module RDoc
##
# RDoc version you are using
VERSION = '6.0.1'
VERSION = '6.0.3'
##
# Method visibilities
@ -125,8 +125,6 @@ module RDoc
autoload :RDoc, 'rdoc/rdoc'
autoload :TestCase, 'rdoc/test_case'
autoload :CrossReference, 'rdoc/cross_reference'
autoload :ERBIO, 'rdoc/erbio'
autoload :ERBPartial, 'rdoc/erb_partial'
@ -153,7 +151,7 @@ module RDoc
autoload :Comment, 'rdoc/comment'
autoload :I18n, 'rdoc/i18n'
require 'rdoc/i18n'
# code objects
#

Просмотреть файл

@ -407,6 +407,7 @@ class RDoc::Context < RDoc::CodeObject
mod.section = current_section # TODO declaring context? something is
# wrong here...
mod.parent = self
mod.full_name = nil
mod.store = @store
unless @done_documenting then
@ -414,6 +415,10 @@ class RDoc::Context < RDoc::CodeObject
# this must be done AFTER adding mod to its parent, so that the full
# name is correct:
all_hash[mod.full_name] = mod
if @store.unmatched_constant_alias[mod.full_name] then
to, file = @store.unmatched_constant_alias[mod.full_name]
add_module_alias mod, mod.name, to, file
end
end
mod
@ -510,41 +515,53 @@ class RDoc::Context < RDoc::CodeObject
add_class_or_module mod, @modules, @store.modules_hash
end
##
# Adds a module by +RDoc::NormalModule+ instance. See also #add_module.
def add_module_by_normal_module(mod)
add_class_or_module mod, @modules, @store.modules_hash
end
##
# Adds an alias from +from+ (a class or module) to +name+ which was defined
# in +file+.
def add_module_alias from, name, file
def add_module_alias from, from_name, to, file
return from if @done_documenting
to_name = child_name name
to_full_name = child_name to.name
# if we already know this name, don't register an alias:
# see the metaprogramming in lib/active_support/basic_object.rb,
# where we already know BasicObject is a class when we find
# BasicObject = BlankSlate
return from if @store.find_class_or_module to_name
return from if @store.find_class_or_module to_full_name
to = from.dup
to.name = name
to.full_name = nil
unless from
@store.unmatched_constant_alias[child_name(from_name)] = [to, file]
return to
end
if to.module? then
@store.modules_hash[to_name] = to
@modules[name] = to
new_to = from.dup
new_to.name = to.name
new_to.full_name = nil
if new_to.module? then
@store.modules_hash[to_full_name] = new_to
@modules[to.name] = new_to
else
@store.classes_hash[to_name] = to
@classes[name] = to
@store.classes_hash[to_full_name] = new_to
@classes[to.name] = new_to
end
# Registers a constant for this alias. The constant value and comment
# will be updated later, when the Ruby parser adds the constant
const = RDoc::Constant.new name, nil, to.comment
const = RDoc::Constant.new to.name, nil, new_to.comment
const.record_location file
const.is_alias_for = from
add_constant const
to
new_to
end
##
@ -863,7 +880,13 @@ class RDoc::Context < RDoc::CodeObject
# Finds a method named +name+ with singleton value +singleton+.
def find_method(name, singleton)
@method_list.find { |m| m.name == name && m.singleton == singleton }
@method_list.find { |m|
if m.singleton
m.name == name && m.singleton == singleton
else
m.name == name && !m.singleton && !singleton
end
}
end
##

Просмотреть файл

@ -7,6 +7,18 @@
module RDoc::Encoding
HEADER_REGEXP = /^
(?:
\A\#!.*\n
|
^\#\s+frozen[-_]string[-_]literal[=:].+\n
|
^\#[^\n]+\b(?:en)?coding[=:]\s*(?<name>[^\s;]+).*\n
|
<\?xml[^?]*encoding=(?<quote>["'])(?<name>.*?)\k<quote>.*\n
)+
/xi # :nodoc:
##
# Reads the contents of +filename+ and handles any encoding directives in
# the file.
@ -18,12 +30,13 @@ module RDoc::Encoding
# unknown character in the target encoding will be replaced with '?'
def self.read_file filename, encoding, force_transcode = false
content = open filename, "rb" do |f| f.read end
content = File.open filename, "rb" do |f| f.read end
content.gsub!("\r\n", "\n") if RUBY_PLATFORM =~ /mswin|mingw/
utf8 = content.sub!(/\A\xef\xbb\xbf/, '')
content = RDoc::Encoding.set_encoding content
enc = RDoc::Encoding.detect_encoding content
content = RDoc::Encoding.change_encoding content, enc if enc
begin
encoding ||= Encoding.default_external
@ -85,29 +98,22 @@ module RDoc::Encoding
end
##
# Sets the encoding of +string+ based on the magic comment
# Detects the encoding of +string+ based on the magic comment
def self.set_encoding string
string = remove_frozen_string_literal string
def self.detect_encoding string
result = HEADER_REGEXP.match string
name = result && result[:name]
string =~ /\A(?:#!.*\n)?(.*\n)/
name ? Encoding.find(name) : nil
end
first_line = $1
##
# Removes magic comments and shebang
name = case first_line
when /^<\?xml[^?]*encoding=(["'])(.*?)\1/ then $2
when /\b(?:en)?coding[=:]\s*([^\s;]+)/i then $1
else return string
end
string = string.sub first_line, ''
string = remove_frozen_string_literal string
enc = Encoding.find name
string = RDoc::Encoding.change_encoding string, enc if enc
string
def self.remove_magic_comment string
string.sub HEADER_REGEXP do |s|
s.gsub(/[^\n]/, '')
end
end
##

Просмотреть файл

@ -9,7 +9,7 @@ require 'erb'
#
# erbio = RDoc::ERBIO.new '<%= "hello world" %>', nil, nil
#
# open 'hello.txt', 'w' do |io|
# File.open 'hello.txt', 'w' do |io|
# erbio.result binding
# end
#

Просмотреть файл

@ -147,12 +147,15 @@ class RDoc::Generator::JsonIndex
JSON.dump data, io, 0
end
unless ENV['SOURCE_DATE_EPOCH'].nil?
index_file.utime index_file.atime, Time.at(ENV['SOURCE_DATE_EPOCH'].to_i).gmtime
end
Dir.chdir @template_dir do
Dir['**/*.js'].each do |source|
dest = File.join out_dir, source
FileUtils.install source, dest, :mode => 0644, :verbose => $DEBUG_RDOC
FileUtils.install source, dest, :mode => 0644, :preserve => true, :verbose => $DEBUG_RDOC
end
end
end

Просмотреть файл

@ -91,8 +91,8 @@ class RDoc::Generator::POT
extractor.extract
end
autoload :MessageExtractor, 'rdoc/generator/pot/message_extractor'
autoload :PO, 'rdoc/generator/pot/po'
autoload :POEntry, 'rdoc/generator/pot/po_entry'
require 'rdoc/generator/pot/message_extractor'
require 'rdoc/generator/pot/po'
require 'rdoc/generator/pot/po_entry'
end

Просмотреть файл

@ -5,6 +5,6 @@
module RDoc::I18n
autoload :Locale, 'rdoc/i18n/locale'
autoload :Text, 'rdoc/i18n/text'
require 'rdoc/i18n/text'
end

Просмотреть файл

@ -1,4 +1,5 @@
# coding: UTF-8
# frozen_string_literal: true
# :markup: markdown
##

Просмотреть файл

@ -1,4 +1,5 @@
# coding: UTF-8
# frozen_string_literal: true
# :markup: markdown
##

Просмотреть файл

@ -266,6 +266,7 @@ class RDoc::Markup::PreProcess
end
content = RDoc::Encoding.read_file full_name, encoding, true
content = RDoc::Encoding.remove_magic_comment content
# strip magic comment
content = content.sub(/\A# .*coding[=:].*$/, '').lstrip

Просмотреть файл

@ -1217,7 +1217,7 @@ Usage: #{opt.program_name} [options] [names...]
def write_options
RDoc.load_yaml
open '.rdoc_options', 'w' do |io|
File.open '.rdoc_options', 'w' do |io|
io.set_encoding Encoding::UTF_8
YAML.dump self, io

Просмотреть файл

@ -139,7 +139,7 @@ class RDoc::Parser
# Returns the file type from the modeline in +file_name+
def self.check_modeline file_name
line = open file_name do |io|
line = File.open file_name do |io|
io.gets
end

Просмотреть файл

@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'ripper'
class RDoc::RipperStateLex
@ -83,6 +84,15 @@ class RDoc::RipperStateLex
when '&&', '||', '+=', '-=', '*=', '**=',
'&=', '|=', '^=', '<<=', '>>=', '||=', '&&='
@lex_state = EXPR_BEG
when '::'
case @lex_state
when EXPR_ARG, EXPR_CMDARG
@lex_state = EXPR_DOT
when EXPR_FNAME, EXPR_DOT
@lex_state = EXPR_ARG
else
@lex_state = EXPR_BEG
end
else
case @lex_state
when EXPR_FNAME, EXPR_DOT
@ -109,8 +119,10 @@ class RDoc::RipperStateLex
else
@lex_state = EXPR_BEG
end
when 'begin'
when 'begin', 'case', 'when'
@lex_state = EXPR_BEG
when 'return', 'break'
@lex_state = EXPR_MID
else
if @lex_state == EXPR_FNAME
@lex_state = EXPR_END
@ -245,7 +257,7 @@ class RDoc::RipperStateLex
case @lex_state
when EXPR_FNAME
@lex_state = EXPR_ENDFN
when EXPR_CLASS
when EXPR_CLASS, EXPR_CMDARG, EXPR_MID
@lex_state = EXPR_ARG
else
@lex_state = EXPR_CMDARG
@ -330,8 +342,10 @@ class RDoc::RipperStateLex
@heredoc_queue << retrieve_heredoc_info(tk)
@inner_lex.lex_state = EXPR_END unless RIPPER_HAS_LEX_STATE
when :on_nl, :on_ignored_nl, :on_comment, :on_heredoc_end then
unless @heredoc_queue.empty?
if !@heredoc_queue.empty?
get_heredoc_tk(*@heredoc_queue.shift)
elsif tk[:text].nil? # :on_ignored_nl sometimes gives nil
tk[:text] = ''
end
when :on_words_beg then
tk = get_words_tk(tk)

Просмотреть файл

@ -177,6 +177,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
@size = 0
@token_listeners = nil
content = RDoc::Encoding.remove_magic_comment content
@scanner = RDoc::RipperStateLex.parse(content)
@content = content
@scanner_point = 0
@ -306,7 +307,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
container.find_module_named rhs_name
end
container.add_module_alias mod, constant.name, @top_level if mod
container.add_module_alias mod, rhs_name, constant, @top_level
end
##
@ -355,12 +356,15 @@ class RDoc::Parser::Ruby < RDoc::Parser
given_name << name_t[:text]
is_self = name_t[:kind] == :on_op && name_t[:text] == '<<'
new_modules = []
while !is_self && (tk = peek_tk) and :on_op == tk[:kind] and '::' == tk[:text] do
prev_container = container
container = container.find_module_named name_t[:text]
container ||=
if ignore_constants then
RDoc::Context.new
c = RDoc::NormalModule.new name_t[:text]
new_modules << [prev_container, c]
c
else
c = prev_container.add_module RDoc::NormalModule, name_t[:text]
c.ignore unless prev_container.document_children
@ -385,7 +389,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
skip_tkspace false
return [container, name_t, given_name]
return [container, name_t, given_name, new_modules]
end
##
@ -760,7 +764,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
line_no = tk[:line_no]
declaration_context = container
container, name_t, given_name = get_class_or_module container
container, name_t, given_name, = get_class_or_module container
if name_t[:kind] == :on_const
cls = parse_class_regular container, declaration_context, single,
@ -877,10 +881,11 @@ class RDoc::Parser::Ruby < RDoc::Parser
return unless name =~ /^\w+$/
new_modules = []
if :on_op == peek_tk[:kind] && '::' == peek_tk[:text] then
unget_tk tk
container, name_t, = get_class_or_module container, ignore_constants
container, name_t, _, new_modules = get_class_or_module container, true
name = name_t[:text]
end
@ -907,6 +912,14 @@ class RDoc::Parser::Ruby < RDoc::Parser
end
get_tk
unless ignore_constants
new_modules.each do |prev_c, new_module|
prev_c.add_module_by_normal_module new_module
new_module.ignore unless prev_c.document_children
@top_level.add_to_classes_or_modules new_module
end
end
value = ''
con = RDoc::Constant.new name, value, comment
@ -2074,13 +2087,16 @@ class RDoc::Parser::Ruby < RDoc::Parser
$stderr.puts @file_name
return
end
bytes = ''
if @scanner_point >= @scanner.size
now_line_no = @scanner[@scanner.size - 1][:line_no]
else
now_line_no = peek_tk[:line_no]
end
first_tk_index = @scanner.find_index { |tk| tk[:line_no] == now_line_no }
last_tk_index = @scanner.find_index { |tk| tk[:line_no] == now_line_no + 1 }
last_tk_index = last_tk_index ? last_tk_index - 1 : @scanner.size - 1
code = @scanner[first_tk_index..last_tk_index].map{ |t| t[:text] }.join
$stderr.puts <<-EOF
@ -2089,12 +2105,9 @@ class RDoc::Parser::Ruby < RDoc::Parser
EOF
unless bytes.empty? then
unless code.empty? then
$stderr.puts code
$stderr.puts
now_line_no = peek_tk[:line_no]
start_index = @scanner.find_index { |tk| tk[:line_no] == now_line_no }
end_index = @scanner.find_index { |tk| tk[:line_no] == now_line_no + 1 } - 1
$stderr.puts @scanner[start_index..end_index].join
end
raise e

Просмотреть файл

@ -1,3 +1,4 @@
# frozen_string_literal: true
#
# DO NOT MODIFY!!!!
# This file is automatically generated by Racc 1.4.14
@ -207,7 +208,7 @@ def next_token # :nodoc:
if @in_verbatim
[:STRINGLINE, line]
else
@indent_stack.push("\s" << newIndent)
@indent_stack.push("\s" + newIndent)
[:ITEMLISTLINE, rest]
end
end
@ -219,7 +220,7 @@ def next_token # :nodoc:
if @in_verbatim
[:STRINGLINE, line]
else
@indent_stack.push("\s" * mark.size << newIndent)
@indent_stack.push("\s" * mark.size + newIndent)
[:ENUMLISTLINE, rest]
end
end
@ -677,54 +678,54 @@ Racc_debug_parser = false
# reduce 0 omitted
def _reduce_1(val, _values, result)
result = RDoc::Markup::Document.new(*val[0])
result = RDoc::Markup::Document.new(*val[0])
result
end
def _reduce_2(val, _values, result)
raise ParseError, "file empty"
raise ParseError, "file empty"
result
end
def _reduce_3(val, _values, result)
result = val[0].concat val[1]
result = val[0].concat val[1]
result
end
def _reduce_4(val, _values, result)
result = val[0]
result = val[0]
result
end
def _reduce_5(val, _values, result)
result = val
result = val
result
end
def _reduce_6(val, _values, result)
result = val
result = val
result
end
# reduce 7 omitted
def _reduce_8(val, _values, result)
result = val
result = val
result
end
def _reduce_9(val, _values, result)
result = val
result = val
result
end
def _reduce_10(val, _values, result)
result = [RDoc::Markup::BlankLine.new]
result = [RDoc::Markup::BlankLine.new]
result
end
def _reduce_11(val, _values, result)
result = val[0].parts
result = val[0].parts
result
end
@ -732,30 +733,30 @@ def _reduce_12(val, _values, result)
# val[0] is like [level, title]
title = @inline_parser.parse(val[0][1])
result = RDoc::Markup::Heading.new(val[0][0], title)
result
end
def _reduce_13(val, _values, result)
result = RDoc::Markup::Include.new val[0], @include_path
result
end
def _reduce_14(val, _values, result)
# val[0] is Array of String
result = paragraph val[0]
result
end
def _reduce_15(val, _values, result)
result << val[1].rstrip
result << val[1].rstrip
result
end
def _reduce_16(val, _values, result)
result = [val[0].rstrip]
result = [val[0].rstrip]
result
end
@ -766,7 +767,7 @@ def _reduce_17(val, _values, result)
# imform to lexer.
@in_verbatim = false
result
end
@ -777,25 +778,25 @@ def _reduce_18(val, _values, result)
# imform to lexer.
@in_verbatim = false
result
end
def _reduce_19(val, _values, result)
result << val[1]
result
end
def _reduce_20(val, _values, result)
result.concat val[2]
result
end
def _reduce_21(val, _values, result)
result << "\n"
result
end
@ -803,7 +804,7 @@ def _reduce_22(val, _values, result)
result = val
# inform to lexer.
@in_verbatim = true
result
end
@ -817,89 +818,89 @@ end
def _reduce_27(val, _values, result)
result = val[0]
result
end
def _reduce_28(val, _values, result)
result = val[1]
result
end
def _reduce_29(val, _values, result)
result = val[1].push(val[2])
result
end
def _reduce_30(val, _values, result)
result = val[0] << val[1]
result = val[0] << val[1]
result
end
def _reduce_31(val, _values, result)
result = [val[0]]
result = [val[0]]
result
end
def _reduce_32(val, _values, result)
result = RDoc::Markup::List.new :BULLET, *val[0]
result
end
def _reduce_33(val, _values, result)
result.push(val[1])
result.push(val[1])
result
end
def _reduce_34(val, _values, result)
result = val
result = val
result
end
def _reduce_35(val, _values, result)
result = RDoc::Markup::ListItem.new nil, val[0], *val[1]
result
end
def _reduce_36(val, _values, result)
result = RDoc::Markup::List.new :NUMBER, *val[0]
result
end
def _reduce_37(val, _values, result)
result.push(val[1])
result.push(val[1])
result
end
def _reduce_38(val, _values, result)
result = val
result = val
result
end
def _reduce_39(val, _values, result)
result = RDoc::Markup::ListItem.new nil, val[0], *val[1]
result
end
def _reduce_40(val, _values, result)
result = RDoc::Markup::List.new :NOTE, *val[0]
result
end
def _reduce_41(val, _values, result)
result.push(val[1])
result.push(val[1])
result
end
def _reduce_42(val, _values, result)
result = val
result = val
result
end
@ -907,77 +908,77 @@ def _reduce_43(val, _values, result)
term = @inline_parser.parse val[0].strip
result = RDoc::Markup::ListItem.new term, *val[1]
result
end
def _reduce_44(val, _values, result)
result = RDoc::Markup::List.new :LABEL, *val[0]
result
end
def _reduce_45(val, _values, result)
result.push(val[1])
result.push(val[1])
result
end
def _reduce_46(val, _values, result)
result = val
result = val
result
end
def _reduce_47(val, _values, result)
result = RDoc::Markup::ListItem.new "<tt>#{val[0].strip}</tt>", *val[1]
result
end
def _reduce_48(val, _values, result)
result = [val[1]].concat(val[2])
result
end
def _reduce_49(val, _values, result)
result = [val[1]]
result
end
def _reduce_50(val, _values, result)
result = val[2]
result
end
def _reduce_51(val, _values, result)
result = []
result
end
def _reduce_52(val, _values, result)
result.concat val[1]
result.concat val[1]
result
end
# reduce 53 omitted
def _reduce_54(val, _values, result)
result = val
result = val
result
end
def _reduce_55(val, _values, result)
result = val
result = val
result
end
# reduce 56 omitted
def _reduce_57(val, _values, result)
result = []
result = []
result
end
@ -991,58 +992,58 @@ end
def _reduce_62(val, _values, result)
result = paragraph [val[0]].concat(val[1])
result
end
def _reduce_63(val, _values, result)
result = paragraph [val[0]]
result
end
def _reduce_64(val, _values, result)
result = paragraph [val[0]].concat(val[1])
result
end
def _reduce_65(val, _values, result)
result = paragraph [val[0]]
result
end
def _reduce_66(val, _values, result)
result = [val[0]].concat(val[1])
result
end
def _reduce_67(val, _values, result)
result.concat val[1]
result.concat val[1]
result
end
def _reduce_68(val, _values, result)
result = val[1]
result = val[1]
result
end
def _reduce_69(val, _values, result)
result = val
result = val
result
end
# reduce 70 omitted
def _reduce_71(val, _values, result)
result = []
result = []
result
end
def _reduce_72(val, _values, result)
result = []
result = []
result
end

Просмотреть файл

@ -1,3 +1,4 @@
# frozen_string_literal: true
#
# DO NOT MODIFY!!!!
# This file is automatically generated by Racc 1.4.14
@ -96,7 +97,7 @@ end
def parse inline
@inline = inline
@src = StringScanner.new inline
@pre = ""
@pre = "".dup
@yydebug = true
do_parse.to_s
end
@ -732,12 +733,12 @@ Racc_debug_parser = false
# reduce 1 omitted
def _reduce_2(val, _values, result)
result.append val[1]
result.append val[1]
result
end
def _reduce_3(val, _values, result)
result = val[0]
result = val[0]
result
end
@ -762,28 +763,28 @@ end
def _reduce_13(val, _values, result)
content = val[1]
result = inline "<em>#{content}</em>", content
result
end
def _reduce_14(val, _values, result)
content = val[1]
result = inline "<code>#{content}</code>", 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 "<tt>#{content}</tt>", content
result
end
@ -791,13 +792,13 @@ def _reduce_17(val, _values, result)
label = val[1]
@block_parser.add_label label.reference
result = "<span id=\"label-#{label}\">#{label}</span>"
result
end
def _reduce_18(val, _values, result)
result = "{#{val[1]}}[#{val[2].join}]"
result
end
@ -805,13 +806,13 @@ def _reduce_19(val, _values, result)
scheme, inline = val[1]
result = "{#{inline}}[#{scheme}#{inline.reference}]"
result
end
def _reduce_20(val, _values, result)
result = [nil, inline(val[1])]
result
end
@ -820,25 +821,25 @@ def _reduce_21(val, _values, result)
'rdoc-label:',
inline("#{val[0].reference}/#{val[1].reference}")
]
result
end
def _reduce_22(val, _values, result)
result = ['rdoc-label:', val[0].reference]
result
end
def _reduce_23(val, _values, result)
result = ['rdoc-label:', "#{val[0].reference}/"]
result
end
def _reduce_24(val, _values, result)
result = [nil, inline(val[1])]
result
end
@ -847,92 +848,92 @@ def _reduce_25(val, _values, result)
'rdoc-label:',
inline("#{val[0].reference}/#{val[1].reference}")
]
result
end
def _reduce_26(val, _values, result)
result = ['rdoc-label:', val[0]]
result
end
def _reduce_27(val, _values, result)
ref = val[0].reference
result = ['rdoc-label:', inline(ref, "#{ref}/")]
result
end
# reduce 28 omitted
def _reduce_29(val, _values, result)
result = val[1]
result = val[1]
result
end
def _reduce_30(val, _values, result)
result = val[1]
result = val[1]
result
end
def _reduce_31(val, _values, result)
result = inline val[0]
result
end
def _reduce_32(val, _values, result)
result = inline "\"#{val[1]}\""
result
end
def _reduce_33(val, _values, result)
result = inline val[0]
result
end
def _reduce_34(val, _values, result)
result = inline "\"#{val[1]}\""
result
end
# reduce 35 omitted
def _reduce_36(val, _values, result)
result = val[1]
result = val[1]
result
end
def _reduce_37(val, _values, result)
result = inline val[1]
result = inline val[1]
result
end
def _reduce_38(val, _values, result)
result = val[0].append val[1]
result
end
def _reduce_39(val, _values, result)
result = val[0].append val[1]
result
end
def _reduce_40(val, _values, result)
result = val[0]
result
end
def _reduce_41(val, _values, result)
result = inline val[0]
result
end
@ -940,25 +941,25 @@ end
def _reduce_43(val, _values, result)
result = val[0].append val[1]
result
end
def _reduce_44(val, _values, result)
result = inline val[0]
result
end
def _reduce_45(val, _values, result)
result = val[0].append val[1]
result
end
def _reduce_46(val, _values, result)
result = val[0]
result
end
@ -984,24 +985,24 @@ end
def _reduce_57(val, _values, result)
result = val[0]
result
end
def _reduce_58(val, _values, result)
result = inline val[0]
result
end
def _reduce_59(val, _values, result)
result = inline val[0]
result
end
def _reduce_60(val, _values, result)
result << val[1]
result << val[1]
result
end
@ -1009,7 +1010,7 @@ end
def _reduce_62(val, _values, result)
result << val[1]
result
end
@ -1017,7 +1018,7 @@ end
def _reduce_64(val, _values, result)
result << val[1]
result
end
@ -1048,7 +1049,7 @@ end
# reduce 77 omitted
def _reduce_78(val, _values, result)
result << val[1]
result << val[1]
result
end
@ -1099,13 +1100,13 @@ end
def _reduce_101(val, _values, result)
index = @block_parser.add_footnote val[1].rdoc
result = "{*#{index}}[rdoc-label:foottext-#{index}:footmark-#{index}]"
result
end
def _reduce_102(val, _values, result)
result = inline "<tt>#{val[1]}</tt>", val[1]
result
end
@ -1122,7 +1123,7 @@ end
# reduce 108 omitted
def _reduce_109(val, _values, result)
result << val[1]
result << val[1]
result
end
@ -1130,24 +1131,24 @@ end
def _reduce_111(val, _values, result)
result = inline val[0]
result
end
# reduce 112 omitted
def _reduce_113(val, _values, result)
result = val[1]
result = val[1]
result
end
def _reduce_114(val, _values, result)
result = val[1]
result = val[1]
result
end
def _reduce_115(val, _values, result)
result = val[1]
result = val[1]
result
end
@ -1192,7 +1193,7 @@ end
# reduce 135 omitted
def _reduce_136(val, _values, result)
result << val[1]
result << val[1]
result
end

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -35,11 +35,6 @@ class RDoc::RDoc
GENERATORS = {}
##
# File pattern to exclude
attr_accessor :exclude
##
# Generator instance used for creating output
@ -93,7 +88,6 @@ class RDoc::RDoc
def initialize
@current = nil
@exclude = nil
@generator = nil
@last_modified = {}
@old_siginfo = nil
@ -116,7 +110,7 @@ class RDoc::RDoc
def gather_files files
files = ["."] if files.empty?
file_list = normalized_file_list files, true, @exclude
file_list = normalized_file_list files, true, @options.exclude
file_list = file_list.uniq
@ -188,7 +182,7 @@ class RDoc::RDoc
error "#{dir} exists and is not a directory" unless File.directory? dir
begin
open flag_file do |io|
File.open flag_file do |io|
unless force then
Time.parse io.gets
@ -232,8 +226,11 @@ option)
def update_output_dir(op_dir, time, last = {})
return if @options.dry_run or not @options.update_output_dir
unless ENV['SOURCE_DATE_EPOCH'].nil?
time = Time.at(ENV['SOURCE_DATE_EPOCH'].to_i).gmtime
end
open output_flag_file(op_dir), "w" do |f|
File.open output_flag_file(op_dir), "w" do |f|
f.puts time.rfc2822
last.each do |n, t|
f.puts "#{n}\t#{t.rfc2822}"
@ -261,7 +258,7 @@ option)
patterns.split.each do |patt|
candidates = Dir.glob(File.join(in_dir, patt))
result.concat normalized_file_list(candidates)
result.concat normalized_file_list(candidates, false, @options.exclude)
end
result
@ -469,8 +466,6 @@ The internal error was:
exit
end
@exclude = @options.exclude
unless @options.coverage_report then
@last_modified = setup_output_dir @options.op_dir, @options.force_update
end

Просмотреть файл

@ -110,7 +110,7 @@ class RDoc::RI::Driver
def self.dump data_path
require 'pp'
open data_path, 'rb' do |io|
File.open data_path, 'rb' do |io|
pp Marshal.load(io.read)
end
end
@ -425,6 +425,7 @@ or the PAGER environment variable.
@server = options[:server]
@use_stdout = options[:use_stdout]
@show_all = options[:show_all]
@width = options[:width]
# pager process for jruby
@jruby_pager_process = nil
@ -795,7 +796,9 @@ or the PAGER environment variable.
def display document
page do |io|
text = document.accept formatter(io)
f = formatter(io)
f.width = @width if @width and f.respond_to?(:width)
text = document.accept f
io.write text
end
@ -1440,7 +1443,13 @@ or the PAGER environment variable.
render_method_arguments out, method.arglists
render_method_superclass out, method
render_method_comment out, method
if method.is_alias_for
al = method.is_alias_for
alias_for = store.load_method al.parent_name, "#{al.name_prefix}#{al.name}"
render_method_comment out, method, alias_for
else
render_method_comment out, method
end
end
def render_method_arguments out, arglists # :nodoc:
@ -1452,10 +1461,22 @@ or the PAGER environment variable.
out << RDoc::Markup::Rule.new(1)
end
def render_method_comment out, method # :nodoc:
out << RDoc::Markup::BlankLine.new
out << method.comment
out << RDoc::Markup::BlankLine.new
def render_method_comment out, method, alias_for = nil# :nodoc:
if alias_for
unless method.comment.nil? or method.comment.empty?
out << RDoc::Markup::BlankLine.new
out << method.comment
end
out << RDoc::Markup::BlankLine.new
out << RDoc::Markup::Paragraph.new("(this method is alias for #{alias_for.full_name})")
out << RDoc::Markup::BlankLine.new
out << alias_for.comment
out << RDoc::Markup::BlankLine.new
else
out << RDoc::Markup::BlankLine.new
out << method.comment
out << RDoc::Markup::BlankLine.new
end
end
def render_method_superclass out, method # :nodoc:

Просмотреть файл

@ -1,5 +1,6 @@
# frozen_string_literal: true
require 'rdoc'
require 'erb'
require 'time'
require 'json'
require 'webrick'
@ -111,7 +112,7 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
# GET request entry point. Fills in +res+ for the path, etc. in +req+.
def do_GET req, res
req.path = req.path.sub(/^#{Regexp.escape @mount_path}/o, '') if @mount_path
req.path.sub!(/^#{Regexp.escape @mount_path}/o, '') if @mount_path
case req.path
when '/' then
@ -427,14 +428,14 @@ version. If you're viewing Ruby's documentation, include the version of ruby.
end
raise WEBrick::HTTPStatus::NotFound,
"Could not find gem \"#{source_name}\". Are you sure you installed it?" unless ri_dir
"Could not find gem \"#{ERB::Util.html_escape(source_name)}\". Are you sure you installed it?" unless ri_dir
store = RDoc::Store.new ri_dir, type
return store if File.exist? store.cache_path
raise WEBrick::HTTPStatus::NotFound,
"Could not find documentation for \"#{source_name}\". Please run `gem rdoc --ri gem_name`"
"Could not find documentation for \"#{ERB::Util.html_escape(source_name)}\". Please run `gem rdoc --ri gem_name`"
end
end

Просмотреть файл

@ -116,6 +116,11 @@ class RDoc::Store
attr_accessor :encoding
##
# The lazy constants alias will be discovered in passing
attr_reader :unmatched_constant_alias
##
# Creates a new Store of +type+ that will load or save to +path+
@ -152,6 +157,8 @@ class RDoc::Store
@unique_classes = nil
@unique_modules = nil
@unmatched_constant_alias = {}
end
##
@ -539,7 +546,7 @@ class RDoc::Store
def load_cache
#orig_enc = @encoding
open cache_path, 'rb' do |io|
File.open cache_path, 'rb' do |io|
@cache = Marshal.load io.read
end
@ -585,6 +592,8 @@ class RDoc::Store
case obj
when RDoc::NormalClass then
@classes_hash[klass_name] = obj
when RDoc::SingleClass then
@classes_hash[klass_name] = obj
when RDoc::NormalModule then
@modules_hash[klass_name] = obj
end
@ -596,7 +605,7 @@ class RDoc::Store
def load_class_data klass_name
file = class_file klass_name
open file, 'rb' do |io|
File.open file, 'rb' do |io|
Marshal.load io.read
end
rescue Errno::ENOENT => e
@ -611,7 +620,7 @@ class RDoc::Store
def load_method klass_name, method_name
file = method_file klass_name, method_name
open file, 'rb' do |io|
File.open file, 'rb' do |io|
obj = Marshal.load io.read
obj.store = self
obj.parent =
@ -631,7 +640,7 @@ class RDoc::Store
def load_page page_name
file = page_file page_name
open file, 'rb' do |io|
File.open file, 'rb' do |io|
obj = Marshal.load io.read
obj.store = self
obj
@ -778,7 +787,7 @@ class RDoc::Store
marshal = Marshal.dump @cache
open cache_path, 'wb' do |io|
File.open cache_path, 'wb' do |io|
io.write marshal
end
end
@ -854,7 +863,7 @@ class RDoc::Store
marshal = Marshal.dump klass
open path, 'wb' do |io|
File.open path, 'wb' do |io|
io.write marshal
end
end
@ -879,7 +888,7 @@ class RDoc::Store
marshal = Marshal.dump method
open method_file(full_name, method.full_name), 'wb' do |io|
File.open method_file(full_name, method.full_name), 'wb' do |io|
io.write marshal
end
end
@ -901,7 +910,7 @@ class RDoc::Store
marshal = Marshal.dump page
open path, 'wb' do |io|
File.open path, 'wb' do |io|
io.write marshal
end
end

Просмотреть файл

@ -169,7 +169,7 @@ module RDoc::Text
encoding = text.encoding
text = text.gsub %r%Document-method:\s+[\w:.#=!?]+%, ''
text = text.gsub %r%Document-method:\s+[\w:.#=!?|^&<>~+-/*\%@`\[\]]+%, ''
space = ' '
space = RDoc::Encoding.change_encoding space, encoding if encoding

Просмотреть файл

@ -107,7 +107,7 @@ module RDoc::TokenStream
# Returns a string representation of the token stream
def tokens_to_s
token_stream.compact.map { |token| token.text }.join ''
token_stream.compact.map { |token| token[:text] }.join ''
end
end

Просмотреть файл

@ -1,6 +1,6 @@
# frozen_string_literal: true
begin
gem 'minitest', '~> 4.0' unless defined?(Test::Unit)
gem 'minitest', '~> 5.0'
rescue NoMethodError, Gem::LoadError
# for ruby tests
end
@ -29,7 +29,7 @@ require 'rdoc'
# * <code>@pwd</code> containing the current working directory
# * FileUtils, pp, Tempfile, Dir.tmpdir and StringIO
class RDoc::TestCase < MiniTest::Unit::TestCase
class RDoc::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Unit::TestCase)
##
# Abstract test-case setup

Просмотреть файл

@ -133,7 +133,7 @@ method(a, b) { |c, d| ... }
assert_equal 'Klass#method', loaded.full_name
assert_equal 'method', loaded.name
assert_equal 'param', loaded.params
assert_equal nil, loaded.singleton # defaults to nil
assert_nil loaded.singleton # defaults to nil
assert_equal :public, loaded.visibility
assert_equal cm, loaded.parent
assert_equal section, loaded.section
@ -151,6 +151,19 @@ method(a, b) { |c, d| ... }
assert aliased_method.display?
end
def test_marshal_load_aliased_method_with_nil_singleton
aliased_method = Marshal.load Marshal.dump(@c2_a)
aliased_method.store = @store
aliased_method.is_alias_for = ["C2", nil, "b"]
assert_equal 'C2#a', aliased_method.full_name
assert_equal 'C2', aliased_method.parent_name
assert_equal '()', aliased_method.params
assert_equal @c2_b, aliased_method.is_alias_for, 'is_alias_for'
assert aliased_method.display?
end
def test_marshal_load_class_method
class_method = Marshal.load Marshal.dump(@c1.method_list.first)
@ -207,9 +220,9 @@ method(a, b) { |c, d| ... }
assert_equal 'Klass#method', loaded.full_name
assert_equal 'method', loaded.name
assert_equal 'param', loaded.params
assert_equal nil, loaded.singleton # defaults to nil
assert_nil loaded.singleton # defaults to nil
assert_equal :public, loaded.visibility
assert_equal nil, loaded.file
assert_nil loaded.file
assert_equal cm, loaded.parent
assert_equal section, loaded.section
assert_nil loaded.is_alias_for
@ -264,7 +277,7 @@ method(a, b) { |c, d| ... }
assert_equal 'Klass#method', loaded.full_name
assert_equal 'method', loaded.name
assert_equal 'param', loaded.params
assert_equal nil, loaded.singleton # defaults to nil
assert_nil loaded.singleton # defaults to nil
assert_equal :public, loaded.visibility
assert_equal cm, loaded.parent
assert_equal section, loaded.section
@ -467,4 +480,3 @@ method(a, b) { |c, d| ... }
end
end

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocAttr < RDoc::TestCase
@ -139,7 +139,7 @@ class TestRDocAttr < RDoc::TestCase
assert_equal cm, loaded.parent
assert_equal section, loaded.section
assert loaded.display?
assert loaded.display?
end
def test_marshal_load_version_2
@ -188,4 +188,3 @@ class TestRDocAttr < RDoc::TestCase
end
end

Просмотреть файл

@ -1277,7 +1277,8 @@ class TestRDocClassModule < XrefTestCase
n1 = @xref_data.add_module RDoc::NormalClass, 'N1'
n1_k2 = n1.add_module RDoc::NormalClass, 'N2'
n1.add_module_alias n1_k2, 'A1', @xref_data
a1 = RDoc::Constant.new 'A1', '', ''
n1.add_module_alias n1_k2, n1_k2.name, a1, @xref_data
n1_a1_c = n1.constants.find { |c| c.name == 'A1' }
refute_nil n1_a1_c
@ -1301,7 +1302,8 @@ class TestRDocClassModule < XrefTestCase
n1 = @xref_data.add_module RDoc::NormalModule, 'N1'
n1_n2 = n1.add_module RDoc::NormalModule, 'N2'
n1.add_module_alias n1_n2, 'A1', @xref_data
a1 = RDoc::Constant.new 'A1', '', ''
n1.add_module_alias n1_n2, n1_n2.name, a1, @xref_data
n1_a1_c = n1.constants.find { |c| c.name == 'A1' }
refute_nil n1_a1_c
@ -1326,7 +1328,8 @@ class TestRDocClassModule < XrefTestCase
l1_l2 = l1.add_module RDoc::NormalModule, 'L2'
o1 = @xref_data.add_module RDoc::NormalModule, 'O1'
o1.add_module_alias l1_l2, 'A1', @xref_data
a1 = RDoc::Constant.new 'A1', '', ''
o1.add_module_alias l1_l2, l1_l2.name, a1, @xref_data
o1_a1_c = o1.constants.find { |c| c.name == 'A1' }
refute_nil o1_a1_c
@ -1358,7 +1361,8 @@ class TestRDocClassModule < XrefTestCase
const.record_location top_level
const.is_alias_for = klass
top_level.add_module_alias klass, 'A', top_level
a = RDoc::Constant.new 'A', '', ''
top_level.add_module_alias klass, klass.name, a, top_level
object.add_constant const

Просмотреть файл

@ -213,7 +213,7 @@ class TestRDocCodeObject < XrefTestCase
end
def test_file_name
assert_equal nil, @co.file_name
assert_nil @co.file_name
@co.record_location @store.add_file 'lib/file.rb'

Просмотреть файл

@ -1,7 +1,7 @@
# coding: us-ascii
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocComment < RDoc::TestCase
@ -77,7 +77,7 @@ call-seq:
comment.extract_call_seq m
assert_equal nil, m.call_seq
assert_nil m.call_seq
end
def test_extract_call_seq_no_blank

Просмотреть файл

@ -118,7 +118,7 @@ class TestRDocConstant < XrefTestCase
assert_equal cm, loaded.parent
assert_equal section, loaded.section
assert loaded.display?
assert loaded.display?
end
def test_marshal_load_version_0

Просмотреть файл

@ -14,10 +14,10 @@ class TestRDocContext < XrefTestCase
assert_empty @context.in_files
assert_equal 'unknown', @context.name
assert_equal '', @context.comment
assert_equal nil, @context.parent
assert_nil @context.parent
assert_equal :public, @context.visibility
assert_equal 1, @context.sections.length
assert_equal nil, @context.temporary_section
assert_nil @context.temporary_section
assert_empty @context.classes_hash
assert_empty @context.modules_hash
@ -280,7 +280,8 @@ class TestRDocContext < XrefTestCase
def test_add_module_alias
tl = @store.add_file 'file.rb'
c3_c4 = @c2.add_module_alias @c2_c3, 'C4', tl
c4 = RDoc::Constant.new 'C4', '', ''
c3_c4 = @c2.add_module_alias @c2_c3, @c2_c3.name, c4, tl
alias_constant = @c2.constants.first
@ -298,7 +299,8 @@ class TestRDocContext < XrefTestCase
object = top_level.add_class RDoc::NormalClass, 'Object'
top_level.add_module_alias klass, 'A', top_level
a = RDoc::Constant.new 'A', '', ''
top_level.add_module_alias klass, klass.name, a, top_level
refute_empty object.constants
@ -512,7 +514,7 @@ class TestRDocContext < XrefTestCase
end
def test_find_attribute_named
assert_equal nil, @c1.find_attribute_named('none')
assert_nil @c1.find_attribute_named('none')
assert_equal 'R', @c1.find_attribute_named('attr').rw
assert_equal 'R', @c1.find_attribute_named('attr_reader').rw
assert_equal 'W', @c1.find_attribute_named('attr_writer').rw
@ -520,7 +522,7 @@ class TestRDocContext < XrefTestCase
end
def test_find_class_method_named
assert_equal nil, @c1.find_class_method_named('none')
assert_nil @c1.find_class_method_named('none')
m = @c1.find_class_method_named('m')
assert_instance_of RDoc::AnyMethod, m
@ -528,23 +530,23 @@ class TestRDocContext < XrefTestCase
end
def test_find_constant_named
assert_equal nil, @c1.find_constant_named('NONE')
assert_nil @c1.find_constant_named('NONE')
assert_equal ':const', @c1.find_constant_named('CONST').value
end
def test_find_enclosing_module_named
assert_equal nil, @c2_c3.find_enclosing_module_named('NONE')
assert_nil @c2_c3.find_enclosing_module_named('NONE')
assert_equal @c1, @c2_c3.find_enclosing_module_named('C1')
assert_equal @c2, @c2_c3.find_enclosing_module_named('C2')
end
def test_find_file_named
assert_equal nil, @c1.find_file_named('nonexistent.rb')
assert_nil @c1.find_file_named('nonexistent.rb')
assert_equal @xref_data, @c1.find_file_named(@file_name)
end
def test_find_instance_method_named
assert_equal nil, @c1.find_instance_method_named('none')
assert_nil @c1.find_instance_method_named('none')
m = @c1.find_instance_method_named('m')
assert_instance_of RDoc::AnyMethod, m
@ -559,6 +561,14 @@ class TestRDocContext < XrefTestCase
assert_equal @c2_c3, @c2.find_local_symbol('C3')
end
def test_find_method
loaded_c2 = Marshal.load Marshal.dump @c2
assert_equal @c2_a, loaded_c2.find_method('a', false)
assert_equal @c2_b, loaded_c2.find_method('b', false)
assert_equal @c2_a, loaded_c2.find_method('a', nil)
assert_equal @c2_b, loaded_c2.find_method('b', nil)
end
def test_find_method_named
assert_equal true, @c1.find_method_named('m').singleton
end

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocContextSection < RDoc::TestCase

Просмотреть файл

@ -1,7 +1,7 @@
# coding: US-ASCII
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocEncoding < RDoc::TestCase
@ -31,7 +31,7 @@ class TestRDocEncoding < RDoc::TestCase
@tempfile.flush
contents = RDoc::Encoding.read_file @tempfile.path, Encoding::UTF_8
assert_equal "hi everybody", contents
assert_equal "# coding: utf-8\nhi everybody", contents
assert_equal Encoding::UTF_8, contents.encoding
end
@ -45,7 +45,7 @@ class TestRDocEncoding < RDoc::TestCase
contents = RDoc::Encoding.read_file @tempfile.path, Encoding::UTF_8
assert_equal Encoding::UTF_8, contents.encoding
assert_equal "hi \u00e9verybody", contents.sub("\r", '')
assert_equal "# coding: ISO-8859-1\nhi \u00e9verybody", contents.sub("\r", '')
end
def test_class_read_file_encoding_fail
@ -65,13 +65,13 @@ class TestRDocEncoding < RDoc::TestCase
def test_class_read_file_encoding_fancy
expected = "# -*- coding: utf-8; fill-column: 74 -*-\nhi everybody"
exptected = RDoc::Encoding.change_encoding expected, Encoding::UTF_8
expected = RDoc::Encoding.change_encoding expected, Encoding::UTF_8
@tempfile.write expected
@tempfile.flush
contents = RDoc::Encoding.read_file @tempfile.path, Encoding::UTF_8
assert_equal "hi everybody", contents
assert_equal "# -*- coding: utf-8; fill-column: 74 -*-\nhi everybody", contents
assert_equal Encoding::UTF_8, contents.encoding
end
@ -81,7 +81,7 @@ class TestRDocEncoding < RDoc::TestCase
contents = RDoc::Encoding.read_file @tempfile.path, Encoding::US_ASCII, true
assert_equal '?', contents
assert_equal "# coding: utf-8\n?", contents
assert_equal Encoding::US_ASCII, contents.encoding
end
@ -124,108 +124,58 @@ class TestRDocEncoding < RDoc::TestCase
contents = RDoc::Encoding.read_file @tempfile.path, Encoding::UTF_8
expected = ":\xe3\x82\xb3\xe3\x83\x9e\xe3\x83\xb3\xe3\x83\x89:"
expected = "# coding: ISO-2022-JP\n:\xe3\x82\xb3\xe3\x83\x9e\xe3\x83\xb3\xe3\x83\x89:"
expected = RDoc::Encoding.change_encoding expected, Encoding::UTF_8
assert_equal expected, contents
assert_equal Encoding::UTF_8, contents.encoding
end
def test_class_set_encoding
def test_class_detect_encoding
s = "# coding: UTF-8\n"
s = RDoc::Encoding.set_encoding s
encoding = RDoc::Encoding.detect_encoding s
# sanity check for 1.8
assert_equal Encoding::UTF_8, s.encoding
assert_equal Encoding::UTF_8, encoding
s = "#!/bin/ruby\n# coding: UTF-8\n"
s = RDoc::Encoding.set_encoding s
encoding = RDoc::Encoding.detect_encoding s
assert_equal Encoding::UTF_8, s.encoding
assert_equal Encoding::UTF_8, encoding
s = "<?xml version='1.0' encoding='UTF-8'?>\n"
s = RDoc::Encoding.set_encoding s
encoding = RDoc::Encoding.detect_encoding s
assert_equal Encoding::UTF_8, s.encoding
assert_equal Encoding::UTF_8, encoding
s = "<?xml version='1.0' encoding=\"UTF-8\"?>\n"
s = RDoc::Encoding.set_encoding s
encoding = RDoc::Encoding.detect_encoding s
assert_equal Encoding::UTF_8, s.encoding
end
def test_class_set_encoding_strip
s = "# coding: UTF-8\n# more comments"
s = RDoc::Encoding.set_encoding s
assert_equal "# more comments", s
s = "#!/bin/ruby\n# coding: UTF-8\n# more comments"
s = RDoc::Encoding.set_encoding s
assert_equal "#!/bin/ruby\n# more comments", s
assert_equal Encoding::UTF_8, encoding
end
def test_class_set_encoding_bad
s = ""
expected = s.encoding
s = RDoc::Encoding.set_encoding s
encoding = RDoc::Encoding.detect_encoding s
assert_equal expected, s.encoding
assert_nil encoding
s = "# vim:set fileencoding=utf-8:\n"
expected = s.encoding
s = RDoc::Encoding.set_encoding s
encoding = RDoc::Encoding.detect_encoding s
assert_equal expected, s.encoding
assert_nil encoding
s = "# vim:set fileencoding=utf-8:\n"
expected = s.encoding
s = RDoc::Encoding.set_encoding s
encoding = RDoc::Encoding.detect_encoding s
assert_equal expected, s.encoding
assert_nil encoding
assert_raises ArgumentError do
s = RDoc::Encoding.set_encoding "# -*- encoding: undecided -*-\n"
s = RDoc::Encoding.detect_encoding "# -*- encoding: undecided -*-\n"
end
end
def test_skip_frozen_string_literal
expected = "# frozen_string_literal: true\nhi everybody"
@tempfile.write expected
@tempfile.flush
contents = RDoc::Encoding.read_file @tempfile.path, Encoding::UTF_8
assert_equal "hi everybody", contents
assert_equal Encoding::UTF_8, contents.encoding
end
def test_skip_frozen_string_literal_after_coding
expected = "# coding: utf-8\n# frozen-string-literal: false\nhi everybody"
@tempfile.write expected
@tempfile.flush
contents = RDoc::Encoding.read_file @tempfile.path, Encoding::UTF_8
assert_equal "hi everybody", contents
assert_equal Encoding::UTF_8, contents.encoding
end
def test_skip_frozen_string_literal_before_coding
expected = "# frozen_string_literal: true\n# coding: utf-8\nhi everybody"
@tempfile.write expected
@tempfile.flush
contents = RDoc::Encoding.read_file @tempfile.path, Encoding::UTF_8
assert_equal "hi everybody", contents
assert_equal Encoding::UTF_8, contents.encoding
end
def test_sanity
assert_equal Encoding::US_ASCII, ''.encoding,
'If this file is not ASCII tests may incorrectly pass'

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocGeneratorDarkfish < RDoc::TestCase
@ -39,7 +39,7 @@ class TestRDocGeneratorDarkfish < RDoc::TestCase
@top_level.add_constant @alias_constant
@klass.add_module_alias @klass, 'A', @top_level
@klass.add_module_alias @klass, @klass.name, @alias_constant, @top_level
@meth = RDoc::AnyMethod.new nil, 'method'
@meth_bang = RDoc::AnyMethod.new nil, 'method!'
@ -135,7 +135,7 @@ class TestRDocGeneratorDarkfish < RDoc::TestCase
end
def test_install_rdoc_static_file
src = Pathname(__FILE__)
src = Pathname File.expand_path(__FILE__, @pwd)
dst = File.join @tmpdir, File.basename(src)
options = {}

Просмотреть файл

@ -1,14 +1,14 @@
# coding: US-ASCII
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocGeneratorJsonIndex < RDoc::TestCase
def setup
super
@tmpdir = File.join Dir.tmpdir, "test_rdoc_generator_darkfish_#{$$}"
@tmpdir = Dir.mktmpdir "test_rdoc_generator_darkfish_#{$$}_"
FileUtils.mkdir_p @tmpdir
@options = RDoc::Options.new
@ -89,12 +89,31 @@ class TestRDocGeneratorJsonIndex < RDoc::TestCase
end
def test_generate
now = Time.now
@g.generate
assert_file 'js/searcher.js'
assert_file 'js/navigation.js'
assert_file 'js/search_index.js'
srcdir = File.expand_path("../../lib/rdoc", __FILE__)
if !File.directory? srcdir
# for Ruby core repository
srcdir = File.expand_path("../../../lib/rdoc", __FILE__)
end
orig_file = Pathname(File.join srcdir, 'generator/template/json_index/js/navigation.js')
generated_file = Pathname(File.join @tmpdir, 'js/navigation.js')
# This is dirty hack on JRuby for MiniTest 4
assert orig_file.mtime.inspect == generated_file.mtime.inspect,
'.js files should be tha same timestamp of original'
assert generated_file.mtime < now, '.js files should be the same timestamp'
generated_search_index = Pathname(File.join @tmpdir, 'js/search_index.js')
assert generated_search_index.mtime > (now - 1), 'search_index.js should be generated timestamp'
json = File.read 'js/search_index.js'
json =~ /\Avar search_data = /
@ -137,6 +156,20 @@ class TestRDocGeneratorJsonIndex < RDoc::TestCase
assert_equal expected, index
end
def test_generate_search_index_with_reproducible_builds
backup_epoch = ENV['SOURCE_DATE_EPOCH']
ruby_birthday = Time.parse 'Wed, 24 Feb 1993 21:00:00 +0900'
ENV['SOURCE_DATE_EPOCH'] = ruby_birthday.to_i.to_s
@g.generate
assert_file 'js/search_index.js'
generated_search_index = Pathname(File.join @tmpdir, 'js/search_index.js')
assert_equal ruby_birthday, generated_search_index.mtime
ENV['SOURCE_DATE_EPOCH'] = backup_epoch
end
def test_generate_gzipped
begin
require 'zlib'

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocGeneratorMarkup < RDoc::TestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocGeneratorPOT < RDoc::TestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocGeneratorPOTPO < RDoc::TestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocGeneratorPOTPOEntry < RDoc::TestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocGeneratorRI < RDoc::TestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocI18nLocale < RDoc::TestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocI18nText < RDoc::TestCase

Просмотреть файл

@ -1,7 +1,7 @@
# coding: UTF-8
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
require 'rdoc/markup/block_quote'
require 'rdoc/markdown'

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocMarkup < RDoc::TestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocMarkupAttributeManager < RDoc::TestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocMarkupAttributes < RDoc::TestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocMarkupDocument < RDoc::TestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocMarkupFormatter < RDoc::TestCase
@ -111,15 +111,15 @@ class TestRDocMarkupFormatter < RDoc::TestCase
assert_equal 'http', scheme
assert_equal 'example/foo', url
assert_equal nil, id
assert_nil id
end
def test_parse_url_anchor
scheme, url, id = @to.parse_url '#foottext-1'
assert_equal nil, scheme
assert_nil scheme
assert_equal '#foottext-1', url
assert_equal nil, id
assert_nil id
end
def test_parse_url_link
@ -127,7 +127,7 @@ class TestRDocMarkupFormatter < RDoc::TestCase
assert_equal 'link', scheme
assert_equal 'README.txt', url
assert_equal nil, id
assert_nil id
end
def test_parse_url_link_id
@ -135,7 +135,7 @@ class TestRDocMarkupFormatter < RDoc::TestCase
assert_equal 'link', scheme
assert_equal 'README.txt#label-foo', url
assert_equal nil, id
assert_nil id
end
def test_parse_url_rdoc_label
@ -143,7 +143,7 @@ class TestRDocMarkupFormatter < RDoc::TestCase
assert_equal 'link', scheme
assert_equal '#foo', url
assert_equal nil, id
assert_nil id
scheme, url, id = @to.parse_url 'rdoc-label:foo:bar'
@ -157,13 +157,13 @@ class TestRDocMarkupFormatter < RDoc::TestCase
assert_equal 'http', scheme
assert_equal 'http://example/foo', url
assert_equal nil, id
assert_nil id
scheme, url, id = @to.parse_url 'https://example/foo'
assert_equal 'https', scheme
assert_equal 'https://example/foo', url
assert_equal nil, id
assert_nil id
end
def test_convert_tt_special
@ -173,4 +173,3 @@ class TestRDocMarkupFormatter < RDoc::TestCase
end
end

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocMarkupHardBreak < RDoc::TestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocMarkupHeading < RDoc::TestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocMarkupInclude < RDoc::TestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocMarkupIndentedParagraph < RDoc::TestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocMarkupParagraph < RDoc::TestCase

Просмотреть файл

@ -1,7 +1,7 @@
# coding: utf-8
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocMarkupParser < RDoc::TestCase
@ -1068,7 +1068,7 @@ the time
assert_equal [:NEWLINE, "\n", 9, 0], parser.peek_token
assert_equal nil, parser.skip(:NONE, false)
assert_nil parser.skip(:NONE, false)
assert_equal [:NEWLINE, "\n", 9, 0], parser.peek_token
end

Просмотреть файл

@ -1,6 +1,6 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocMarkupPreProcess < RDoc::TestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocMarkupRaw < RDoc::TestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocMarkupToAnsi < RDoc::Markup::TextFormatterTestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocMarkupToBs < RDoc::Markup::TextFormatterTestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocMarkupToHtmlSnippet < RDoc::Markup::FormatterTestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocMarkupToJoinedParagraph < RDoc::TestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocMarkupToLabel < RDoc::Markup::FormatterTestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocMarkupToMarkdown < RDoc::Markup::TextFormatterTestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocMarkupToRDoc < RDoc::Markup::TextFormatterTestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocMarkupToTableOfContents < RDoc::Markup::FormatterTestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocMarkupToTtOnly < RDoc::Markup::FormatterTestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocMarkupVerbatim < RDoc::TestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocOptions < RDoc::TestCase
@ -18,7 +18,6 @@ class TestRDocOptions < RDoc::TestCase
def test_check_files
skip "assumes UNIX permission model" if /mswin|mingw/ =~ RUBY_PLATFORM
skip "skipped in root privilege" if Process.uid == 0
out, err = capture_io do
temp_dir do

Просмотреть файл

@ -1,7 +1,7 @@
# -*- coding: us-ascii -*-
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocParser < RDoc::TestCase
@ -19,7 +19,7 @@ class TestRDocParser < RDoc::TestCase
def test_class_binary_eh_ISO_2022_JP
iso_2022_jp = File.join Dir.tmpdir, "test_rdoc_parser_#{$$}.rd"
open iso_2022_jp, 'wb' do |io|
File.open iso_2022_jp, 'wb' do |io|
io.write "# coding: ISO-2022-JP\n"
io.write ":\e$B%3%^%s%I\e(B:\n"
end
@ -31,7 +31,7 @@ class TestRDocParser < RDoc::TestCase
def test_class_binary_eh_marshal
marshal = File.join Dir.tmpdir, "test_rdoc_parser_#{$$}.marshal"
open marshal, 'wb' do |io|
File.open marshal, 'wb' do |io|
io.write Marshal.dump('')
io.write 'lots of text ' * 500
end
@ -92,7 +92,7 @@ class TestRDocParser < RDoc::TestCase
def test_class_for_executable
temp_dir do
content = "#!/usr/bin/env ruby -w\n"
open 'app', 'w' do |io| io.write content end
File.open 'app', 'w' do |io| io.write content end
app = @store.add_file 'app'
parser = @RP.for app, 'app', content, @options, :stats
@ -126,7 +126,7 @@ class TestRDocParser < RDoc::TestCase
temp_dir do
content = "# -*- rdoc -*-\n= NEWS\n"
open 'NEWS', 'w' do |io| io.write content end
File.open 'NEWS', 'w' do |io| io.write content end
app = @store.add_file 'NEWS'
parser = @RP.for app, 'NEWS', content, @options, :stats
@ -140,7 +140,7 @@ class TestRDocParser < RDoc::TestCase
def test_can_parse_modeline
readme_ext = File.join Dir.tmpdir, "README.EXT.#{$$}"
open readme_ext, 'w' do |io|
File.open readme_ext, 'w' do |io|
io.puts "# README.EXT - -*- rdoc -*- created at: Mon Aug 7 16:45:54 JST 1995"
io.puts
io.puts "This document explains how to make extension libraries for Ruby."
@ -162,7 +162,7 @@ class TestRDocParser < RDoc::TestCase
def test_check_modeline
readme_ext = File.join Dir.tmpdir, "README.EXT.#{$$}"
open readme_ext, 'w' do |io|
File.open readme_ext, 'w' do |io|
io.puts "# README.EXT - -*- RDoc -*- created at: Mon Aug 7 16:45:54 JST 1995"
io.puts
io.puts "This document explains how to make extension libraries for Ruby."
@ -176,7 +176,7 @@ class TestRDocParser < RDoc::TestCase
def test_check_modeline_coding
readme_ext = File.join Dir.tmpdir, "README.EXT.#{$$}"
open readme_ext, 'w' do |io|
File.open readme_ext, 'w' do |io|
io.puts "# -*- coding: utf-8 -*-"
end
@ -188,7 +188,7 @@ class TestRDocParser < RDoc::TestCase
def test_check_modeline_with_other
readme_ext = File.join Dir.tmpdir, "README.EXT.#{$$}"
open readme_ext, 'w' do |io|
File.open readme_ext, 'w' do |io|
io.puts "# README.EXT - -*- mode: RDoc; indent-tabs-mode: nil -*-"
io.puts
io.puts "This document explains how to make extension libraries for Ruby."
@ -202,7 +202,7 @@ class TestRDocParser < RDoc::TestCase
def test_check_modeline_no_modeline
readme_ext = File.join Dir.tmpdir, "README.EXT.#{$$}"
open readme_ext, 'w' do |io|
File.open readme_ext, 'w' do |io|
io.puts "This document explains how to make extension libraries for Ruby."
end

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
=begin
TODO: test call-seq parsing
@ -327,7 +327,7 @@ VALUE cFoo = boot_defclass("Foo", 0);
klass = util_get_class content, 'cFoo'
assert_equal "this is the Foo boot class", klass.comment.text
assert_equal nil, klass.superclass
assert_nil klass.superclass
end
def test_do_aliases_missing_class
@ -1377,7 +1377,7 @@ commercial() -> Date <br />
parser.find_modifiers comment, method_obj
assert_equal nil, method_obj.document_self
assert_nil method_obj.document_self
end
def test_find_modifiers_yields

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocParserChangeLog < RDoc::TestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocParserMarkdown < RDoc::TestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocParserRd < RDoc::TestCase

Просмотреть файл

@ -1,6 +1,6 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocParserRuby < RDoc::TestCase
@ -231,8 +231,8 @@ class C; end
@parser.look_for_directives_in @top_level, comment
section = @top_level.current_section
assert_equal nil, section.title
assert_equal nil, section.comment
assert_nil section.title
assert_nil section.comment
assert_equal "# how to make a section:\n# # :section: new section\n",
comment.text
@ -306,6 +306,67 @@ ruby
assert_equal @top_level, sum.file
end
def test_parse_on_ignored_nl_with_nil_text
util_parser <<ruby
class Foo
def meth
variable # comment
.chain
end
end
ruby
expected = <<EXPECTED
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">meth</span>
<span class="ruby-identifier">variable</span> <span class="ruby-comment"># comment</span>
.<span class="ruby-identifier">chain</span>
<span class="ruby-keyword">end</span>
EXPECTED
expected = expected.rstrip
@parser.scan
foo = @store.find_class_named 'Foo'
meth = foo.method_list.first
assert_equal 'meth', meth.name
assert_equal @top_level, meth.file
markup_code = meth.markup_code.sub(/^.*\n/, '')
assert_equal expected, markup_code
end
def test_parse_redefined_op_with_constant
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
comment = RDoc::Comment.new '', @top_level
util_parser <<ruby
def meth
Integer::**()
return Integer::**()
break Integer::**()
case Integer::**()
when Integer::**()
end
while Integer::**()
end
yield Integer::**()
defined? Integer::**()
if Integer::**()
end
end
ruby
tk = @parser.get_tk
@parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, comment
meth = klass.method_list.first
assert_equal 'meth', meth.name
end
def test_parse_alias
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
@ -813,6 +874,31 @@ end
assert_match(/Expected class name or '<<'\. Got/, err)
end
def test_parse_syntax_error_code
@options.verbosity = 2
stds = capture_io do
begin
util_parser <<INVALID_CODE
# invalid class name
class Invalid::@@Code
end
INVALID_CODE
@parser.scan
rescue
end
end
err = stds[1]
expected = <<EXPECTED
RDoc::Parser::Ruby failure around line 2 of
#{@filename}
class Invalid::@@Code
EXPECTED
assert_match(expected, err)
end
def test_parse_multi_ghost_methods
util_parser <<-'CLASS'
class Foo
@ -1139,7 +1225,7 @@ EOF
assert_equal @top_level, foo.file
assert_equal 1, foo.line
assert_equal nil, foo.viewer
assert_nil foo.viewer
assert_equal true, foo.document_children
assert_equal true, foo.document_self
assert_equal false, foo.done_documenting
@ -1202,21 +1288,21 @@ EOF
assert_equal @top_level, foo.file
assert_equal 1, foo.line
assert_equal [], foo.aliases
assert_equal nil, foo.block_params
assert_equal nil, foo.call_seq
assert_equal nil, foo.is_alias_for
assert_equal nil, foo.viewer
assert_equal true, foo.document_children
assert_equal true, foo.document_self
assert_equal '', foo.params
assert_equal false, foo.done_documenting
assert_equal false, foo.dont_rename_initialize
assert_equal false, foo.force_documentation
assert_equal klass, foo.parent
assert_equal false, foo.singleton
assert_equal :public, foo.visibility
assert_equal "\n", foo.text
assert_equal [], foo.aliases
assert_nil foo.block_params
assert_nil foo.call_seq
assert_nil foo.is_alias_for
assert_nil foo.viewer
assert_equal true, foo.document_children
assert_equal true, foo.document_self
assert_equal '', foo.params
assert_equal false, foo.done_documenting
assert_equal false, foo.dont_rename_initialize
assert_equal false, foo.force_documentation
assert_equal klass, foo.parent
assert_equal false, foo.singleton
assert_equal :public, foo.visibility
assert_equal "\n", foo.text
assert_equal klass.current_section, foo.section
stream = [
@ -1302,6 +1388,9 @@ EOF
@parser.parse_constant klass, tk, @comment
assert_equal [], klass.modules.map(&:full_name)
assert_equal ['Foo::B', 'Foo::A'], klass.classes.map(&:full_name)
assert_equal ['Foo::A'], klass.constants.map(&:full_name)
assert_equal 'Foo::A', klass.find_module_named('A').full_name
end
@ -1516,19 +1605,19 @@ end
assert_equal 1, foo.line
assert_equal [], foo.aliases
assert_equal nil, foo.block_params
assert_equal nil, foo.call_seq
assert_nil foo.block_params
assert_nil foo.call_seq
assert_equal true, foo.document_children
assert_equal true, foo.document_self
assert_equal false, foo.done_documenting
assert_equal false, foo.dont_rename_initialize
assert_equal false, foo.force_documentation
assert_equal nil, foo.is_alias_for
assert_nil foo.is_alias_for
assert_equal '', foo.params
assert_equal klass, foo.parent
assert_equal false, foo.singleton
assert_equal 'add_my_method :foo', foo.text
assert_equal nil, foo.viewer
assert_nil foo.viewer
assert_equal :public, foo.visibility
assert_equal klass.current_section, foo.section
@ -1726,10 +1815,10 @@ end
assert_equal 1, foo.line
assert_equal [], foo.aliases
assert_equal nil, foo.block_params
assert_equal nil, foo.call_seq
assert_equal nil, foo.is_alias_for
assert_equal nil, foo.viewer
assert_nil foo.block_params
assert_nil foo.call_seq
assert_nil foo.is_alias_for
assert_nil foo.viewer
assert_equal true, foo.document_children
assert_equal true, foo.document_self
assert_equal '()', foo.params
@ -2981,12 +3070,12 @@ RUBY
@parser.skip_tkspace
assert_equal nil, @parser.parse_symbol_in_arg
assert_nil @parser.parse_symbol_in_arg
@parser.get_tk # skip ','
@parser.skip_tkspace
assert_equal nil, @parser.parse_symbol_in_arg
assert_nil @parser.parse_symbol_in_arg
end
def test_parse_statements_alias_method
@ -3090,7 +3179,7 @@ end
assert_equal 'category', directive
assert_equal 'test', value
assert_equal nil, parser.get_tk
assert_nil parser.get_tk
end
def test_read_directive_allow
@ -3100,7 +3189,7 @@ end
assert_nil directive
assert_equal nil, parser.get_tk
assert_nil parser.get_tk
end
def test_read_directive_empty
@ -3110,7 +3199,7 @@ end
assert_nil directive
assert_equal nil, parser.get_tk
assert_nil parser.get_tk
end
def test_read_directive_no_comment
@ -3120,7 +3209,7 @@ end
assert_nil directive
assert_equal nil, parser.get_tk
assert_nil parser.get_tk
end
def test_read_directive_one_liner
@ -3197,14 +3286,14 @@ end
util_parser '"#{"#{"a")}" if b}"'
assert_equal '"#{"#{"a")}" if b}"', @parser.get_tk[:text]
assert_equal nil, @parser.get_tk
assert_nil @parser.get_tk
end
def test_sanity_interpolation_curly
util_parser '%{ #{} }'
assert_equal '%{ #{} }', @parser.get_tk[:text]
assert_equal nil, @parser.get_tk
assert_nil @parser.get_tk
end
def test_sanity_interpolation_format
@ -3842,4 +3931,150 @@ end
second_file_content, @options, @stats
end
def test_parse_const_third_party
util_parser <<-CLASS
class A
true if B
true if B::C
true if B::C::D
module B
end
end
CLASS
tk = @parser.get_tk
@parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, @comment
a = @top_level.classes.first
assert_equal 'A', a.full_name
visible = @store.all_modules.reject { |mod| mod.suppressed? }
visible = visible.map { |mod| mod.full_name }
assert_equal ['A::B'], visible
end
def test_parse_const_alias_defined_elsewhere
util_parser <<-CLASS
module A
Aliased = Defined
end
module A
class Defined
end
end
CLASS
@parser.scan
a = @top_level.modules.first
assert_equal 'A', a.full_name
aliased = a.constants.first
assert_equal 'A::Aliased', aliased.full_name
assert_equal [], a.modules.map(&:full_name)
assert_equal ['A::Defined', 'A::Aliased'], a.classes.map(&:full_name)
assert_equal ['A::Aliased'], a.constants.map(&:full_name)
visible = @store.all_modules.reject { |mod| mod.suppressed? }
visible = visible.map { |mod| mod.full_name }
assert_equal ['A'], visible
end
def test_parse_const_alias_defined_far_away
util_parser <<-CLASS
module A
Aliased = ::B::C::Defined
end
module B
module C
class Defined
end
end
end
CLASS
@parser.scan
a = @top_level.modules.first
assert_equal 'A', a.full_name
assert_empty a.classes
assert_empty a.modules
assert_equal ['A::Aliased'], a.constants.map(&:full_name)
defined = @store.find_class_named 'B::C::Defined'
assert_equal 'B::C::Defined', defined.full_name
aliased = @store.find_class_named 'B::C::Aliased'
assert_equal 'B::C::Aliased', aliased.full_name
visible = @store.all_modules.reject { |mod| mod.suppressed? }
visible = visible.map { |mod| mod.full_name }
assert_equal ['A', 'B', 'B::C'], visible
end
def test_parse_const_alias_defined_elsewhere
util_parser <<-CLASS
module A
Aliased = Defined
end
module A
class Defined
end
end
CLASS
@parser.scan
a = @top_level.modules.first
assert_equal 'A', a.full_name
aliased = a.constants.first
assert_equal 'A::Aliased', aliased.full_name
visible = @store.all_modules.reject { |mod| mod.suppressed? }
visible = visible.map { |mod| mod.full_name }
assert_equal ['A'], visible
end
def test_parse_const_alias_defined_far_away
util_parser <<-CLASS
module A
Aliased = ::B::C::Defined
end
module B
module C
class Defined
end
end
end
CLASS
@parser.scan
a = @top_level.modules.first
assert_equal 'A', a.full_name
assert_empty a.classes
assert_empty a.modules
assert_equal ['A::Aliased'], a.constants.map(&:full_name)
defined = @store.find_class_named 'B::C::Defined'
assert_equal 'B::C::Defined', defined.full_name
aliased = @store.find_class_named 'B::C::Aliased'
assert_equal 'B::C::Aliased', aliased.full_name
visible = @store.all_modules.reject { |mod| mod.suppressed? }
visible = visible.map { |mod| mod.full_name }
assert_equal ['A', 'B', 'B::C'], visible
end
end

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocParserSimple < RDoc::TestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocRd < RDoc::TestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocRdBlockParser < RDoc::TestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocRdInline < RDoc::TestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocRdInlineParser < RDoc::TestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocRDoc < RDoc::TestCase
@ -115,7 +115,7 @@ class TestRDocRDoc < RDoc::TestCase
def test_load_options_invalid
temp_dir do
open '.rdoc_options', 'w' do |io|
File.open '.rdoc_options', 'w' do |io|
io.write "a: !ruby.yaml.org,2002:str |\nfoo"
end
@ -181,13 +181,67 @@ class TestRDocRDoc < RDoc::TestCase
assert_match %r"#{dev}$", err
end
def test_normalized_file_list_with_dot_doc
expected_files = []
files = temp_dir do |dir|
a = File.expand_path('a.rb')
b = File.expand_path('b.rb')
c = File.expand_path('c.rb')
FileUtils.touch a
FileUtils.touch b
FileUtils.touch c
dot_doc = File.expand_path('.document')
FileUtils.touch dot_doc
open(dot_doc, 'w') do |f|
f.puts 'a.rb'
f.puts 'b.rb'
end
expected_files << a
expected_files << b
@rdoc.normalized_file_list [File.realpath(dir)]
end
files = files.map { |file| File.expand_path file }
assert_equal expected_files, files
end
def test_normalized_file_list_with_dot_doc_overridden_by_exclude_option
expected_files = []
files = temp_dir do |dir|
a = File.expand_path('a.rb')
b = File.expand_path('b.rb')
c = File.expand_path('c.rb')
FileUtils.touch a
FileUtils.touch b
FileUtils.touch c
dot_doc = File.expand_path('.document')
FileUtils.touch dot_doc
open(dot_doc, 'w') do |f|
f.puts 'a.rb'
f.puts 'b.rb'
end
expected_files << a
@rdoc.options.exclude = Regexp.new(['b.rb'].join('|'))
@rdoc.normalized_file_list [File.realpath(dir)]
end
files = files.map { |file| File.expand_path file }
assert_equal expected_files, files
end
def test_parse_file
@rdoc.store = RDoc::Store.new
temp_dir do |dir|
@rdoc.options.root = Pathname(Dir.pwd)
open 'test.txt', 'w' do |io|
File.open 'test.txt', 'w' do |io|
io.puts 'hi'
end
@ -223,7 +277,7 @@ class TestRDocRDoc < RDoc::TestCase
temp_dir do |dir|
@rdoc.options.parse %W[--root #{test_path}]
open 'include.txt', 'w' do |io|
File.open 'include.txt', 'w' do |io|
io.puts ':include: test.txt'
end
@ -244,7 +298,7 @@ class TestRDocRDoc < RDoc::TestCase
@rdoc.options.page_dir = Pathname('pages')
@rdoc.options.root = Pathname(Dir.pwd)
open 'pages/test.txt', 'w' do |io|
File.open 'pages/test.txt', 'w' do |io|
io.puts 'hi'
end
@ -263,7 +317,7 @@ class TestRDocRDoc < RDoc::TestCase
temp_dir do |dir|
@rdoc.options.root = Pathname(dir)
open 'test.txt', 'w' do |io|
File.open 'test.txt', 'w' do |io|
io.puts 'hi'
end
@ -296,7 +350,6 @@ class TestRDocRDoc < RDoc::TestCase
def test_parse_file_forbidden
skip 'chmod not supported' if Gem.win_platform?
skip 'skipped in root privilege' if Process.uid == 0
@rdoc.store = RDoc::Store.new
@ -340,7 +393,7 @@ class TestRDocRDoc < RDoc::TestCase
def test_remove_unparseable_tags_emacs
temp_dir do
open 'TAGS', 'wb' do |io| # emacs
File.open 'TAGS', 'wb' do |io| # emacs
io.write "\f\nlib/foo.rb,43\n"
end
@ -354,7 +407,7 @@ class TestRDocRDoc < RDoc::TestCase
def test_remove_unparseable_tags_vim
temp_dir do
open 'TAGS', 'w' do |io| # emacs
File.open 'TAGS', 'w' do |io| # emacs
io.write "!_TAG_"
end
@ -393,7 +446,7 @@ class TestRDocRDoc < RDoc::TestCase
def test_setup_output_dir_exists
Dir.mktmpdir {|path|
open @rdoc.output_flag_file(path), 'w' do |io|
File.open @rdoc.output_flag_file(path), 'w' do |io|
io.puts Time.at 0
io.puts "./lib/rdoc.rb\t#{Time.at 86400}"
end
@ -407,7 +460,7 @@ class TestRDocRDoc < RDoc::TestCase
def test_setup_output_dir_exists_empty_created_rid
Dir.mktmpdir {|path|
open @rdoc.output_flag_file(path), 'w' do end
File.open @rdoc.output_flag_file(path), 'w' do end
e = assert_raises RDoc::Error do
@rdoc.setup_output_dir path, false
@ -468,6 +521,25 @@ class TestRDocRDoc < RDoc::TestCase
end
end
def test_update_output_dir_with_reproducible_time
Dir.mktmpdir do |d|
backup_epoch = ENV['SOURCE_DATE_EPOCH']
ruby_birthday = Time.parse 'Wed, 24 Feb 1993 21:00:00 +0900'
ENV['SOURCE_DATE_EPOCH'] = ruby_birthday.to_i.to_s
@rdoc.update_output_dir d, Time.now, {}
assert File.exist? "#{d}/created.rid"
f = File.open("#{d}/created.rid", 'r')
head_timestamp = Time.parse f.gets.chomp
f.close
assert_equal ruby_birthday, head_timestamp
ENV['SOURCE_DATE_EPOCH'] = backup_epoch
end
end
def test_normalized_file_list_removes_created_rid_dir
temp_dir do |d|
FileUtils.mkdir "doc"

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocRIDriver < RDoc::TestCase
@ -243,6 +243,32 @@ class TestRDocRIDriver < RDoc::TestCase
assert_equal expected, out
end
def test_add_method_that_is_alias_for_original
util_store
out = doc
@driver.add_method out, 'Qux#aliased'
expected =
doc(
head(1, 'Qux#aliased'),
blank_line,
para('(from ~/.rdoc)'),
rule(1),
blank_line,
para('alias comment'),
blank_line,
blank_line,
para('(this method is alias for Qux#original)'),
blank_line,
para('original comment'),
blank_line,
blank_line)
assert_equal expected, out
end
def test_add_method_attribute
util_store
@ -348,6 +374,22 @@ class TestRDocRIDriver < RDoc::TestCase
assert_equal expected, out
end
def test_output_width
@options[:width] = 10
driver = RDoc::RI::Driver.new @options
doc = @RM::Document.new
doc << @RM::IndentedParagraph.new(0, 'new, parse, foo, bar, baz')
out, = capture_io do
driver.display doc
end
expected = "new, parse, foo,\nbar, baz\n"
assert_equal expected, out
end
def test_add_method_list_interative
@options[:interactive] = true
driver = RDoc::RI::Driver.new @options
@ -390,6 +432,7 @@ class TestRDocRIDriver < RDoc::TestCase
'Foo::Bar' => [@store1],
'Foo::Baz' => [@store1, @store2],
'Inc' => [@store1],
'Qux' => [@store1],
}
classes = @driver.classes
@ -923,6 +966,7 @@ Foo::Bar#bother
[@store1, 'Foo::Bar', 'Foo::Bar', :both, 'blah'],
[@store1, 'Foo::Baz', 'Foo::Baz', :both, 'blah'],
[@store1, 'Inc', 'Inc', :both, 'blah'],
[@store1, 'Qux', 'Qux', :both, 'blah'],
]
assert_equal expected, items
@ -1056,7 +1100,7 @@ Foo::Bar#bother
@driver.list_known_classes
end
assert_equal "Ambiguous\nExt\nFoo\nFoo::Bar\nFoo::Baz\nInc\n", out
assert_equal "Ambiguous\nExt\nFoo\nFoo::Bar\nFoo::Baz\nInc\nQux\n", out
end
def test_list_known_classes_name
@ -1127,7 +1171,7 @@ Foo::Bar#bother
method = @driver.load_method(@store2, :instance_methods, 'Bar', '#',
'inherit')
assert_equal nil, method
assert_nil method
end
def test_load_methods_matching
@ -1232,7 +1276,7 @@ Foo::Bar#bother
assert_equal 'ruby', klass, 'ruby project'
assert_equal ':', type, 'ruby type'
assert_equal nil, meth, 'ruby page'
assert_nil meth, 'ruby page'
end
def test_parse_name_page_extenson
@ -1247,26 +1291,26 @@ Foo::Bar#bother
klass, type, meth = @driver.parse_name 'Foo'
assert_equal 'Foo', klass, 'Foo class'
assert_equal nil, type, 'Foo type'
assert_equal nil, meth, 'Foo method'
assert_nil type, 'Foo type'
assert_nil meth, 'Foo method'
klass, type, meth = @driver.parse_name 'Foo#'
assert_equal 'Foo', klass, 'Foo# class'
assert_equal '#', type, 'Foo# type'
assert_equal nil, meth, 'Foo# method'
assert_nil meth, 'Foo# method'
klass, type, meth = @driver.parse_name 'Foo::'
assert_equal 'Foo', klass, 'Foo:: class'
assert_equal '::', type, 'Foo:: type'
assert_equal nil, meth, 'Foo:: method'
assert_nil meth, 'Foo:: method'
klass, type, meth = @driver.parse_name 'Foo.'
assert_equal 'Foo', klass, 'Foo. class'
assert_equal '.', type, 'Foo. type'
assert_equal nil, meth, 'Foo. method'
assert_nil meth, 'Foo. method'
klass, type, meth = @driver.parse_name 'Foo#Bar'
@ -1291,14 +1335,14 @@ Foo::Bar#bother
klass, type, meth = @driver.parse_name 'Foo::Bar'
assert_equal 'Foo::Bar', klass, 'Foo::Bar class'
assert_equal nil, type, 'Foo::Bar type'
assert_equal nil, meth, 'Foo::Bar method'
assert_nil type, 'Foo::Bar type'
assert_nil meth, 'Foo::Bar method'
klass, type, meth = @driver.parse_name 'Foo::Bar#'
assert_equal 'Foo::Bar', klass, 'Foo::Bar# class'
assert_equal '#', type, 'Foo::Bar# type'
assert_equal nil, meth, 'Foo::Bar# method'
assert_nil meth, 'Foo::Bar# method'
klass, type, meth = @driver.parse_name 'Foo::Bar#baz'
@ -1481,6 +1525,15 @@ Foo::Bar#bother
@overridden.comment = 'must not be displayed in Bar#override'
@overridden.record_location @top_level
@cQux = @top_level.add_class RDoc::NormalClass, 'Qux'
@original = @cQux.add_method RDoc::AnyMethod.new(nil, 'original')
@original.comment = 'original comment'
@original.record_location @top_level
@aliased = @original.add_alias RDoc::Alias.new(nil, 'original', 'aliased', 'alias comment'), @cQux
@aliased.record_location @top_level
@store1.save
@driver.stores = [@store1]

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocRIPaths < RDoc::TestCase
@ -22,7 +22,7 @@ class TestRDocRIPaths < RDoc::TestCase
specs.each do |spec|
spec.loaded_from = spec.spec_file
open spec.spec_file, 'w' do |file|
File.open spec.spec_file, 'w' do |file|
file.write spec.to_ruby_for_cache
end

Просмотреть файл

@ -200,7 +200,6 @@ class TestRDocRubygemsHook < Gem::TestCase
def test_remove_unwritable
skip 'chmod not supported' if Gem.win_platform?
skip 'skipped in root privilege' if Process.uid == 0
FileUtils.mkdir_p @a.base_dir
FileUtils.chmod 0, @a.base_dir
@ -229,7 +228,6 @@ class TestRDocRubygemsHook < Gem::TestCase
def test_setup_unwritable
skip 'chmod not supported' if Gem.win_platform?
skip 'skipped in root privilege' if Process.uid == 0
FileUtils.mkdir_p @a.doc_dir
FileUtils.chmod 0, @a.doc_dir

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocServlet < RDoc::TestCase
@ -69,7 +69,7 @@ class TestRDocServlet < RDoc::TestCase
FileUtils.mkdir 'css'
now = Time.now
open 'css/rdoc.css', 'w' do |io| io.write 'h1 { color: red }' end
File.open 'css/rdoc.css', 'w' do |io| io.write 'h1 { color: red }' end
File.utime now, now, 'css/rdoc.css'
@s.asset_dirs[:darkfish] = '.'
@ -143,7 +143,7 @@ class TestRDocServlet < RDoc::TestCase
@s.asset_dirs[:darkfish] = '.'
@req.path = '/mount/path/css/rdoc.css'
@req.path = '/mount/path/css/rdoc.css'.dup
@s.do_GET @req, @res

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocSingleClass < RDoc::TestCase

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocStats < RDoc::TestCase

Просмотреть файл

@ -162,7 +162,7 @@ class TestRDocStore < XrefTestCase
def test_all_classes_and_modules
expected = %w[
C1 C2 C2::C3 C2::C3::H1 C3 C3::H1 C3::H2 C4 C4::C4 C5 C5::C1 C6 C7
C1 C2 C2::C3 C2::C3::H1 C3 C3::H1 C3::H2 C4 C4::C4 C5 C5::C1 C6 C7 C8 C8::S1
Child
M1 M1::M2
Parent
@ -213,7 +213,7 @@ class TestRDocStore < XrefTestCase
def test_classes
expected = %w[
C1 C2 C2::C3 C2::C3::H1 C3 C3::H1 C3::H2 C4 C4::C4 C5 C5::C1 C6 C7
C1 C2 C2::C3 C2::C3::H1 C3 C3::H1 C3::H2 C4 C4::C4 C5 C5::C1 C6 C7 C8 C8::S1
Child
Parent
]
@ -222,7 +222,8 @@ class TestRDocStore < XrefTestCase
end
def test_complete
@c2.add_module_alias @c2_c3, 'A1', @top_level
a1 = RDoc::Constant.new 'A1', '', ''
@c2.add_module_alias @c2_c3, @c2_c3.name, a1, @top_level
@store.complete :public
@ -407,7 +408,7 @@ class TestRDocStore < XrefTestCase
Dir.mkdir @tmpdir
open File.join(@tmpdir, 'cache.ri'), 'wb' do |io|
File.open File.join(@tmpdir, 'cache.ri'), 'wb' do |io|
Marshal.dump cache, io
end
@ -441,7 +442,7 @@ class TestRDocStore < XrefTestCase
Dir.mkdir @tmpdir
open File.join(@tmpdir, 'cache.ri'), 'wb' do |io|
File.open File.join(@tmpdir, 'cache.ri'), 'wb' do |io|
Marshal.dump cache, io
end
@ -490,7 +491,7 @@ class TestRDocStore < XrefTestCase
Dir.mkdir @tmpdir
open File.join(@tmpdir, 'cache.ri'), 'wb' do |io|
File.open File.join(@tmpdir, 'cache.ri'), 'wb' do |io|
Marshal.dump cache, io
end
@ -524,6 +525,15 @@ class TestRDocStore < XrefTestCase
assert_includes @s.classes_hash, 'Object'
end
def test_load_single_class
@s.save_class @c8_s1
@s.classes_hash.clear
assert_equal @c8_s1, @s.load_class('C8::S1')
assert_includes @s.classes_hash, 'C8::S1'
end
def test_load_method
@s.save_method @klass, @meth_bang
@ -538,7 +548,7 @@ class TestRDocStore < XrefTestCase
file = @s.method_file @klass.full_name, @meth.full_name
open file, 'wb' do |io|
File.open file, 'wb' do |io|
io.write "\x04\bU:\x14RDoc::AnyMethod[\x0Fi\x00I" +
"\"\vmethod\x06:\x06EF\"\x11Klass#method0:\vpublic" +
"o:\eRDoc::Markup::Document\x06:\v@parts[\x06" +
@ -563,7 +573,7 @@ class TestRDocStore < XrefTestCase
end
def test_main
assert_equal nil, @s.main
assert_nil @s.main
@s.main = 'README.txt'
@ -633,7 +643,7 @@ class TestRDocStore < XrefTestCase
expected[:ancestors]['Object'] = %w[BasicObject]
open File.join(@tmpdir, 'cache.ri'), 'rb' do |io|
File.open File.join(@tmpdir, 'cache.ri'), 'rb' do |io|
cache = Marshal.load io.read
assert_equal expected, cache
@ -701,7 +711,7 @@ class TestRDocStore < XrefTestCase
expected[:ancestors]['Object'] = %w[BasicObject]
open File.join(@tmpdir, 'cache.ri'), 'rb' do |io|
File.open File.join(@tmpdir, 'cache.ri'), 'rb' do |io|
cache = Marshal.load io.read
assert_equal expected, cache
@ -981,7 +991,7 @@ class TestRDocStore < XrefTestCase
end
def test_title
assert_equal nil, @s.title
assert_nil @s.title
@s.title = 'rdoc'

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
begin
require 'rake'
rescue LoadError

Просмотреть файл

@ -1,6 +1,7 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
require 'timeout'
class TestRDocText < RDoc::TestCase
@ -377,6 +378,32 @@ paragraph will be cut off …
assert_equal expected, strip_stars(text)
end
def test_strip_stars_document_method_special
text = <<-TEXT
/*
* Document-method: Zlib::GzipFile#mtime=
* Document-method: []
* Document-method: `
* Document-method: |
* Document-method: &
* Document-method: <=>
* Document-method: =~
* Document-method: +
* Document-method: -
* Document-method: +@
*
* A comment
*/
TEXT
expected = <<-EXPECTED
A comment
EXPECTED
assert_equal expected, strip_stars(text)
end
def test_strip_stars_encoding
text = <<-TEXT
/*

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocTokenStream < RDoc::TestCase
@ -39,5 +39,20 @@ class TestRDocTokenStream < RDoc::TestCase
assert_equal '', RDoc::TokenStream.to_html([])
end
def test_tokens_to_s
foo = Class.new do
include RDoc::TokenStream
def initialize
@token_stream = [
{ line_no: 0, char_no: 0, kind: :on_ident, text: "foo" },
{ line_no: 0, char_no: 0, kind: :on_sp, text: " " },
{ line_no: 0, char_no: 0, kind: :on_tstring, text: "'bar'" },
]
end
end.new
assert_equal "foo 'bar'", foo.tokens_to_s
end
end

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'rdoc/test_case'
require 'minitest_helper'
class TestRDocTomDoc < RDoc::TestCase

Просмотреть файл

@ -160,7 +160,7 @@ class TestRDocTopLevel < XrefTestCase
end
def test_last_modified
assert_equal nil, @top_level.last_modified
assert_nil @top_level.last_modified
stat = Object.new
def stat.mtime() 0 end
@top_level.file_stat = stat

Просмотреть файл

@ -94,6 +94,13 @@ class C7
CONST_NODOC = :const_nodoc # :nodoc:
end
class C8
class << self
class S1
end
end
end
module M1
def m
end

Просмотреть файл

@ -1,7 +1,7 @@
# frozen_string_literal: true
ENV['RDOC_TEST'] = 'yes'
require 'rdoc'
require 'minitest_helper'
require File.expand_path '../xref_data', __FILE__
class XrefTestCase < RDoc::TestCase
@ -53,6 +53,8 @@ class XrefTestCase < RDoc::TestCase
@c3_h2 = @xref_data.find_module_named 'C3::H2'
@c6 = @xref_data.find_module_named 'C6'
@c7 = @xref_data.find_module_named 'C7'
@c8 = @xref_data.find_module_named 'C8'
@c8_s1 = @xref_data.find_module_named 'C8::S1'
@m1 = @xref_data.find_module_named 'M1'
@m1_m = @m1.method_list.first