diff --git a/TODO.rdoc b/TODO.rdoc
index da919118d9..c4dbc4cf5f 100644
--- a/TODO.rdoc
+++ b/TODO.rdoc
@@ -43,7 +43,6 @@ Forward Looking Statements applies.
the middle of a method section.
* RDoc::CodeObject
* Move into own namespace
- * Rename TopLevel to File
* Rename Context to Container
* Rename NormalClass to Class
diff --git a/lib/rdoc.rb b/lib/rdoc.rb
index b42059c712..1413486111 100644
--- a/lib/rdoc.rb
+++ b/lib/rdoc.rb
@@ -131,21 +131,21 @@ def self.load_yaml
def self.home
rdoc_dir = begin
- File.expand_path('~/.rdoc')
+ ::File.expand_path('~/.rdoc')
rescue ArgumentError
end
- if File.directory?(rdoc_dir)
+ if ::File.directory?(rdoc_dir)
rdoc_dir
else
require 'fileutils'
begin
# XDG
- xdg_data_home = ENV["XDG_DATA_HOME"] || File.join(File.expand_path("~"), '.local', 'share')
- unless File.exist?(xdg_data_home)
+ xdg_data_home = ENV["XDG_DATA_HOME"] || ::File.join(::File.expand_path("~"), '.local', 'share')
+ unless ::File.exist?(xdg_data_home)
FileUtils.mkdir_p xdg_data_home
end
- File.join xdg_data_home, "rdoc"
+ ::File.join xdg_data_home, "rdoc"
rescue Errno::EACCES
end
end
@@ -187,7 +187,8 @@ def self.home
autoload :CodeObject, "#{__dir__}/rdoc/code_object"
autoload :Context, "#{__dir__}/rdoc/code_object/context"
- autoload :TopLevel, "#{__dir__}/rdoc/code_object/top_level"
+ autoload :File, "#{__dir__}/rdoc/code_object/file"
+ autoload :TopLevel, "#{__dir__}/rdoc/code_object/top_level" # @deprecated Use RDoc::File instead
autoload :AnonClass, "#{__dir__}/rdoc/code_object/anon_class"
autoload :ClassModule, "#{__dir__}/rdoc/code_object/class_module"
diff --git a/lib/rdoc/code_object.rb b/lib/rdoc/code_object.rb
index 388863b06c..c7b4d934f1 100644
--- a/lib/rdoc/code_object.rb
+++ b/lib/rdoc/code_object.rb
@@ -8,7 +8,7 @@
# Here's the tree of the CodeObject subclasses:
#
# * RDoc::Context
-# * RDoc::TopLevel
+# * RDoc::File
# * RDoc::ClassModule
# * RDoc::AnonClass (never used so far)
# * RDoc::NormalClass
@@ -291,7 +291,7 @@ def parent
return @parent if @parent
return nil unless @parent_name
- if @parent_class == RDoc::TopLevel then
+ if @parent_class == RDoc::File then
@parent = @store.add_file @parent_name
else
@parent = @store.find_class_or_module @parent_name
@@ -314,12 +314,12 @@ def parent_name
end
##
- # Records the RDoc::TopLevel (file) where this code object was defined
+ # Records the RDoc::File (file) where this code object was defined
- def record_location(top_level)
+ def record_location(file)
@ignored = false
@suppressed = false
- @file = top_level
+ @file = file
end
##
diff --git a/lib/rdoc/code_object/any_method.rb b/lib/rdoc/code_object/any_method.rb
index f56110ea11..dff39f186f 100644
--- a/lib/rdoc/code_object/any_method.rb
+++ b/lib/rdoc/code_object/any_method.rb
@@ -217,7 +217,7 @@ def marshal_load(array)
name.join '::'
end
- @file = RDoc::TopLevel.new array[10] if version > 0
+ @file = RDoc::File.new array[10] if version > 0
end
##
diff --git a/lib/rdoc/code_object/attr.rb b/lib/rdoc/code_object/attr.rb
index 969b18346d..e036437f7b 100644
--- a/lib/rdoc/code_object/attr.rb
+++ b/lib/rdoc/code_object/attr.rb
@@ -140,7 +140,7 @@ def marshal_load(array)
@parent_class = array[9]
@section_title = array[10]
- @file = RDoc::TopLevel.new array[7] if version > 1
+ @file = RDoc::File.new array[7] if version > 1
@parent_name ||= @full_name.split('#', 2).first
end
diff --git a/lib/rdoc/code_object/class_module.rb b/lib/rdoc/code_object/class_module.rb
index f6b0abb2f5..e1a5ace51f 100644
--- a/lib/rdoc/code_object/class_module.rb
+++ b/lib/rdoc/code_object/class_module.rb
@@ -393,7 +393,7 @@ def marshal_load(array) # :nodoc:
add_attribute attr
attr.visibility = visibility
- attr.record_location RDoc::TopLevel.new file
+ attr.record_location RDoc::File.new file
end
array[6].each do |constant, document, file|
@@ -402,13 +402,13 @@ def marshal_load(array) # :nodoc:
add_constant constant
else
constant = add_constant RDoc::Constant.new(constant, nil, RDoc::Comment.from_document(document))
- constant.record_location RDoc::TopLevel.new file
+ constant.record_location RDoc::File.new file
end
end
array[7].each do |name, document, file|
incl = add_include RDoc::Include.new(name, RDoc::Comment.from_document(document))
- incl.record_location RDoc::TopLevel.new file
+ incl.record_location RDoc::File.new file
end
array[8].each do |type, visibilities|
@@ -417,7 +417,7 @@ def marshal_load(array) # :nodoc:
methods.each do |name, file|
method = RDoc::AnyMethod.new nil, name, singleton: type == 'class'
- method.record_location RDoc::TopLevel.new file
+ method.record_location RDoc::File.new file
add_method method
end
end
@@ -425,7 +425,7 @@ def marshal_load(array) # :nodoc:
array[9].each do |name, document, file|
ext = add_extend RDoc::Extend.new(name, RDoc::Comment.from_document(document))
- ext.record_location RDoc::TopLevel.new file
+ ext.record_location RDoc::File.new file
end if array[9] # Support Marshal version 1
sections = (array[10] || []).map do |section|
@@ -438,7 +438,7 @@ def marshal_load(array) # :nodoc:
@in_files = []
(array[11] || []).each do |filename|
- record_location RDoc::TopLevel.new filename
+ record_location RDoc::File.new filename
end
@parent_name = array[12]
@@ -632,7 +632,7 @@ def parse(comment_location)
def path
prefix = options.class_module_path_prefix
return http_url unless prefix
- File.join(prefix, http_url)
+ ::File.join(prefix, http_url)
end
##
@@ -795,7 +795,7 @@ def update_aliases
cm_alias.name = const.name
# Don't move top-level aliases under Object, they look ugly there
- unless RDoc::TopLevel === cm_alias.parent then
+ unless RDoc::File === cm_alias.parent then
cm_alias.parent = self
cm_alias.full_name = nil # force update for new parent
end
diff --git a/lib/rdoc/code_object/constant.rb b/lib/rdoc/code_object/constant.rb
index d5f54edb67..47e071d900 100644
--- a/lib/rdoc/code_object/constant.rb
+++ b/lib/rdoc/code_object/constant.rb
@@ -144,7 +144,7 @@ def marshal_load(array)
@parent_class = array[8]
@section_title = array[9]
- @file = RDoc::TopLevel.new array[6]
+ @file = RDoc::File.new array[6]
end
##
diff --git a/lib/rdoc/code_object/context.rb b/lib/rdoc/code_object/context.rb
index 3a4dd0ec68..36ef61fa34 100644
--- a/lib/rdoc/code_object/context.rb
+++ b/lib/rdoc/code_object/context.rb
@@ -297,7 +297,7 @@ def add_class(class_type, given_name, superclass = '::Object')
# find the name & enclosing context
if given_name =~ /^:+(\w+)$/ then
full_name = $1
- enclosing = top_level
+ enclosing = file_context
name = full_name.split(/:+/).last
else
full_name = child_name given_name
@@ -361,7 +361,7 @@ def add_class(class_type, given_name, superclass = '::Object')
klass = @store.classes_hash[full_name]
if klass then
- # if TopLevel, it may not be registered in the classes:
+ # if File, it may not be registered in the classes:
enclosing.classes_hash[name] = klass
# update the superclass if needed
@@ -397,7 +397,7 @@ def add_class(class_type, given_name, superclass = '::Object')
##
# Adds the class or module +mod+ to the modules or
# classes Hash +self_hash+, and to +all_hash+ (either
- # TopLevel::modules_hash or TopLevel::classes_hash ),
+ # File::modules_hash or File::classes_hash ),
# unless #done_documenting is +true+. Sets the #parent of +mod+
# to +self+, and its #section to #current_section. Returns +mod+.
@@ -568,7 +568,7 @@ def add_module_alias(from, from_name, to, file)
def add_require(require)
return require unless @document_self
- if RDoc::TopLevel === self then
+ if RDoc::File === self then
add_to @requires, require
else
parent.add_require require
@@ -632,7 +632,7 @@ def any_content(includes = true)
def child_name(name)
if name =~ /^:+/
$' #'
- elsif RDoc::TopLevel === self then
+ elsif RDoc::File === self then
name
else
"#{self.full_name}::#{name}"
@@ -894,14 +894,14 @@ def find_symbol_module(symbol)
mod = searched.find_module_named(top)
break unless mod
result = @store.find_class_or_module "#{mod.full_name}::#{suffix}"
- break if result || searched.is_a?(RDoc::TopLevel)
+ break if result || searched.is_a?(RDoc::File)
searched = searched.parent
end
else
searched = self
while searched do
result = searched.find_module_named(symbol)
- break if result || searched.is_a?(RDoc::TopLevel)
+ break if result || searched.is_a?(RDoc::File)
searched = searched.parent
end
end
@@ -936,7 +936,7 @@ def http_url
path = path.gsub(/<<\s*(\w*)/, 'from-\1') if path =~ /<
path = path.split('::')
- File.join(*path.compact) + '.html'
+ ::File.join(*path.compact) + '.html'
end
##
@@ -1033,10 +1033,10 @@ def ongoing_visibility=(visibility)
end
##
- # Record +top_level+ as a file +self+ is in.
+ # Record +file+ as a file +self+ is in.
- def record_location(top_level)
- @in_files << top_level unless @in_files.include?(top_level)
+ def record_location(file)
+ @in_files << file unless @in_files.include?(file)
end
##
@@ -1189,18 +1189,20 @@ def to_s # :nodoc:
end
##
- # Return the TopLevel that owns us
+ # Return the File that owns us
#--
- # FIXME we can be 'owned' by several TopLevel (see #record_location &
+ # FIXME we can be 'owned' by several Files (see #record_location &
# #in_files)
- def top_level
- return @top_level if defined? @top_level
- @top_level = self
- @top_level = @top_level.parent until RDoc::TopLevel === @top_level
- @top_level
+ def file_context
+ return @file_context if defined? @file_context
+ @file_context = self
+ @file_context = @file_context.parent until @file_context.nil? or RDoc::File === @file_context
+ @file_context
end
+ alias_method :top_level, :file_context # :nodoc:
+
##
# Upgrades NormalModule +mod+ in +enclosing+ to a +class_type+
diff --git a/lib/rdoc/code_object/file.rb b/lib/rdoc/code_object/file.rb
new file mode 100644
index 0000000000..88e9188ed2
--- /dev/null
+++ b/lib/rdoc/code_object/file.rb
@@ -0,0 +1,266 @@
+# frozen_string_literal: true
+##
+# A File context is a representation of the contents of a single file
+
+class RDoc::File < RDoc::Context
+
+ MARSHAL_VERSION = 0 # :nodoc:
+
+ ##
+ # Relative name of this file
+
+ attr_accessor :relative_name
+
+ ##
+ # Absolute name of this file
+
+ attr_accessor :absolute_name
+
+ ##
+ # Base name of this file
+
+ attr_reader :base_name
+
+ ##
+ # Base name of this file without the extension
+
+ attr_reader :page_name
+
+ ##
+ # All the classes or modules that were declared in
+ # this file. These are assigned to either +#classes_hash+
+ # or +#modules_hash+ once we know what they really are.
+
+ attr_reader :classes_or_modules
+
+ ##
+ # The parser class that processed this file
+
+ attr_reader :parser
+
+ ##
+ # Creates a new File for the file at +absolute_name+. If documentation
+ # is being generated outside the source dir +relative_name+ is relative to
+ # the source directory.
+
+ def initialize(absolute_name, relative_name = absolute_name)
+ super()
+ @name = nil
+ @absolute_name = absolute_name
+ @relative_name = relative_name
+ @parser = nil
+
+ if relative_name
+ @base_name = ::File.basename(relative_name)
+ @page_name = @base_name.sub(/\.(rb|rdoc|txt|md)\z/i, '')
+ else
+ @base_name = nil
+ @page_name = nil
+ end
+
+ @classes_or_modules = []
+ end
+
+ ##
+ # Sets the parser for this file context, also the store.
+
+ def parser=(val)
+ @parser = val
+ @store.update_parser_of_file(absolute_name, val) if @store
+ @parser
+ end
+
+ ##
+ # An RDoc::File is equal to another with the same relative_name
+
+ def ==(other)
+ self.class === other and @relative_name == other.relative_name
+ end
+
+ alias eql? ==
+
+ ##
+ # Adds +an_alias+ to +Object+ instead of +self+.
+
+ def add_alias(an_alias)
+ object_class.record_location self
+ return an_alias unless @document_self
+ object_class.add_alias an_alias
+ end
+
+ ##
+ # Adds +constant+ to +Object+ instead of +self+.
+
+ def add_constant(constant)
+ object_class.record_location self
+ return constant unless @document_self
+ object_class.add_constant constant
+ end
+
+ ##
+ # Adds +include+ to +Object+ instead of +self+.
+
+ def add_include(include)
+ object_class.record_location self
+ return include unless @document_self
+ object_class.add_include include
+ end
+
+ ##
+ # Adds +method+ to +Object+ instead of +self+.
+
+ def add_method(method)
+ object_class.record_location self
+ return method unless @document_self
+ object_class.add_method method
+ end
+
+ ##
+ # Adds class or module +mod+. Used in the building phase
+ # by the Ruby parser.
+
+ def add_to_classes_or_modules(mod)
+ @classes_or_modules << mod
+ end
+
+ alias name base_name
+
+ ##
+ # See RDoc::File::find_class_or_module
+ #--
+ # TODO Why do we search through all classes/modules found, not just the
+ # ones of this instance?
+
+ def find_class_or_module(name)
+ @store.find_class_or_module name
+ end
+
+ ##
+ # Finds a class or module named +symbol+
+
+ def find_local_symbol(symbol)
+ find_class_or_module(symbol) || super
+ end
+
+ ##
+ # Finds a module or class with +name+
+
+ def find_module_named(name)
+ find_class_or_module(name)
+ end
+
+ ##
+ # Returns the relative name of this file
+
+ def full_name
+ @relative_name
+ end
+
+ ##
+ # An RDoc::File has the same hash as another with the same
+ # relative_name
+
+ def hash
+ @relative_name.hash
+ end
+
+ ##
+ # URL for this with a +prefix+
+
+ def http_url
+ @relative_name.tr('.', '_') + '.html'
+ end
+
+ def inspect # :nodoc:
+ "#<%s:0x%x %p modules: %p classes: %p>" % [
+ self.class, object_id,
+ base_name,
+ @modules.map { |n, m| m },
+ @classes.map { |n, c| c }
+ ]
+ end
+
+ ##
+ # Dumps this File for use by ri. See also #marshal_load
+
+ def marshal_dump
+ [
+ MARSHAL_VERSION,
+ @relative_name,
+ @parser,
+ parse(@comment),
+ ]
+ end
+
+ ##
+ # Loads this File from +array+.
+
+ def marshal_load(array) # :nodoc:
+ initialize array[1]
+
+ @parser = array[2]
+ @comment = RDoc::Comment.from_document array[3]
+ end
+
+ ##
+ # Returns the NormalClass "Object", creating it if not found.
+ #
+ # Records +self+ as a location in "Object".
+
+ def object_class
+ @object_class ||= begin
+ oc = @store.find_class_named('Object') || add_class(RDoc::NormalClass, 'Object')
+ oc.record_location self
+ oc
+ end
+ end
+
+ ##
+ # Path to this file for use with HTML generator output.
+
+ def path
+ prefix = options.file_path_prefix
+ return http_url unless prefix
+ ::File.join(prefix, http_url)
+ end
+
+ def pretty_print(q) # :nodoc:
+ q.group 2, "[#{self.class}: ", "]" do
+ q.text "base name: #{base_name.inspect}"
+ q.breakable
+
+ items = @modules.map { |n, m| m }
+ items.concat @modules.map { |n, c| c }
+ q.seplist items do |mod| q.pp mod end
+ end
+ end
+
+ ##
+ # Search record used by RDoc::Generator::JsonIndex
+
+ def search_record
+ return unless @parser < RDoc::Parser::Text
+
+ [
+ page_name,
+ '',
+ page_name,
+ '',
+ path,
+ '',
+ snippet(@comment),
+ ]
+ end
+
+ ##
+ # Is this File from a text file instead of a source code file?
+
+ def text?
+ @parser and @parser.include? RDoc::Parser::Text
+ end
+
+ def to_s # :nodoc:
+ "file #{full_name}"
+ end
+
+end
diff --git a/lib/rdoc/code_object/require.rb b/lib/rdoc/code_object/require.rb
index f47e3b1534..fcb721b3e1 100644
--- a/lib/rdoc/code_object/require.rb
+++ b/lib/rdoc/code_object/require.rb
@@ -15,7 +15,7 @@ class RDoc::Require < RDoc::CodeObject
def initialize(name, comment)
super()
@name = name.gsub(/'|"/, "") #'
- @top_level = nil
+ @file_context = nil
self.comment = comment
end
@@ -33,19 +33,21 @@ def to_s # :nodoc:
end
##
- # The RDoc::TopLevel corresponding to this require, or +nil+ if not found.
+ # The RDoc::File corresponding to this require, or +nil+ if not found.
- def top_level
- @top_level ||= begin
- tl = RDoc::TopLevel.all_files_hash[name + '.rb']
+ def file_context
+ @file_context ||= begin
+ f = RDoc::File.all_files_hash[name + '.rb']
- if tl.nil? and RDoc::TopLevel.all_files.first.full_name =~ %r(^lib/) then
+ if f.nil? and RDoc::File.all_files.first.full_name =~ %r(^lib/) then
# second chance
- tl = RDoc::TopLevel.all_files_hash['lib/' + name + '.rb']
+ f = RDoc::File.all_files_hash['lib/' + name + '.rb']
end
- tl
+ f
end
end
+ alias_method :top_level, :file_context # :nodoc:
+
end
diff --git a/lib/rdoc/code_object/top_level.rb b/lib/rdoc/code_object/top_level.rb
index c1c003130e..87f4e4f4f0 100644
--- a/lib/rdoc/code_object/top_level.rb
+++ b/lib/rdoc/code_object/top_level.rb
@@ -1,266 +1,12 @@
# frozen_string_literal: true
-##
-# A TopLevel context is a representation of the contents of a single file
-
-class RDoc::TopLevel < RDoc::Context
-
- MARSHAL_VERSION = 0 # :nodoc:
-
- ##
- # Relative name of this file
-
- attr_accessor :relative_name
-
- ##
- # Absolute name of this file
-
- attr_accessor :absolute_name
-
- ##
- # Base name of this file
-
- attr_reader :base_name
-
- ##
- # Base name of this file without the extension
-
- attr_reader :page_name
-
- ##
- # All the classes or modules that were declared in
- # this file. These are assigned to either +#classes_hash+
- # or +#modules_hash+ once we know what they really are.
-
- attr_reader :classes_or_modules
-
- ##
- # The parser class that processed this file
-
- attr_reader :parser
-
- ##
- # Creates a new TopLevel for the file at +absolute_name+. If documentation
- # is being generated outside the source dir +relative_name+ is relative to
- # the source directory.
-
- def initialize(absolute_name, relative_name = absolute_name)
- super()
- @name = nil
- @absolute_name = absolute_name
- @relative_name = relative_name
- @parser = nil
-
- if relative_name
- @base_name = File.basename(relative_name)
- @page_name = @base_name.sub(/\.(rb|rdoc|txt|md)\z/i, '')
- else
- @base_name = nil
- @page_name = nil
- end
-
- @classes_or_modules = []
- end
-
- ##
- # Sets the parser for this toplevel context, also the store.
-
- def parser=(val)
- @parser = val
- @store.update_parser_of_file(absolute_name, val) if @store
- @parser
- end
-
- ##
- # An RDoc::TopLevel is equal to another with the same relative_name
-
- def ==(other)
- self.class === other and @relative_name == other.relative_name
- end
-
- alias eql? ==
-
- ##
- # Adds +an_alias+ to +Object+ instead of +self+.
-
- def add_alias(an_alias)
- object_class.record_location self
- return an_alias unless @document_self
- object_class.add_alias an_alias
- end
-
- ##
- # Adds +constant+ to +Object+ instead of +self+.
-
- def add_constant(constant)
- object_class.record_location self
- return constant unless @document_self
- object_class.add_constant constant
- end
-
- ##
- # Adds +include+ to +Object+ instead of +self+.
-
- def add_include(include)
- object_class.record_location self
- return include unless @document_self
- object_class.add_include include
- end
-
- ##
- # Adds +method+ to +Object+ instead of +self+.
-
- def add_method(method)
- object_class.record_location self
- return method unless @document_self
- object_class.add_method method
- end
- ##
- # Adds class or module +mod+. Used in the building phase
- # by the Ruby parser.
+require_relative "file"
- def add_to_classes_or_modules(mod)
- @classes_or_modules << mod
- end
-
- alias name base_name
-
- ##
- # See RDoc::TopLevel::find_class_or_module
- #--
- # TODO Why do we search through all classes/modules found, not just the
- # ones of this instance?
-
- def find_class_or_module(name)
- @store.find_class_or_module name
- end
-
- ##
- # Finds a class or module named +symbol+
-
- def find_local_symbol(symbol)
- find_class_or_module(symbol) || super
- end
-
- ##
- # Finds a module or class with +name+
-
- def find_module_named(name)
- find_class_or_module(name)
- end
-
- ##
- # Returns the relative name of this file
-
- def full_name
- @relative_name
- end
-
- ##
- # An RDoc::TopLevel has the same hash as another with the same
- # relative_name
-
- def hash
- @relative_name.hash
- end
-
- ##
- # URL for this with a +prefix+
-
- def http_url
- @relative_name.tr('.', '_') + '.html'
- end
-
- def inspect # :nodoc:
- "#<%s:0x%x %p modules: %p classes: %p>" % [
- self.class, object_id,
- base_name,
- @modules.map { |n, m| m },
- @classes.map { |n, c| c }
- ]
- end
-
- ##
- # Dumps this TopLevel for use by ri. See also #marshal_load
-
- def marshal_dump
- [
- MARSHAL_VERSION,
- @relative_name,
- @parser,
- parse(@comment),
- ]
- end
-
- ##
- # Loads this TopLevel from +array+.
-
- def marshal_load(array) # :nodoc:
- initialize array[1]
-
- @parser = array[2]
- @comment = RDoc::Comment.from_document array[3]
- end
-
- ##
- # Returns the NormalClass "Object", creating it if not found.
- #
- # Records +self+ as a location in "Object".
-
- def object_class
- @object_class ||= begin
- oc = @store.find_class_named('Object') || add_class(RDoc::NormalClass, 'Object')
- oc.record_location self
- oc
- end
- end
-
- ##
- # Path to this file for use with HTML generator output.
-
- def path
- prefix = options.file_path_prefix
- return http_url unless prefix
- File.join(prefix, http_url)
- end
-
- def pretty_print(q) # :nodoc:
- q.group 2, "[#{self.class}: ", "]" do
- q.text "base name: #{base_name.inspect}"
- q.breakable
-
- items = @modules.map { |n, m| m }
- items.concat @modules.map { |n, c| c }
- q.seplist items do |mod| q.pp mod end
- end
- end
-
- ##
- # Search record used by RDoc::Generator::JsonIndex
-
- def search_record
- return unless @parser < RDoc::Parser::Text
-
- [
- page_name,
- '',
- page_name,
- '',
- path,
- '',
- snippet(@comment),
- ]
- end
-
- ##
- # Is this TopLevel from a text file instead of a source code file?
-
- def text?
- @parser and @parser.include? RDoc::Parser::Text
- end
-
- def to_s # :nodoc:
- "file #{full_name}"
- end
+##
+# RDoc::TopLevel is deprecated and will be removed in a future version.
+# Use RDoc::File instead.
+module RDoc
+ TopLevel = File # :nodoc:
+ deprecate_constant :TopLevel
end
diff --git a/lib/rdoc/comment.rb b/lib/rdoc/comment.rb
index 5d71cd35bd..87783bee3c 100644
--- a/lib/rdoc/comment.rb
+++ b/lib/rdoc/comment.rb
@@ -19,7 +19,7 @@ class RDoc::Comment
attr_reader :format
##
- # The RDoc::TopLevel this comment was found in
+ # The RDoc::File this comment was found in
attr_accessor :location
@@ -50,7 +50,7 @@ class RDoc::Comment
attr_writer :document
##
- # Creates a new comment with +text+ that is found in the RDoc::TopLevel
+ # Creates a new comment with +text+ that is found in the RDoc::File
# +location+.
def initialize(text = nil, location = nil, language = nil)
@@ -246,7 +246,7 @@ class << self
def from_document(document) # :nodoc:
comment = RDoc::Comment.new('')
comment.document = document
- comment.location = RDoc::TopLevel.new(document.file) if document.file
+ comment.location = RDoc::File.new(document.file) if document.file
comment
end
diff --git a/lib/rdoc/cross_reference.rb b/lib/rdoc/cross_reference.rb
index 1f33538b73..4b2a03be78 100644
--- a/lib/rdoc/cross_reference.rb
+++ b/lib/rdoc/cross_reference.rb
@@ -159,7 +159,7 @@ def resolve_method(name)
end
if container then
- unless RDoc::TopLevel === container then
+ unless RDoc::File === container then
if '.' == type then
if 'new' == method then # AnyClassName.new will be class method
ref = container.find_local_symbol method
diff --git a/lib/rdoc/encoding.rb b/lib/rdoc/encoding.rb
index 78dbe87d0c..4804e0037c 100644
--- a/lib/rdoc/encoding.rb
+++ b/lib/rdoc/encoding.rb
@@ -30,7 +30,7 @@ module RDoc::Encoding
# unknown character in the target encoding will be replaced with '?'
def self.read_file(filename, encoding, force_transcode = false)
- content = File.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/, '')
diff --git a/lib/rdoc/erbio.rb b/lib/rdoc/erbio.rb
index e955eed811..ea5a0f6743 100644
--- a/lib/rdoc/erbio.rb
+++ b/lib/rdoc/erbio.rb
@@ -9,7 +9,7 @@
#
# erbio = RDoc::ERBIO.new '<%= "hello world" %>', nil, nil
#
-# File.open 'hello.txt', 'w' do |io|
+# ::File.open 'hello.txt', 'w' do |io|
# erbio.result binding
# end
#
diff --git a/lib/rdoc/generator.rb b/lib/rdoc/generator.rb
index e8a14d4a66..eb4be6bbbd 100644
--- a/lib/rdoc/generator.rb
+++ b/lib/rdoc/generator.rb
@@ -31,9 +31,9 @@
# #initialize with an RDoc::Store instance and an RDoc::Options instance.
#
# The RDoc::Store instance holds documentation for parsed source code. In
-# RDoc 3 and earlier the RDoc::TopLevel class held this data. When upgrading
+# RDoc 3 and earlier the RDoc::File class held this data. When upgrading
# a generator from RDoc 3 and earlier you should only need to replace
-# RDoc::TopLevel with the store instance.
+# RDoc::File with the store instance.
#
# RDoc will then call #generate on the generator instance. You can use the
# various methods on RDoc::Store and in the RDoc::CodeObject tree to create
diff --git a/lib/rdoc/generator/aliki.rb b/lib/rdoc/generator/aliki.rb
index faa310451c..5ce7f1d138 100644
--- a/lib/rdoc/generator/aliki.rb
+++ b/lib/rdoc/generator/aliki.rb
@@ -11,7 +11,7 @@ class RDoc::Generator::Aliki < RDoc::Generator::Darkfish
def initialize(store, options)
super
- aliki_template_dir = File.expand_path(File.join(__dir__, 'template', 'aliki'))
+ aliki_template_dir = ::File.expand_path(::File.join(__dir__, 'template', 'aliki'))
@template_dir = Pathname.new(aliki_template_dir)
end
@@ -31,8 +31,8 @@ def write_style_sheet
end
Dir[(@template_dir + 'js/**/*').to_s].each do |path|
- next if File.directory?(path)
- next if File.basename(path).start_with?('.')
+ next if ::File.directory?(path)
+ next if ::File.basename(path).start_with?('.')
dst = Pathname.new(path).relative_path_from(@template_dir)
diff --git a/lib/rdoc/generator/darkfish.rb b/lib/rdoc/generator/darkfish.rb
index 9679216b95..fea0b3c11b 100644
--- a/lib/rdoc/generator/darkfish.rb
+++ b/lib/rdoc/generator/darkfish.rb
@@ -203,8 +203,8 @@ def write_style_sheet
end
Dir[(@template_dir + "{js,images}/**/*").to_s].each do |path|
- next if File.directory? path
- next if File.basename(path) =~ /^\./
+ next if ::File.directory? path
+ next if ::File.basename(path) =~ /^\./
dst = Pathname.new(path).relative_path_from @template_dir
@@ -213,7 +213,7 @@ def write_style_sheet
end
##
- # Build the initial indices and output objects based on an array of TopLevel
+ # Build the initial indices and output objects based on an array of File
# objects containing the extracted information.
def generate
@@ -246,16 +246,16 @@ def copy_static
fu_options = { :verbose => $DEBUG_RDOC, :noop => @dry_run }
@options.static_path.each do |path|
- unless File.directory? path then
+ unless ::File.directory? path then
FileUtils.install path, @outputdir, **fu_options.merge(:mode => 0644)
next
end
Dir.chdir path do
- Dir[File.join('**', '*')].each do |entry|
+ Dir[::File.join('**', '*')].each do |entry|
dest_file = @outputdir + entry
- if File.directory? entry then
+ if ::File.directory? entry then
FileUtils.mkdir_p entry, **fu_options
else
FileUtils.install entry, dest_file, **fu_options.merge(:mode => 0644)
@@ -555,7 +555,7 @@ def install_rdoc_static_file(source, destination, options) # :nodoc:
return unless source.exist?
begin
- FileUtils.mkdir_p File.dirname(destination), **options
+ FileUtils.mkdir_p ::File.dirname(destination), **options
begin
FileUtils.ln source, destination, **options
@@ -688,7 +688,7 @@ def template_for(file, page = true, klass = ERB)
template = file.read
template = template.encode @options.encoding
- file_var = File.basename(file).sub(/\..*/, '')
+ file_var = ::File.basename(file).sub(/\..*/, '')
erbout = "_erbout_#{file_var}"
end
diff --git a/lib/rdoc/generator/json_index.rb b/lib/rdoc/generator/json_index.rb
index 065caa47ea..ec5fa8e0a8 100644
--- a/lib/rdoc/generator/json_index.rb
+++ b/lib/rdoc/generator/json_index.rb
@@ -81,7 +81,7 @@ class RDoc::Generator::JsonIndex
##
# Where the search index lives in the generated output
- SEARCH_INDEX_FILE = File.join 'js', 'search_index.js'
+ SEARCH_INDEX_FILE = ::File.join 'js', 'search_index.js'
attr_reader :index # :nodoc:
@@ -94,7 +94,7 @@ def initialize(parent_generator, options)
@store = parent_generator.store
@options = options
- @template_dir = File.expand_path '../template/json_index', __FILE__
+ @template_dir = ::File.expand_path '../template/json_index', __FILE__
@base_dir = @parent_generator.base_dir
@classes = nil
@@ -151,7 +151,7 @@ def generate
Dir.chdir @template_dir do
Dir['**/*.js'].each do |source|
- dest = File.join out_dir, source
+ dest = ::File.join out_dir, source
FileUtils.install source, dest, :mode => 0644, :preserve => true, :verbose => $DEBUG_RDOC
end
@@ -176,7 +176,7 @@ def generate_gzipped
debug_msg "Writing gzipped search index to %s" % outfile
Zlib::GzipWriter.open(outfile) do |gz|
- gz.mtime = File.mtime(search_index_file)
+ gz.mtime = ::File.mtime(search_index_file)
gz.orig_name = search_index_file.basename.to_s
gz.write search_index
gz.close
@@ -194,7 +194,7 @@ def generate_gzipped
debug_msg "Writing gzipped file to %s" % outfile
Zlib::GzipWriter.open(outfile) do |gz|
- gz.mtime = File.mtime(dest)
+ gz.mtime = ::File.mtime(dest)
gz.orig_name = dest.basename.to_s
gz.write data
gz.close
diff --git a/lib/rdoc/generator/markup.rb b/lib/rdoc/generator/markup.rb
index 1c39687040..0f80db634c 100644
--- a/lib/rdoc/generator/markup.rb
+++ b/lib/rdoc/generator/markup.rb
@@ -61,7 +61,7 @@ def cvs_url(url, full_path)
def canonical_url
options = @store.options
if path
- File.join(options.canonical_root, path.to_s)
+ ::File.join(options.canonical_root, path.to_s)
else
options.canonical_root
end
@@ -152,7 +152,7 @@ class RDoc::Context::Section
end
-class RDoc::TopLevel
+class RDoc::File
##
# Returns a URL for this source file on some web repository. Use the -W
diff --git a/lib/rdoc/generator/pot.rb b/lib/rdoc/generator/pot.rb
index a20fde077b..4d599d797d 100644
--- a/lib/rdoc/generator/pot.rb
+++ b/lib/rdoc/generator/pot.rb
@@ -76,7 +76,7 @@ def initialize(store, options) #:not-new:
def generate
po = extract_messages
pot_path = 'rdoc.pot'
- File.open(pot_path, "w") do |pot|
+ ::File.open(pot_path, "w") do |pot|
pot.print(po.to_s)
end
end
diff --git a/lib/rdoc/generator/template/aliki/_head.rhtml b/lib/rdoc/generator/template/aliki/_head.rhtml
index d7392f3487..1327b2f0cf 100644
--- a/lib/rdoc/generator/template/aliki/_head.rhtml
+++ b/lib/rdoc/generator/template/aliki/_head.rhtml
@@ -152,7 +152,7 @@
<%- @options.template_stylesheets.each do |stylesheet| %>
<%- end %>
diff --git a/lib/rdoc/generator/template/darkfish/_head.rhtml b/lib/rdoc/generator/template/darkfish/_head.rhtml
index c90635877a..aed0e661c7 100644
--- a/lib/rdoc/generator/template/darkfish/_head.rhtml
+++ b/lib/rdoc/generator/template/darkfish/_head.rhtml
@@ -39,5 +39,5 @@
<%- @options.template_stylesheets.each do |stylesheet| %>
-
+
<%- end %>
diff --git a/lib/rdoc/i18n/locale.rb b/lib/rdoc/i18n/locale.rb
index 6a70d6c986..478feba56e 100644
--- a/lib/rdoc/i18n/locale.rb
+++ b/lib/rdoc/i18n/locale.rb
@@ -64,11 +64,11 @@ def load(locale_directory)
return false if @name.nil?
po_file_candidates = [
- File.join(locale_directory, @name, 'rdoc.po'),
- File.join(locale_directory, "#{@name}.po"),
+ ::File.join(locale_directory, @name, 'rdoc.po'),
+ ::File.join(locale_directory, "#{@name}.po"),
]
po_file = po_file_candidates.find do |po_file_candidate|
- File.exist?(po_file_candidate)
+ ::File.exist?(po_file_candidate)
end
return false unless po_file
diff --git a/lib/rdoc/markdown.kpeg b/lib/rdoc/markdown.kpeg
index 46c8f07f41..d6c01c3a49 100644
--- a/lib/rdoc/markdown.kpeg
+++ b/lib/rdoc/markdown.kpeg
@@ -16,7 +16,7 @@
#
# Here is a brief example of using this parse to read a markdown file by hand.
#
-# data = File.read("README.md")
+# data = ::File.read("README.md")
# formatter = RDoc::Markup::ToHtml.new(RDoc::Options.new, nil)
# html = RDoc::Markdown.parse(data).accept(formatter)
#
diff --git a/lib/rdoc/markdown.rb b/lib/rdoc/markdown.rb
index e9cb35c244..c440ef5f95 100644
--- a/lib/rdoc/markdown.rb
+++ b/lib/rdoc/markdown.rb
@@ -13,7 +13,7 @@
#
# Here is a brief example of using this parse to read a markdown file by hand.
#
-# data = File.read("README.md")
+# data = ::File.read("README.md")
# formatter = RDoc::Markup::ToHtml.new(RDoc::Options.new, nil)
# html = RDoc::Markdown.parse(data).accept(formatter)
#
diff --git a/lib/rdoc/markup/document.rb b/lib/rdoc/markup/document.rb
index 399cfe8e3e..6ce1c31588 100644
--- a/lib/rdoc/markup/document.rb
+++ b/lib/rdoc/markup/document.rb
@@ -96,7 +96,7 @@ def empty?
def file=(location)
@file = case location
- when RDoc::TopLevel then
+ when RDoc::File then
location.relative_name
else
location
diff --git a/lib/rdoc/markup/formatter.rb b/lib/rdoc/markup/formatter.rb
index 8c55a37b06..aa8348c056 100644
--- a/lib/rdoc/markup/formatter.rb
+++ b/lib/rdoc/markup/formatter.rb
@@ -22,8 +22,8 @@ class RDoc::Markup::Formatter
# Converts a target url to one that is relative to a given path
def self.gen_relative_url(path, target)
- from = File.dirname path
- to, to_file = File.split target
+ from = ::File.dirname path
+ to, to_file = ::File.split target
from = from.split "/"
to = to.split "/"
@@ -39,7 +39,7 @@ def self.gen_relative_url(path, target)
from.fill ".."
from.concat to
from << to_file
- File.join(*from)
+ ::File.join(*from)
end
##
diff --git a/lib/rdoc/markup/pre_process.rb b/lib/rdoc/markup/pre_process.rb
index 9e36d7f0cd..0d7aedae5f 100644
--- a/lib/rdoc/markup/pre_process.rb
+++ b/lib/rdoc/markup/pre_process.rb
@@ -330,10 +330,10 @@ def include_file(name, indent, encoding)
# and then in each of the directories specified in the RDOC_INCLUDE path
def find_include_file(name)
- to_search = [File.dirname(@input_file_name)].concat @include_path
+ to_search = [::File.dirname(@input_file_name)].concat @include_path
to_search.each do |dir|
- full_name = File.join(dir, name)
- stat = File.stat(full_name) rescue next
+ full_name = ::File.join(dir, name)
+ stat = ::File.stat(full_name) rescue next
return full_name if stat.readable?
end
nil
diff --git a/lib/rdoc/markup/to_html_crossref.rb b/lib/rdoc/markup/to_html_crossref.rb
index c05a3b5b17..0e8ca845c9 100644
--- a/lib/rdoc/markup/to_html_crossref.rb
+++ b/lib/rdoc/markup/to_html_crossref.rb
@@ -164,7 +164,7 @@ def link(name, text, code = true, rdoc_ref: false)
else
path = ref ? ref.as_href(@from_path) : +""
- if code and RDoc::CodeObject === ref and !(RDoc::TopLevel === ref)
+ if code and RDoc::CodeObject === ref and !(RDoc::File === ref)
text = "#{CGI.escapeHTML text}"
end
diff --git a/lib/rdoc/options.rb b/lib/rdoc/options.rb
index c3f16d37b1..580c963ca7 100644
--- a/lib/rdoc/options.rb
+++ b/lib/rdoc/options.rb
@@ -556,8 +556,8 @@ def ==(other) # :nodoc:
def check_files
@files.delete_if do |file|
- if File.exist? file then
- if File.readable? file then
+ if ::File.exist? file then
+ if ::File.readable? file then
false
else
warn "file '#{file}' not readable"
@@ -726,7 +726,7 @@ def parse(argv)
opts = OptionParser.new do |opt|
@option_parser = opt
- opt.program_name = File.basename $0
+ opt.program_name = ::File.basename $0
opt.version = RDoc::VERSION
opt.release = nil
opt.summary_indent = ' ' * 4
@@ -789,17 +789,17 @@ def parse(argv)
end
opt.accept Directory do |directory|
- directory = File.expand_path directory
+ directory = ::File.expand_path directory
- raise OptionParser::InvalidArgument unless File.directory? directory
+ raise OptionParser::InvalidArgument unless ::File.directory? directory
directory
end
opt.accept Path do |path|
- path = File.expand_path path
+ path = ::File.expand_path path
- raise OptionParser::InvalidArgument unless File.exist? path
+ raise OptionParser::InvalidArgument unless ::File.exist? path
path
end
@@ -810,9 +810,9 @@ def parse(argv)
end
paths.map do |path|
- path = File.expand_path path
+ path = ::File.expand_path path
- raise OptionParser::InvalidArgument unless File.exist? path
+ raise OptionParser::InvalidArgument unless ::File.exist? path
path
end
@@ -1349,12 +1349,12 @@ def setup_generator(generator_name = @generator_name)
# Finds the template dir for +template+
def template_dir_for(template)
- template_path = File.join 'rdoc', 'generator', 'template', template
+ template_path = ::File.join 'rdoc', 'generator', 'template', template
$LOAD_PATH.map do |path|
- File.join File.expand_path(path), template_path
+ ::File.join ::File.expand_path(path), template_path
end.find do |dir|
- File.directory? dir
+ ::File.directory? dir
end
end
@@ -1388,7 +1388,7 @@ def warn(message)
def write_options
RDoc.load_yaml
- File.open '.rdoc_options', 'w' do |io|
+ ::File.open '.rdoc_options', 'w' do |io|
io.set_encoding Encoding::UTF_8
io.print to_yaml
@@ -1400,13 +1400,13 @@ def write_options
# new RDoc::Options instance.
def self.load_options
- options_file = File.expand_path '.rdoc_options'
- return RDoc::Options.new unless File.exist? options_file
+ options_file = ::File.expand_path '.rdoc_options'
+ return RDoc::Options.new unless ::File.exist? options_file
RDoc.load_yaml
begin
- options = YAML.safe_load File.read('.rdoc_options'), permitted_classes: [RDoc::Options, Symbol]
+ options = YAML.safe_load ::File.read('.rdoc_options'), permitted_classes: [RDoc::Options, Symbol]
rescue Psych::SyntaxError
raise RDoc::Error, "#{options_file} is not a valid rdoc options file"
end
diff --git a/lib/rdoc/parser.rb b/lib/rdoc/parser.rb
index 2ac960e089..0e7047d114 100644
--- a/lib/rdoc/parser.rb
+++ b/lib/rdoc/parser.rb
@@ -3,13 +3,13 @@
##
# A parser is simple a class that subclasses RDoc::Parser and implements #scan
-# to fill in an RDoc::TopLevel with parsed data.
+# to fill in an RDoc::File with parsed data.
#
-# The initialize method takes an RDoc::TopLevel to fill with parsed content,
+# The initialize method takes an RDoc::File to fill with parsed content,
# the name of the file to be parsed, the content of the file, an RDoc::Options
# object and an RDoc::Stats object to inform the user of parsed items. The
# scan method is then called to parse the file and must return the
-# RDoc::TopLevel object. By calling super these items will be set for you.
+# RDoc::File object. By calling super these items will be set for you.
#
# In order to be used by RDoc the parser needs to register the file extensions
# it can parse. Use ::parse_files_matching to register extensions.
@@ -19,14 +19,14 @@
# class RDoc::Parser::Xyz < RDoc::Parser
# parse_files_matching /\.xyz$/
#
-# def initialize top_level, file_name, content, options, stats
+# def initialize file, file_name, content, options, stats
# super
#
# # extra initialization if needed
# end
#
# def scan
-# # parse file and fill in @top_level
+# # parse file and fill in @file
# end
# end
@@ -74,7 +74,7 @@ def self.alias_extension(old_ext, new_ext)
def self.binary?(file)
return false if file =~ /\.(rdoc|txt)$/
- s = File.read(file, 1024) or return false
+ s = ::File.read(file, 1024) or return false
return true if s[0, 2] == Marshal.dump('')[0, 2] or s.index("\x00")
@@ -82,7 +82,7 @@ def self.binary?(file)
s.sub!(/\A#!.*\n/, '') # assume shebang line isn't longer than 1024.
encoding = s[/^\s*\#\s*(?:-\*-\s*)?(?:en)?coding:\s*([^\s;]+?)(?:-\*-|[\s;])/, 1]
mode = "rb:#{encoding}" if encoding
- s = File.open(file, mode) {|f| f.gets(nil, 1024)}
+ s = ::File.open(file, mode) {|f| f.gets(nil, 1024)}
not s.valid_encoding?
end
@@ -92,7 +92,7 @@ def self.binary?(file)
# http://www.garykessler.net/library/file_sigs.html
def self.zip?(file)
- zip_signature = File.read file, 4
+ zip_signature = ::File.read file, 4
zip_signature == "PK\x03\x04" or
zip_signature == "PK\x05\x06" or
@@ -121,7 +121,7 @@ def self.can_parse_by_name(file_name)
_, parser = RDoc::Parser.parsers.find { |regexp,| regexp =~ file_name }
# The default parser must not parse binary files
- ext_name = File.extname file_name
+ ext_name = ::File.extname file_name
return parser if ext_name.empty?
if parser == RDoc::Parser::Simple and ext_name !~ /txt|rdoc/ then
@@ -141,7 +141,7 @@ def self.can_parse_by_name(file_name)
# Returns the file type from the modeline in +file_name+
def self.check_modeline(file_name)
- line = File.open file_name do |io|
+ line = ::File.open file_name do |io|
io.gets
end
@@ -166,8 +166,8 @@ def self.check_modeline(file_name)
# Finds and instantiates the correct parser for the given +file_name+ and
# +content+.
- def self.for(top_level, content, options, stats)
- file_name = top_level.absolute_name
+ def self.for(file, content, options, stats)
+ file_name = file.absolute_name
return if binary? file_name
parser = use_markup content
@@ -191,7 +191,7 @@ def self.for(top_level, content, options, stats)
content = remove_modeline content
- parser.new top_level, content, options, stats
+ parser.new file, content, options, stats
rescue SystemCallError
nil
end
@@ -247,17 +247,17 @@ def self.use_markup(content)
end
##
- # Creates a new Parser storing +top_level+, +file_name+, +content+,
+ # Creates a new Parser storing +file+, +file_name+, +content+,
# +options+ and +stats+ in instance variables. In +@preprocess+ an
# RDoc::Markup::PreProcess object is created which allows processing of
# directives.
- def initialize(top_level, content, options, stats)
- @top_level = top_level
- @top_level.parser = self.class
- @store = @top_level.store
+ def initialize(file, content, options, stats)
+ @file = file
+ @file.parser = self.class
+ @store = @file.store
- @file_name = top_level.absolute_name
+ @file_name = file.absolute_name
@content = content
@options = options
@stats = stats
diff --git a/lib/rdoc/parser/c.rb b/lib/rdoc/parser/c.rb
index 603f28dfe1..e0aaf1f61b 100644
--- a/lib/rdoc/parser/c.rb
+++ b/lib/rdoc/parser/c.rb
@@ -160,20 +160,20 @@ class RDoc::Parser::C < RDoc::Parser
attr_reader :singleton_classes
##
- # The TopLevel items in the parsed file belong to
+ # The File items in the parsed file belong to
- attr_reader :top_level
+ attr_reader :file
##
# Prepares for parsing a C file. See RDoc::Parser#initialize for details on
# the arguments.
- def initialize(top_level, content, options, stats)
+ def initialize(file, content, options, stats)
super
@known_classes = RDoc::KNOWN_CLASSES.dup
@content = handle_tab_width handle_ifdefs_in @content
- @file_dir = File.dirname @file_name
+ @file_dir = ::File.dirname @file_name
@classes = load_variable_map :c_class_variables
@singleton_classes = load_variable_map :c_singleton_class_variables
@@ -249,7 +249,7 @@ def do_aliases
def add_alias(var_name, class_obj, old_name, new_name, comment)
al = RDoc::Alias.new '', old_name, new_name, comment, singleton: @singleton_classes.key?(var_name)
- al.record_location @top_level
+ al.record_location @file
class_obj.add_alias al
@stats.add_alias al
al
@@ -443,9 +443,9 @@ def do_includes
next unless cls = @classes[c]
m = @known_classes[m] || m
- comment = new_comment '', @top_level, :c
+ comment = new_comment '', @file, :c
incl = cls.add_include RDoc::Include.new(m, comment)
- incl.record_location @top_level
+ incl.record_location @file
end
end
@@ -525,7 +525,7 @@ def find_alias_comment(class_name, new_name, old_name)
\s*"#{Regexp.escape new_name}"\s*,
\s*"#{Regexp.escape old_name}"\s*\);%xm
- new_comment($1 || '', @top_level, :c)
+ new_comment($1 || '', @file, :c)
end
##
@@ -564,7 +564,7 @@ def find_attr_comment(var_name, attr_name, read = nil, write = nil)
''
end
- new_comment comment, @top_level, :c
+ new_comment comment, @file, :c
end
##
@@ -603,7 +603,7 @@ def find_body(class_name, meth_name, meth_obj, file_content, quiet = false)
case type
when :func_def
- comment = new_comment args[0], @top_level, :c
+ comment = new_comment args[0], @file, :c
body = args[1]
offset, = args[2]
@@ -630,7 +630,7 @@ def find_body(class_name, meth_name, meth_obj, file_content, quiet = false)
body
when :macro_def
- comment = new_comment args[0], @top_level, :c
+ comment = new_comment args[0], @file, :c
body = args[1]
offset, = args[2]
@@ -676,13 +676,13 @@ def find_body(class_name, meth_name, meth_obj, file_content, quiet = false)
def find_class(raw_name, name, base_name = nil)
unless @classes[raw_name]
if raw_name =~ /^rb_m/
- container = @top_level.add_module RDoc::NormalModule, name
+ container = @file.add_module RDoc::NormalModule, name
else
- container = @top_level.add_class RDoc::NormalClass, name
+ container = @file.add_class RDoc::NormalClass, name
end
container.name = base_name if base_name
- container.record_location @top_level
+ container.record_location @file
@classes[raw_name] = container
end
@classes[raw_name]
@@ -736,11 +736,11 @@ def find_class_comment(class_name, class_mod)
comment = ''
end
- comment = new_comment comment, @top_level, :c
+ comment = new_comment comment, @file, :c
look_for_directives_in class_mod, comment
- class_mod.add_comment comment, @top_level
+ class_mod.add_comment comment, @file
end
##
@@ -794,7 +794,7 @@ def find_const_comment(type, const_name, class_name = nil)
table[const_name] ||
''
- new_comment comment, @top_level, :c
+ new_comment comment, @file, :c
end
##
@@ -822,7 +822,7 @@ def find_override_comment(class_name, meth_obj)
return unless comment
- new_comment comment, @top_level, :c
+ new_comment comment, @file, :c
end
##
@@ -849,7 +849,7 @@ def handle_attr(var_name, attr_name, read, write)
attr = RDoc::Attr.new '', name, rw, comment
- attr.record_location @top_level
+ attr.record_location @file
class_obj.add_attribute attr
@stats.add_attribute attr
end
@@ -878,7 +878,7 @@ def handle_class_module(var_name, type, class_name, parent, in_module)
return
end
else
- enclosure = @top_level
+ enclosure = @file
end
if type == :class then
@@ -897,7 +897,7 @@ def handle_class_module(var_name, type, class_name, parent, in_module)
cm = enclosure.add_module RDoc::NormalModule, class_name
end
- cm.record_location enclosure.top_level
+ cm.record_location enclosure.file_context
find_class_comment cm.full_name, cm
@@ -955,7 +955,7 @@ def handle_constants(type, var_name, const_name, definition)
new_comment = "#{$1}#{new_comment.lstrip}"
- new_comment = self.new_comment(new_comment, @top_level, :c)
+ new_comment = self.new_comment(new_comment, @file, :c)
con = RDoc::Constant.new const_name, new_definition, new_comment
else
@@ -965,7 +965,7 @@ def handle_constants(type, var_name, const_name, definition)
con = RDoc::Constant.new const_name, definition, comment
end
- con.record_location @top_level
+ con.record_location @file
@stats.add_constant con
class_obj.add_constant con
end
@@ -1011,10 +1011,10 @@ def handle_method(type, var_name, meth_name, function, param_count,
p_count = Integer(param_count) rescue -1
if source_file then
- file_name = File.join @file_dir, source_file
+ file_name = ::File.join @file_dir, source_file
- if File.exist? file_name then
- file_content = File.read file_name
+ if ::File.exist? file_name then
+ file_content = ::File.read file_name
else
@options.warn "unknown source #{source_file} for #{meth_name} in #{@file_name}"
end
@@ -1035,7 +1035,7 @@ def handle_method(type, var_name, meth_name, function, param_count,
end
- meth_obj.record_location @top_level
+ meth_obj.record_location @file
if meth_obj.section_title
class_obj.temporary_section = class_obj.add_section(meth_obj.section_title)
@@ -1196,7 +1196,7 @@ def remove_commented_out_lines
##
# Extracts the classes, modules, methods, attributes, constants and aliases
- # from a C file and returns an RDoc::TopLevel for this file
+ # from a C file and returns an RDoc::File for this file
def scan
remove_commented_out_lines
@@ -1212,7 +1212,7 @@ def scan
@store.add_c_variables self
- @top_level
+ @file
end
##
diff --git a/lib/rdoc/parser/changelog.rb b/lib/rdoc/parser/changelog.rb
index b8ad2393b1..f9ff4d4504 100644
--- a/lib/rdoc/parser/changelog.rb
+++ b/lib/rdoc/parser/changelog.rb
@@ -44,9 +44,9 @@ def continue_entry_body(entry_body, continuation)
def create_document(groups)
doc = RDoc::Markup::Document.new
doc.omit_headings_below = 2
- doc.file = @top_level
+ doc.file = @file
- doc << RDoc::Markup::Heading.new(1, File.basename(@file_name))
+ doc << RDoc::Markup::Heading.new(1, ::File.basename(@file_name))
doc << RDoc::Markup::BlankLine.new
groups.sort_by do |day,| day end.reverse_each do |day, entries|
@@ -212,9 +212,9 @@ def scan
doc = create_document grouped_entries
comment = RDoc::Comment.new(@content)
comment.document = doc
- @top_level.comment = comment
+ @file.comment = comment
- @top_level
+ @file
end
##
diff --git a/lib/rdoc/parser/markdown.rb b/lib/rdoc/parser/markdown.rb
index 3c316227b9..cd70d4e203 100644
--- a/lib/rdoc/parser/markdown.rb
+++ b/lib/rdoc/parser/markdown.rb
@@ -10,13 +10,13 @@ class RDoc::Parser::Markdown < RDoc::Parser
parse_files_matching(/\.(md|markdown)(?:\.[^.]+)?$/)
##
- # Creates an Markdown-format TopLevel for the given file.
+ # Creates an Markdown-format File for the given file.
def scan
- comment = RDoc::Comment.new @content, @top_level
+ comment = RDoc::Comment.new @content, @file
comment.format = 'markdown'
- @top_level.comment = comment
+ @file.comment = comment
end
end
diff --git a/lib/rdoc/parser/prism_ruby.rb b/lib/rdoc/parser/prism_ruby.rb
index 56da6ac227..be01af813d 100644
--- a/lib/rdoc/parser/prism_ruby.rb
+++ b/lib/rdoc/parser/prism_ruby.rb
@@ -18,7 +18,7 @@ class RDoc::Parser::PrismRuby < RDoc::Parser
attr_accessor :visibility
attr_reader :container, :singleton
- def initialize(top_level, content, options, stats)
+ def initialize(file, content, options, stats)
super
content = handle_tab_width(content)
@@ -31,8 +31,8 @@ def initialize(top_level, content, options, stats)
@track_visibility = :nodoc != @options.visibility
@encoding = @options.encoding
- @module_nesting = [[top_level, false]]
- @container = top_level
+ @module_nesting = [[file, false]]
+ @container = file
@visibility = :public
@singleton = false
@in_proc_block = false
@@ -80,10 +80,10 @@ def with_container(container, singleton: false)
def record_location(container) # :nodoc:
case container
when RDoc::ClassModule then
- @top_level.add_to_classes_or_modules container
+ @file.add_to_classes_or_modules container
end
- container.record_location @top_level
+ container.record_location @file
end
# Scans this Ruby file for Ruby constructs
@@ -96,14 +96,14 @@ def scan
@line_nodes = {}
prepare_line_nodes(@program_node)
prepare_comments(result.comments)
- return if @top_level.done_documenting
+ return if @file.done_documenting
@first_non_meta_comment_start_line = nil
if (_line_no, start_line = @unprocessed_comments.first)
@first_non_meta_comment_start_line = start_line if start_line < @program_node.location.start_line
end
- @program_node.accept(RDocVisitor.new(self, @top_level, @store))
+ @program_node.accept(RDocVisitor.new(self, @file, @store))
process_comments_until(@lines.size + 1)
end
@@ -323,7 +323,7 @@ def process_comments_until(line_no_until)
while !@unprocessed_comments.empty? && @unprocessed_comments.first[0] <= line_no_until
line_no, start_line, text = @unprocessed_comments.shift
if @markup == 'tomdoc'
- comment = RDoc::Comment.new(text, @top_level, :ruby)
+ comment = RDoc::Comment.new(text, @file, :ruby)
comment.format = 'tomdoc'
parse_comment_tomdoc(@container, comment, line_no, start_line)
@preprocess.run_post_processes(comment, @container)
@@ -354,7 +354,7 @@ def consecutive_comment(line_no)
def parse_comment_text_to_directives(comment_text, start_line) # :nodoc:
comment_text, directives = @preprocess.parse_comment(comment_text, start_line, :ruby)
- comment = RDoc::Comment.new(comment_text, @top_level, :ruby)
+ comment = RDoc::Comment.new(comment_text, @file, :ruby)
comment.normalized = true
comment.line = start_line
markup, = directives['markup']
@@ -378,7 +378,7 @@ def slice_tokens(start_pos, end_pos) # :nodoc:
def file_line_comment_token(line_no) # :nodoc:
position_comment = RDoc::Parser::RipperStateLex::Token.new(line_no - 1, 0, :on_comment)
- position_comment[:text] = "# File #{@top_level.relative_name}, line #{line_no}"
+ position_comment[:text] = "# File #{@file.relative_name}, line #{line_no}"
position_comment
end
@@ -586,7 +586,7 @@ def find_or_create_module_path(module_name, create_mode)
end
}
if root_name.empty?
- mod = @top_level
+ mod = @file
else
@module_nesting.reverse_each do |nesting, singleton|
next if singleton
@@ -617,7 +617,7 @@ def resolve_constant_path(constant_path)
mod = nesting.find_module_named(owner_name)
break if mod
end
- mod ||= @top_level.find_module_named(owner_name)
+ mod ||= @file.find_module_named(owner_name)
[mod.full_name, path].compact.join('::') if mod
end
@@ -632,7 +632,7 @@ def find_or_create_constant_owner_name(constant_path)
# but RDoc don't track constants of a singleton class of module
[(@singleton ? nil : @container), name]
elsif const_path.empty? # class ::Foo
- [@top_level, name]
+ [@file, name]
else # `class Foo::Bar` or `class ::Foo::Bar`
[find_or_create_module_path(const_path, :module), name]
end
@@ -660,7 +660,7 @@ def add_constant(constant_name, rhs_name, start_line, end_line)
@container.find_module_named(rhs_name)
end
if mod && constant.document_self
- a = @container.add_module_alias(mod, rhs_name, constant, @top_level)
+ a = @container.add_module_alias(mod, rhs_name, constant, @file)
a.store = @store
a.line = start_line
record_location(a)
@@ -704,14 +704,14 @@ def add_module_or_class(module_name, start_line, end_line, is_class: false, supe
record_location(mod)
handle_modifier_directive(mod, start_line)
handle_modifier_directive(mod, end_line)
- mod.add_comment(comment, @top_level) if comment
+ mod.add_comment(comment, @file) if comment
mod
end
class RDocVisitor < Prism::Visitor # :nodoc:
- def initialize(scanner, top_level, store)
+ def initialize(scanner, file, store)
@scanner = scanner
- @top_level = top_level
+ @file = file
@store = store
end
@@ -841,7 +841,7 @@ def visit_singleton_class_node(node)
# If a constant_path does not exist, RDoc creates a module
mod = @scanner.find_or_create_module_path(expression_name, :module) if expression_name
when Prism::SelfNode
- mod = @scanner.container if @scanner.container != @top_level
+ mod = @scanner.container if @scanner.container != @file
end
expression.accept(self)
if mod
diff --git a/lib/rdoc/parser/rd.rb b/lib/rdoc/parser/rd.rb
index 19e47e549d..a613c3ddca 100644
--- a/lib/rdoc/parser/rd.rb
+++ b/lib/rdoc/parser/rd.rb
@@ -10,13 +10,13 @@ class RDoc::Parser::RD < RDoc::Parser
parse_files_matching(/\.rd(?:\.[^.]+)?$/)
##
- # Creates an rd-format TopLevel for the given file.
+ # Creates an rd-format File for the given file.
def scan
- comment = RDoc::Comment.new @content, @top_level
+ comment = RDoc::Comment.new @content, @file
comment.format = 'rd'
- @top_level.comment = comment
+ @file.comment = comment
end
end
diff --git a/lib/rdoc/parser/ruby.rb b/lib/rdoc/parser/ruby.rb
index c9b662c90a..de2aeb8ae7 100644
--- a/lib/rdoc/parser/ruby.rb
+++ b/lib/rdoc/parser/ruby.rb
@@ -21,7 +21,7 @@
require_relative 'ripper_state_lex'
##
-# Extracts code elements from a source file returning a TopLevel object
+# Extracts code elements from a source file returning a File object
# containing the constituent file elements.
#
# This file is based on rtags
@@ -170,7 +170,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
##
# Creates a new Ruby parser.
- def initialize(top_level, content, options, stats)
+ def initialize(file, content, options, stats)
super
content = handle_tab_width(content)
@@ -313,7 +313,7 @@ def create_module_alias(container, constant, rhs_name) # :nodoc:
container.find_module_named rhs_name
end
- container.add_module_alias mod, rhs_name, constant, @top_level
+ container.add_module_alias mod, rhs_name, constant, @file
end
##
@@ -354,7 +354,7 @@ def get_class_or_module(container, ignore_constants = false)
# class ::A -> A is in the top level
if :on_op == name_t[:kind] and '::' == name_t[:text] then # bug
name_t = get_tk
- container = @top_level
+ container = @file
given_name << '::'
end
@@ -375,7 +375,7 @@ def get_class_or_module(container, ignore_constants = false)
else
c = prev_container.add_module RDoc::NormalModule, name_t[:text]
c.ignore unless prev_container.document_children
- @top_level.add_to_classes_or_modules c
+ @file.add_to_classes_or_modules c
c
end
@@ -700,7 +700,7 @@ def make_message(message)
# Creates a comment with the correct format
def new_comment(comment, line_no = nil)
- c = RDoc::Comment.new comment, @top_level, :ruby
+ c = RDoc::Comment.new comment, @file, :ruby
c.line = line_no
c.format = @markup
c
@@ -890,7 +890,7 @@ def parse_class_regular(container, declaration_context, single, # :nodoc:
superclass = '::Object'
if given_name =~ /^::/ then
- declaration_context = @top_level
+ declaration_context = @file
given_name = $'
end
@@ -909,9 +909,9 @@ def parse_class_regular(container, declaration_context, single, # :nodoc:
read_documentation_modifiers cls, RDoc::CLASS_MODIFIERS
record_location cls
- cls.add_comment comment, @top_level
+ cls.add_comment comment, @file
- @top_level.add_to_classes_or_modules cls
+ @file.add_to_classes_or_modules cls
@stats.add_class cls
suppress_parents container, declaration_context unless cls.document_self
@@ -931,7 +931,7 @@ def parse_class_singleton(container, name, comment) # :nodoc:
unless other then
if name =~ /^::/ then
name = $'
- container = @top_level
+ container = @file
end
other = container.add_module RDoc::NormalModule, name
@@ -940,7 +940,7 @@ def parse_class_singleton(container, name, comment) # :nodoc:
# class << $gvar
other.ignore if name.empty?
- other.add_comment comment, @top_level
+ other.add_comment comment, @file
end
# notify :nodoc: all if not a constant-named class/module
@@ -951,7 +951,7 @@ def parse_class_singleton(container, name, comment) # :nodoc:
other.clear_comment
end
- @top_level.add_to_classes_or_modules other
+ @file.add_to_classes_or_modules other
@stats.add_class other
read_documentation_modifiers other, RDoc::CLASS_MODIFIERS
@@ -1007,7 +1007,7 @@ def parse_constant(container, tk, comment, ignore_constants = false)
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
+ @file.add_to_classes_or_modules new_module
end
end
@@ -1140,7 +1140,7 @@ def parse_comment_ghost(container, text, name, column, line_no, # :nodoc:
meth.start_collecting_tokens(:ruby)
indent = RDoc::Parser::RipperStateLex::Token.new(1, 1, :on_sp, ' ' * column)
position_comment = RDoc::Parser::RipperStateLex::Token.new(line_no, 1, :on_comment)
- position_comment[:text] = "# File #{@top_level.relative_name}, line #{line_no}"
+ position_comment[:text] = "# File #{@file.relative_name}, line #{line_no}"
newline = RDoc::Parser::RipperStateLex::Token.new(0, 0, :on_nl, "\n")
meth.add_tokens [position_comment, newline, indent]
@@ -1183,7 +1183,7 @@ def parse_comment_tomdoc(container, tk, comment)
meth.start_collecting_tokens(:ruby)
indent = RDoc::Parser::RipperStateLex::Token.new(1, 1, :on_sp, ' ' * column)
position_comment = RDoc::Parser::RipperStateLex::Token.new(line_no, 1, :on_comment)
- position_comment[:text] = "# File #{@top_level.relative_name}, line #{line_no}"
+ position_comment[:text] = "# File #{@file.relative_name}, line #{line_no}"
newline = RDoc::Parser::RipperStateLex::Token.new(0, 0, :on_nl, "\n")
meth.add_tokens [position_comment, newline, indent]
@@ -1366,7 +1366,7 @@ def parse_meta_method(container, single, tk, comment)
meth.start_collecting_tokens(:ruby)
indent = RDoc::Parser::RipperStateLex::Token.new(1, 1, :on_sp, ' ' * column)
position_comment = RDoc::Parser::RipperStateLex::Token.new(line_no, 1, :on_comment)
- position_comment[:text] = "# File #{@top_level.relative_name}, line #{line_no}"
+ position_comment[:text] = "# File #{@file.relative_name}, line #{line_no}"
newline = RDoc::Parser::RipperStateLex::Token.new(0, 0, :on_nl, "\n")
meth.add_tokens [position_comment, newline, indent]
meth.add_tokens @token_stream
@@ -1474,7 +1474,7 @@ def parse_method(container, single, tk, comment)
meth.start_collecting_tokens(:ruby)
indent = RDoc::Parser::RipperStateLex::Token.new(1, 1, :on_sp, ' ' * column)
token = RDoc::Parser::RipperStateLex::Token.new(line_no, 1, :on_comment)
- token[:text] = "# File #{@top_level.relative_name}, line #{line_no}"
+ token[:text] = "# File #{@file.relative_name}, line #{line_no}"
newline = RDoc::Parser::RipperStateLex::Token.new(0, 0, :on_nl, "\n")
meth.add_tokens [token, newline, indent]
meth.add_tokens @token_stream
@@ -1610,7 +1610,7 @@ def parse_method_name_singleton(container, name_t) # :nodoc:
elsif (:on_kw == name_t[:kind]) && ('true' == name_t[:text] || 'false' == name_t[:text] || 'nil' == name_t[:text]) then
klass_name = "#{name_t[:text].capitalize}Class"
container = @store.find_class_named klass_name
- container ||= @top_level.add_class RDoc::NormalClass, klass_name
+ container ||= @file.add_class RDoc::NormalClass, klass_name
name = name_t2[:text]
else
@@ -1719,7 +1719,7 @@ def parse_module(container, single, tk, comment)
record_location mod
read_documentation_modifiers mod, RDoc::CLASS_MODIFIERS
- mod.add_comment comment, @top_level
+ mod.add_comment comment, @file
parse_statements mod
# after end modifiers
@@ -1743,7 +1743,7 @@ def parse_require(context, comment)
name = tk[:text][1..-2] if :on_tstring == tk[:kind]
if name then
- @top_level.add_require RDoc::Require.new(name, comment)
+ @file.add_require RDoc::Require.new(name, comment)
else
unget_tk tk
end
@@ -1852,7 +1852,7 @@ def parse_statements(container, single = NORMAL, current_method = nil,
look_for_directives_in container, comment
if container.done_documenting then
- throw :eof if RDoc::TopLevel === container
+ throw :eof if RDoc::File === container
container.ongoing_visibility = save_visibility
end
end
@@ -2197,10 +2197,10 @@ def read_documentation_modifiers(context, allowed)
def record_location(container) # :nodoc:
case container
when RDoc::ClassModule then
- @top_level.add_to_classes_or_modules container
+ @file.add_to_classes_or_modules container
end
- container.record_location @top_level
+ container.record_location @file
end
##
@@ -2211,7 +2211,7 @@ def scan
catch :eof do
begin
- parse_top_level_statements @top_level
+ parse_top_level_statements @file
rescue StandardError => e
if @content.include?('<%') and @content.include?('%>') then
@@ -2247,7 +2247,7 @@ def scan
end
end
- @top_level
+ @file
end
##
diff --git a/lib/rdoc/parser/simple.rb b/lib/rdoc/parser/simple.rb
index a0edca1b33..9579b79d45 100644
--- a/lib/rdoc/parser/simple.rb
+++ b/lib/rdoc/parser/simple.rb
@@ -14,25 +14,25 @@ class RDoc::Parser::Simple < RDoc::Parser
##
# Prepare to parse a plain file
- def initialize(top_level, content, options, stats)
+ def initialize(file, content, options, stats)
super
preprocess = RDoc::Markup::PreProcess.new @file_name, @options.rdoc_include
content = RDoc::Text.expand_tabs(@content)
- @content, = preprocess.run_pre_processes(content, @top_level, 1, :simple)
+ @content, = preprocess.run_pre_processes(content, @file, 1, :simple)
end
##
- # Extract the file contents and attach them to the TopLevel as a comment
+ # Extract the file contents and attach them to the File as a comment
def scan
content = remove_coding_comment @content
- comment = RDoc::Comment.new content, @top_level
+ comment = RDoc::Comment.new content, @file
- @top_level.comment = comment
- @top_level
+ @file.comment = comment
+ @file
end
##
diff --git a/lib/rdoc/rdoc.rb b/lib/rdoc/rdoc.rb
index 8beeac52f5..af958f2e58 100644
--- a/lib/rdoc/rdoc.rb
+++ b/lib/rdoc/rdoc.rb
@@ -174,11 +174,11 @@ def setup_output_dir(dir, force)
if @options.dry_run then
# do nothing
- elsif File.exist? dir then
- error "#{dir} exists and is not a directory" unless File.directory? dir
+ elsif ::File.exist? dir then
+ error "#{dir} exists and is not a directory" unless ::File.directory? dir
begin
- File.open flag_file do |io|
+ ::File.open flag_file do |io|
unless force then
Time.parse io.gets
@@ -217,7 +217,7 @@ def update_output_dir(op_dir, time, last = {})
time = Time.at(ENV['SOURCE_DATE_EPOCH'].to_i).gmtime
end
- File.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}"
@@ -229,7 +229,7 @@ def update_output_dir(op_dir, time, last = {})
# Return the path name of the flag file in an output directory.
def output_flag_file(op_dir)
- File.join op_dir, "created.rid"
+ ::File.join op_dir, "created.rid"
end
##
@@ -239,12 +239,12 @@ def output_flag_file(op_dir)
def parse_dot_doc_file(in_dir, filename)
# read and strip comments
- patterns = File.read(filename).gsub(/#.*/, '')
+ patterns = ::File.read(filename).gsub(/#.*/, '')
result = {}
patterns.split(' ').each do |patt|
- candidates = Dir.glob(File.join(in_dir, patt))
+ candidates = Dir.glob(::File.join(in_dir, patt))
result.update normalized_file_list(candidates, false, @options.exclude)
end
@@ -271,7 +271,7 @@ def normalized_file_list(relative_files, force_doc = false,
rel_file_name = rel_file_name.sub(/^\.\//, '')
next if rel_file_name.end_with? 'created.rid'
next if exclude_pattern && exclude_pattern =~ rel_file_name
- stat = File.stat rel_file_name rescue next
+ stat = ::File.stat rel_file_name rescue next
case type = stat.ftype
when "file" then
@@ -284,15 +284,15 @@ def normalized_file_list(relative_files, force_doc = false,
when "directory" then
next if UNCONDITIONALLY_SKIPPED_DIRECTORIES.include?(rel_file_name)
- basename = File.basename(rel_file_name)
+ basename = ::File.basename(rel_file_name)
next if options.skip_tests && TEST_SUITE_DIRECTORY_NAMES.include?(basename)
- created_rid = File.join rel_file_name, "created.rid"
- next if File.file? created_rid
+ created_rid = ::File.join rel_file_name, "created.rid"
+ next if ::File.file? created_rid
- dot_doc = File.join rel_file_name, RDoc::DOT_DOC_FILENAME
+ dot_doc = ::File.join rel_file_name, RDoc::DOT_DOC_FILENAME
- if File.file? dot_doc then
+ if ::File.file? dot_doc then
file_list.update(parse_dot_doc_file(rel_file_name, dot_doc))
else
file_list.update(list_files_in_directory(rel_file_name))
@@ -312,13 +312,13 @@ def normalized_file_list(relative_files, force_doc = false,
# for .document files.
def list_files_in_directory(dir)
- files = Dir.glob File.join(dir, "*")
+ files = Dir.glob ::File.join(dir, "*")
normalized_file_list files, false, @options.exclude
end
##
- # Parses +filename+ and returns an RDoc::TopLevel
+ # Parses +filename+ and returns an RDoc::File
def parse_file(filename)
encoding = @options.encoding
@@ -345,20 +345,20 @@ def parse_file(filename)
relative_path.relative_path_from @options.page_dir
end
- top_level = @store.add_file filename, relative_name: relative_path.to_s
+ file = @store.add_file filename, relative_name: relative_path.to_s
- parser = RDoc::Parser.for top_level, content, @options, @stats
+ parser = RDoc::Parser.for file, content, @options, @stats
return unless parser
parser.scan
# restart documentation for the classes & modules found
- top_level.classes_or_modules.each do |cm|
+ file.classes_or_modules.each do |cm|
cm.done_documenting = false
end
- top_level
+ file
rescue Errno::EACCES => e
$stderr.puts <<-EOF
@@ -422,7 +422,7 @@ def remove_unparseable(files)
files.reject do |file, *|
file =~ /\.(?:class|eps|erb|scpt\.txt|svg|ttf|yml)$/i or
(file =~ /tags$/i and
- /\A(\f\n[^,]+,\d+$|!_TAG_)/.match?(File.binread(file, 100)))
+ /\A(\f\n[^,]+,\d+$|!_TAG_)/.match?(::File.binread(file, 100)))
end
end
diff --git a/lib/rdoc/ri/driver.rb b/lib/rdoc/ri/driver.rb
index 13ad9366ec..637a774f73 100644
--- a/lib/rdoc/ri/driver.rb
+++ b/lib/rdoc/ri/driver.rb
@@ -99,7 +99,7 @@ def self.default_options
def self.dump(data_path)
require 'pp'
- File.open data_path, 'rb' do |io|
+ ::File.open data_path, 'rb' do |io|
pp Marshal.load(io.read)
end
end
@@ -111,7 +111,7 @@ def self.process_args(argv)
options = default_options
opts = OptionParser.new do |opt|
- opt.program_name = File.basename $0
+ opt.program_name = ::File.basename $0
opt.version = RDoc::VERSION
opt.release = nil
opt.summary_indent = ' ' * 4
@@ -148,7 +148,7 @@ def self.process_args(argv)
#{opt.program_name} Fil
#{opt.program_name} File
- #{opt.program_name} File.new
+ #{opt.program_name} ::File.new
#{opt.program_name} zip
#{opt.program_name} rdoc:README
#{opt.program_name} ruby:comments
@@ -283,11 +283,11 @@ def self.process_args(argv)
"documentation in addition to the standard",
"directories. May be repeated.") do |value|
value.each do |dir|
- unless File.directory? dir then
+ unless ::File.directory? dir then
raise OptionParser::InvalidArgument, "#{dir} is not a directory"
end
- options[:extra_doc_dirs] << File.expand_path(dir)
+ options[:extra_doc_dirs] << ::File.expand_path(dir)
end
end
@@ -350,15 +350,15 @@ def self.process_args(argv)
opt.on("--dump=CACHE",
"Dump data from an ri cache or data file.") do |value|
- unless File.readable?(value)
+ unless ::File.readable?(value)
abort "#{value.inspect} is not readable"
end
- if File.directory?(value)
+ if ::File.directory?(value)
abort "#{value.inspect} is a directory"
end
- options[:dump_path] = File.new(value)
+ options[:dump_path] = ::File.new(value)
end
end
diff --git a/lib/rdoc/ri/paths.rb b/lib/rdoc/ri/paths.rb
index 8d33c5b7e5..872608025f 100644
--- a/lib/rdoc/ri/paths.rb
+++ b/lib/rdoc/ri/paths.rb
@@ -12,7 +12,7 @@ module RDoc::RI::Paths
version = RbConfig::CONFIG['ruby_version']
- BASE = File.join RbConfig::CONFIG['ridir'], version
+ BASE = ::File.join RbConfig::CONFIG['ridir'], version
HOMEDIR = RDoc.home
#:startdoc:
@@ -57,7 +57,7 @@ def self.gem_dir(name, version)
spec = Gem::Specification.find_by_name name, req
- File.join spec.doc_dir, 'ri'
+ ::File.join spec.doc_dir, 'ri'
end
##
@@ -71,7 +71,7 @@ def self.gemdirs(filter = :latest)
ri_paths = {}
all = Gem::Specification.map do |spec|
- [File.join(spec.doc_dir, 'ri'), spec.name, spec.version]
+ [::File.join(spec.doc_dir, 'ri'), spec.name, spec.version]
end
if filter == :all then
@@ -93,7 +93,7 @@ def self.gemdirs(filter = :latest)
end
all.each do |dir, name, ver|
- next unless File.exist? dir
+ next unless ::File.exist? dir
if ri_paths[name].nil? or ver > ri_paths[name].first then
ri_paths[name] = [ver, name, dir]
@@ -125,7 +125,7 @@ def self.home_dir
def self.path(system = true, site = true, home = true, gems = :latest, *extra_dirs)
path = raw_path system, site, home, gems, *extra_dirs
- path.select { |directory| File.directory? directory }
+ path.select { |directory| ::File.directory? directory }
end
##
@@ -152,7 +152,7 @@ def self.raw_path(system, site, home, gems, *extra_dirs)
# modern Ruby installations.
def self.site_dir
- File.join BASE, 'site'
+ ::File.join BASE, 'site'
end
##
@@ -165,7 +165,7 @@ def self.site_dir
# rdoc-data gem to install system ri data for common versions of Ruby.
def self.system_dir
- File.join BASE, 'system'
+ ::File.join BASE, 'system'
end
end
diff --git a/lib/rdoc/rubygems_hook.rb b/lib/rdoc/rubygems_hook.rb
index 448afc9a2f..5e2f9436c9 100644
--- a/lib/rdoc/rubygems_hook.rb
+++ b/lib/rdoc/rubygems_hook.rb
@@ -200,10 +200,10 @@ def generate
end
document 'ri', options, @ri_dir if
- @generate_ri and (@force or not File.exist? @ri_dir)
+ @generate_ri and (@force or not ::File.exist? @ri_dir)
document 'aliki', options, @rdoc_dir if
- @generate_rdoc and (@force or not File.exist? @rdoc_dir)
+ @generate_rdoc and (@force or not ::File.exist? @rdoc_dir)
end
##
@@ -218,7 +218,7 @@ def new_rdoc # :nodoc:
# Is rdoc documentation installed?
def rdoc_installed?
- File.exist? @rdoc_dir
+ ::File.exist? @rdoc_dir
end
##
@@ -227,7 +227,7 @@ def rdoc_installed?
def remove
base_dir = @spec.base_dir
- raise Gem::FilePermissionError, base_dir unless File.writable? base_dir
+ raise Gem::FilePermissionError, base_dir unless ::File.writable? base_dir
FileUtils.rm_rf @rdoc_dir
FileUtils.rm_rf @ri_dir
@@ -237,7 +237,7 @@ def remove
# Is ri data installed?
def ri_installed?
- File.exist? @ri_dir
+ ::File.exist? @ri_dir
end
##
@@ -247,9 +247,9 @@ def setup
self.class.load_rdoc
raise Gem::FilePermissionError, @doc_dir if
- File.exist?(@doc_dir) and not File.writable?(@doc_dir)
+ ::File.exist?(@doc_dir) and not ::File.writable?(@doc_dir)
- FileUtils.mkdir_p @doc_dir unless File.exist? @doc_dir
+ FileUtils.mkdir_p @doc_dir unless ::File.exist? @doc_dir
end
end
@@ -271,7 +271,7 @@ class RubygemsHook
attr_accessor :generate_rdoc, :generate_ri, :force
def self.default_gem?
- !File.exist?(File.join(__dir__, "..", "rubygems_plugin.rb"))
+ !::File.exist?(::File.join(__dir__, "..", "rubygems_plugin.rb"))
end
def initialize(spec, generate_rdoc = false, generate_ri = true)
diff --git a/lib/rdoc/servlet.rb b/lib/rdoc/servlet.rb
index fbb5bb0258..968e6e5e60 100644
--- a/lib/rdoc/servlet.rb
+++ b/lib/rdoc/servlet.rb
@@ -81,8 +81,8 @@ def initialize(server, stores, cache, mount_path = nil, extra_doc_dirs = [])
# HACK dup
$LOAD_PATH.each do |path|
- darkfish_dir = File.join path, 'rdoc/generator/template/darkfish/'
- next unless File.directory? darkfish_dir
+ darkfish_dir = ::File.join path, 'rdoc/generator/template/darkfish/'
+ next unless ::File.directory? darkfish_dir
@options.template_dir = darkfish_dir
break
end
@@ -90,7 +90,7 @@ def initialize(server, stores, cache, mount_path = nil, extra_doc_dirs = [])
@asset_dirs = {
:darkfish => darkfish_dir,
:json_index =>
- File.expand_path('../generator/template/json_index/', __FILE__),
+ ::File.expand_path('../generator/template/json_index/', __FILE__),
}
end
@@ -100,11 +100,11 @@ def initialize(server, stores, cache, mount_path = nil, extra_doc_dirs = [])
def asset(generator_name, req, res)
asset_dir = @asset_dirs[generator_name]
- asset_path = File.join asset_dir, req.path
+ asset_path = ::File.join asset_dir, req.path
if_modified_since req, res, asset_path
- res.body = File.read asset_path
+ res.body = ::File.read asset_path
res.content_type = case req.path
when /\.css\z/ then 'text/css'
@@ -266,7 +266,7 @@ def generator_for(store)
# file has been modified a Last-Modified header is added to +res+.
def if_modified_since(req, res, path = nil)
- last_modified = File.stat(path).mtime if path
+ last_modified = ::File.stat(path).mtime if path
res['last-modified'] = last_modified.httpdate
@@ -292,7 +292,7 @@ def installed_docs
extra_counter = 0
ri_paths.map do |path, type|
store = RDoc::Store.new(@options, path: path, type: type)
- exists = File.exist? store.cache_path
+ exists = ::File.exist? store.cache_path
case type
when :gem then
@@ -441,7 +441,7 @@ def store_for(source_name)
store = RDoc::Store.new(@options, path: ri_dir, type: type)
- return store if File.exist? store.cache_path
+ return store if ::File.exist? store.cache_path
raise WEBrick::HTTPStatus::NotFound,
"Could not find documentation for \"#{ERB::Util.html_escape(source_name)}\". Please run `gem rdoc --ri gem_name`"
diff --git a/lib/rdoc/store.rb b/lib/rdoc/store.rb
index 57429e6aad..c93df12f3d 100644
--- a/lib/rdoc/store.rb
+++ b/lib/rdoc/store.rb
@@ -170,7 +170,7 @@ def add_c_enclosure(variable, namespace)
# Adds C variables from an RDoc::Parser::C
def add_c_variables(c_parser)
- filename = c_parser.top_level.relative_name
+ filename = c_parser.file.relative_name
@c_class_variables[filename] = make_variable_map c_parser.classes
@@ -178,19 +178,19 @@ def add_c_variables(c_parser)
end
##
- # Adds the file with +name+ as an RDoc::TopLevel to the store. Returns the
- # created RDoc::TopLevel.
+ # Adds the file with +name+ as an RDoc::File to the store. Returns the
+ # created RDoc::File.
def add_file(absolute_name, relative_name: absolute_name, parser: nil)
- unless top_level = @files_hash[relative_name] then
- top_level = RDoc::TopLevel.new absolute_name, relative_name
- top_level.parser = parser if parser
- top_level.store = self
- @files_hash[relative_name] = top_level
- @text_files_hash[relative_name] = top_level if top_level.text?
+ unless file = @files_hash[relative_name] then
+ file = RDoc::File.new absolute_name, relative_name
+ file.parser = parser if parser
+ file.store = self
+ @files_hash[relative_name] = file
+ @text_files_hash[relative_name] = file if file.text?
end
- top_level
+ file
end
##
@@ -209,8 +209,8 @@ def resolve_c_superclasses
# Sets the parser of +absolute_name+, unless it from a source code file.
def update_parser_of_file(absolute_name, parser)
- if top_level = @files_hash[absolute_name] then
- @text_files_hash[absolute_name] = top_level if top_level.text?
+ if file = @files_hash[absolute_name] then
+ @text_files_hash[absolute_name] = file if file.text?
end
end
@@ -262,7 +262,7 @@ def attributes
# Path to the cache file
def cache_path
- File.join @path, 'cache.ri'
+ ::File.join @path, 'cache.ri'
end
##
@@ -270,7 +270,7 @@ def cache_path
def class_file(klass_name)
name = klass_name.split('::').last
- File.join class_path(klass_name), "cdesc-#{name}.ri"
+ ::File.join class_path(klass_name), "cdesc-#{name}.ri"
end
##
@@ -285,7 +285,7 @@ def class_methods
# Path where data for +klass_name+ will be stored (methods or class data)
def class_path(klass_name)
- File.join @path, *klass_name.split('::')
+ ::File.join @path, *klass_name.split('::')
end
##
@@ -409,7 +409,7 @@ def find_class_named(name)
def find_class_named_from(name, from)
from = find_class_named from unless RDoc::Context === from
- until RDoc::TopLevel === from do
+ until RDoc::File === from do
return nil unless from
klass = from.find_class_named name
@@ -444,7 +444,7 @@ def find_module_named(name)
end
##
- # Returns the RDoc::TopLevel that is a text file and has the given
+ # Returns the RDoc::File that is a text file and has the given
# +file_name+
def find_text_page(file_name)
@@ -491,8 +491,8 @@ def fix_basic_object_inheritance
def friendly_path
case type
when :gem then
- parent = File.expand_path '..', @path
- "gem #{File.basename parent}"
+ parent = ::File.expand_path '..', @path
+ "gem #{::File.basename parent}"
when :home then RDoc.home
when :site then 'ruby site'
when :system then 'ruby core'
@@ -701,7 +701,7 @@ def method_file(klass_name, method_name)
method_name = $1 if $1
method_name = method_name.gsub(/\W/) { "%%%02x" % $&[0].ord }
- File.join class_path(klass_name), "#{method_name}-#{method_type}.ri"
+ ::File.join class_path(klass_name), "#{method_name}-#{method_type}.ri"
end
##
@@ -720,7 +720,7 @@ def modules_hash
end
##
- # Returns the RDoc::TopLevel that is a file and has the given +name+
+ # Returns the RDoc::File that is a file and has the given +name+
def page(name)
@files_hash.each_value.find do |file|
@@ -732,9 +732,9 @@ def page(name)
# Path to the ri data for +page_name+
def page_file(page_name)
- file_name = File.basename(page_name).gsub('.', '_')
+ file_name = ::File.basename(page_name).gsub('.', '_')
- File.join @path, File.dirname(page_name), "page-#{file_name}.ri"
+ ::File.join @path, ::File.dirname(page_name), "page-#{file_name}.ri"
end
##
@@ -796,7 +796,7 @@ def save_cache
return if @dry_run
- File.open cache_path, 'wb' do |io|
+ ::File.open cache_path, 'wb' do |io|
Marshal.dump @cache, io
end
end
@@ -870,7 +870,7 @@ def save_class(klass)
FileUtils.rm_f to_delete
- File.open path, 'wb' do |io|
+ ::File.open path, 'wb' do |io|
Marshal.dump klass, io
end
end
@@ -893,7 +893,7 @@ def save_method(klass, method)
return if @dry_run
- File.open method_file(full_name, method.full_name), 'wb' do |io|
+ ::File.open method_file(full_name, method.full_name), 'wb' do |io|
Marshal.dump method, io
end
end
@@ -906,14 +906,14 @@ def save_page(page)
path = page_file page.full_name
- FileUtils.mkdir_p File.dirname(path) unless @dry_run
+ FileUtils.mkdir_p ::File.dirname(path) unless @dry_run
cache[:pages] ||= []
cache[:pages] << page.full_name
return if @dry_run
- File.open path, 'wb' do |io|
+ ::File.open path, 'wb' do |io|
Marshal.dump page, io
end
end
@@ -929,7 +929,7 @@ def save_page(page)
def source
case type
- when :gem then File.basename File.expand_path '..', @path
+ when :gem then ::File.basename ::File.expand_path '..', @path
when :home then 'home'
when :site then 'site'
when :system then 'ruby'
@@ -979,7 +979,7 @@ def unique_modules
private
def marshal_load(file)
- File.open(file, 'rb') {|io| Marshal.load(io, MarshalFilter)}
+ ::File.open(file, 'rb') {|io| Marshal.load(io, MarshalFilter)}
end
MarshalFilter = proc do |obj|
diff --git a/test/rdoc/code_object/any_method_test.rb b/test/rdoc/code_object/any_method_test.rb
index 43dc679d95..7be97aab47 100644
--- a/test/rdoc/code_object/any_method_test.rb
+++ b/test/rdoc/code_object/any_method_test.rb
@@ -103,8 +103,8 @@ def test_is_alias_for
def test_call_seq_handles_aliases
# see 0ead786
@store.path = Dir.tmpdir
- top_level = @store.add_file 'file.rb'
- cm = top_level.add_class RDoc::ClassModule, 'Klass'
+ file = @store.add_file 'file.rb'
+ cm = file.add_class RDoc::ClassModule, 'Klass'
method_with_call_seq = RDoc::AnyMethod.new(nil, "method_with_call_seq")
method_with_call_seq.call_seq = <<~SEQ
@@ -128,8 +128,8 @@ def test_call_seq_handles_aliases
def test_call_seq_returns_nil_if_alias_is_missing_from_call_seq
@store.path = Dir.tmpdir
- top_level = @store.add_file 'file.rb'
- cm = top_level.add_class RDoc::ClassModule, 'Klass'
+ file = @store.add_file 'file.rb'
+ cm = file.add_class RDoc::ClassModule, 'Klass'
method_with_call_seq = RDoc::AnyMethod.new(nil, "method_with_call_seq")
method_with_call_seq.call_seq = <<~SEQ
@@ -203,16 +203,16 @@ def test_markup_code_with_variable_expansion
def test_marshal_dump
@store.path = Dir.tmpdir
- top_level = @store.add_file 'file.rb'
+ file = @store.add_file 'file.rb'
m = RDoc::AnyMethod.new nil, 'method'
m.block_params = 'some_block'
m.call_seq = 'call_seq'
m.comment = 'this is a comment'
m.params = 'param'
- m.record_location top_level
+ m.record_location file
- cm = top_level.add_class RDoc::ClassModule, 'Klass'
+ cm = file.add_class RDoc::ClassModule, 'Klass'
cm.add_method m
section = cm.sections.first
@@ -232,7 +232,7 @@ def test_marshal_dump
assert_equal 'some_block', loaded.block_params
assert_equal 'call_seq', loaded.call_seq
assert_equal document, loaded.comment.parse
- assert_equal top_level, loaded.file
+ assert_equal file, loaded.file
assert_equal 'Klass#method', loaded.full_name
assert_equal 'method', loaded.name
assert_equal 'param', loaded.params
@@ -287,11 +287,11 @@ def test_marshal_load_instance_method
def test_marshal_load_version_0
@store.path = Dir.tmpdir
- top_level = @store.add_file 'file.rb'
+ file = @store.add_file 'file.rb'
m = RDoc::AnyMethod.new nil, 'method'
- cm = top_level.add_class RDoc::ClassModule, 'Klass'
+ cm = file.add_class RDoc::ClassModule, 'Klass'
cm.add_method m
section = cm.sections.first
@@ -335,16 +335,16 @@ def test_marshal_load_version_0
def test_marshal_dump_version_2
@store.path = Dir.tmpdir
- top_level = @store.add_file 'file.rb'
+ file = @store.add_file 'file.rb'
m = RDoc::AnyMethod.new nil, 'method'
m.block_params = 'some_block'
m.call_seq = 'call_seq'
m.comment = 'this is a comment'
m.params = 'param'
- m.record_location top_level
+ m.record_location file
- cm = top_level.add_class RDoc::ClassModule, 'Klass'
+ cm = file.add_class RDoc::ClassModule, 'Klass'
cm.add_method m
section = cm.sections.first
@@ -376,7 +376,7 @@ def test_marshal_dump_version_2
assert_equal 'some_block', loaded.block_params
assert_equal 'call_seq', loaded.call_seq
assert_equal document, loaded.comment.parse
- assert_equal top_level, loaded.file
+ assert_equal file, loaded.file
assert_equal 'Klass#method', loaded.full_name
assert_equal 'method', loaded.name
assert_equal 'param', loaded.params
diff --git a/test/rdoc/code_object/class_module_test.rb b/test/rdoc/code_object/class_module_test.rb
index 0a552d1fb4..5ef9a019b3 100644
--- a/test/rdoc/code_object/class_module_test.rb
+++ b/test/rdoc/code_object/class_module_test.rb
@@ -9,19 +9,19 @@ def test_add_comment
tl3 = @store.add_file 'three.rb'
cm = RDoc::ClassModule.new 'Klass'
- comment_tl1 = RDoc::Comment.new('# comment 1', @top_level, :ruby)
+ comment_tl1 = RDoc::Comment.new('# comment 1', @file, :ruby)
cm.add_comment comment_tl1, tl1
assert_equal [[comment_tl1, tl1]], cm.comment_location
assert_equal 'comment 1', cm.comment.text
- comment_tl2 = RDoc::Comment.new('# comment 2', @top_level, :ruby)
+ comment_tl2 = RDoc::Comment.new('# comment 2', @file, :ruby)
cm.add_comment comment_tl2, tl2
assert_equal [[comment_tl1, tl1], [comment_tl2, tl2]], cm.comment_location
assert_equal "comment 1\n---\ncomment 2", cm.comment
- comment_tl3 = RDoc::Comment.new('# * comment 3', @top_level, :ruby)
+ comment_tl3 = RDoc::Comment.new('# * comment 3', @file, :ruby)
cm.add_comment comment_tl3, tl3
assert_equal [[comment_tl1, tl1],
@@ -33,7 +33,7 @@ def test_add_comment
def test_add_comment_comment
cm = RDoc::ClassModule.new 'Klass'
- cm.add_comment comment('comment'), @top_level
+ cm.add_comment comment('comment'), @file
assert_equal 'comment', cm.comment.text
end
@@ -42,8 +42,8 @@ def test_add_comment_duplicate
tl1 = @store.add_file 'one.rb'
cm = RDoc::ClassModule.new 'Klass'
- comment1 = RDoc::Comment.new('# comment 1', @top_level, :ruby)
- comment2 = RDoc::Comment.new('# comment 2', @top_level, :ruby)
+ comment1 = RDoc::Comment.new('# comment 1', @file, :ruby)
+ comment2 = RDoc::Comment.new('# comment 2', @file, :ruby)
cm.add_comment comment1, tl1
cm.add_comment comment2, tl1
@@ -68,15 +68,15 @@ def test_ancestors
def test_comment_equals
cm = RDoc::ClassModule.new 'Klass'
- cm.comment = RDoc::Comment.new('# comment 1', @top_level, :ruby)
+ cm.comment = RDoc::Comment.new('# comment 1', @file, :ruby)
assert_equal 'comment 1', cm.comment.to_s
- cm.comment = RDoc::Comment.new('# comment 2', @top_level, :ruby)
+ cm.comment = RDoc::Comment.new('# comment 2', @file, :ruby)
assert_equal "comment 1\n---\ncomment 2", cm.comment.to_s
- cm.comment = RDoc::Comment.new('# * comment 3', @top_level, :ruby)
+ cm.comment = RDoc::Comment.new('# * comment 3', @file, :ruby)
assert_equal "comment 1\n---\ncomment 2\n---\n* comment 3", cm.comment.to_s
end
@@ -111,11 +111,11 @@ def test_documented_eh
refute cm.documented?, 'no comments, no markers'
- cm.add_comment '', @top_level
+ cm.add_comment '', @file
refute cm.documented?, 'empty comment'
- cm.add_comment 'hi', @top_level
+ cm.add_comment 'hi', @file
assert cm.documented?, 'commented'
@@ -135,7 +135,7 @@ def test_each_ancestor
def test_each_ancestor_cycle
m_incl = RDoc::Include.new 'M', nil
- m = @top_level.add_module RDoc::NormalModule, 'M'
+ m = @file.add_module RDoc::NormalModule, 'M'
m.add_include m_incl
assert_empty m.each_ancestor.to_a
@@ -1185,7 +1185,7 @@ def test_parse_comment_location
end
def test_remove_nodoc_children
- parent = @top_level.add_class RDoc::ClassModule, 'A'
+ parent = @file.add_class RDoc::ClassModule, 'A'
parent.modules_hash.replace 'B' => true, 'C' => true
@store.modules_hash.replace 'A::B' => true
@@ -1384,17 +1384,17 @@ def test_update_aliases_reparent
def test_update_aliases_reparent_root
store = RDoc::Store.new(RDoc::Options.new)
- top_level = store.add_file 'file.rb'
+ file = store.add_file 'file.rb'
- klass = top_level.add_class RDoc::NormalClass, 'Klass'
- object = top_level.add_class RDoc::NormalClass, 'Object'
+ klass = file.add_class RDoc::NormalClass, 'Klass'
+ object = file.add_class RDoc::NormalClass, 'Object'
const = RDoc::Constant.new 'A', nil, ''
- const.record_location top_level
+ const.record_location file
const.is_alias_for = klass
a = RDoc::Constant.new 'A', '', ''
- top_level.add_module_alias klass, klass.name, a, top_level
+ file.add_module_alias klass, klass.name, a, file
object.add_constant const
diff --git a/test/rdoc/code_object/constant_test.rb b/test/rdoc/code_object/constant_test.rb
index 52e40da138..41ffddc98c 100644
--- a/test/rdoc/code_object/constant_test.rb
+++ b/test/rdoc/code_object/constant_test.rb
@@ -10,10 +10,10 @@ def setup
end
def test_documented_eh
- top_level = @store.add_file 'file.rb'
+ file = @store.add_file 'file.rb'
const = RDoc::Constant.new 'CONST', nil, nil
- top_level.add_constant const
+ file.add_constant const
refute const.documented?
@@ -23,10 +23,10 @@ def test_documented_eh
end
def test_documented_eh_alias
- top_level = @store.add_file 'file.rb'
+ file = @store.add_file 'file.rb'
const = RDoc::Constant.new 'CONST', nil, nil
- top_level.add_constant const
+ file.add_constant const
refute const.documented?
@@ -34,7 +34,7 @@ def test_documented_eh_alias
refute const.documented?
- @c1.add_comment comment('comment'), @top_level
+ @c1.add_comment comment('comment'), @file
assert const.documented?
end
@@ -44,10 +44,10 @@ def test_full_name
end
def test_is_alias_for
- top_level = @store.add_file 'file.rb'
+ file = @store.add_file 'file.rb'
c = RDoc::Constant.new 'CONST', nil, 'comment'
- top_level.add_constant c
+ file.add_constant c
assert_nil c.is_alias_for
@@ -61,15 +61,15 @@ def test_is_alias_for
end
def test_marshal_dump
- top_level = @store.add_file 'file.rb'
+ file = @store.add_file 'file.rb'
c = RDoc::Constant.new 'CONST', nil, 'this is a comment'
- c.record_location top_level
+ c.record_location file
- aliased = top_level.add_class RDoc::NormalClass, 'Aliased'
+ aliased = file.add_class RDoc::NormalClass, 'Aliased'
c.is_alias_for = aliased
- cm = top_level.add_class RDoc::NormalClass, 'Klass'
+ cm = file.add_class RDoc::NormalClass, 'Klass'
cm.add_constant c
section = cm.sections.first
@@ -83,7 +83,7 @@ def test_marshal_dump
assert_equal aliased, loaded.is_alias_for
assert_equal document, loaded.comment.parse
- assert_equal top_level, loaded.file
+ assert_equal file, loaded.file
assert_equal 'Klass::CONST', loaded.full_name
assert_equal 'CONST', loaded.name
assert_equal :public, loaded.visibility
@@ -92,12 +92,12 @@ def test_marshal_dump
end
def test_marshal_load
- top_level = @store.add_file 'file.rb'
+ file = @store.add_file 'file.rb'
c = RDoc::Constant.new 'CONST', nil, 'this is a comment'
- c.record_location top_level
+ c.record_location file
- cm = top_level.add_class RDoc::NormalClass, 'Klass'
+ cm = file.add_class RDoc::NormalClass, 'Klass'
cm.add_constant c
section = cm.sections.first
@@ -111,7 +111,7 @@ def test_marshal_load
assert_nil loaded.is_alias_for
assert_equal document, loaded.comment.parse
- assert_equal top_level, loaded.file
+ assert_equal file, loaded.file
assert_equal 'Klass::CONST', loaded.full_name
assert_equal 'CONST', loaded.name
assert_equal :public, loaded.visibility
@@ -122,10 +122,10 @@ def test_marshal_load
end
def test_marshal_load_version_0
- top_level = @store.add_file 'file.rb'
+ file = @store.add_file 'file.rb'
- aliased = top_level.add_class RDoc::NormalClass, 'Aliased'
- cm = top_level.add_class RDoc::NormalClass, 'Klass'
+ aliased = file.add_class RDoc::NormalClass, 'Aliased'
+ cm = file.add_class RDoc::NormalClass, 'Klass'
section = cm.sections.first
loaded = Marshal.load "\x04\bU:\x13RDoc::Constant[\x0Fi\x00I" +
@@ -143,7 +143,7 @@ def test_marshal_load_version_0
assert_equal aliased, loaded.is_alias_for
assert_equal document, loaded.comment.parse
- assert_equal top_level, loaded.file
+ assert_equal file, loaded.file
assert_equal 'Klass::CONST', loaded.full_name
assert_equal 'CONST', loaded.name
assert_equal :public, loaded.visibility
@@ -154,13 +154,13 @@ def test_marshal_load_version_0
end
def test_marshal_round_trip
- top_level = @store.add_file 'file.rb'
+ file = @store.add_file 'file.rb'
c = RDoc::Constant.new 'CONST', nil, 'this is a comment'
- c.record_location top_level
+ c.record_location file
c.is_alias_for = 'Unknown'
- cm = top_level.add_class RDoc::NormalClass, 'Klass'
+ cm = file.add_class RDoc::NormalClass, 'Klass'
cm.add_constant c
section = cm.sections.first
diff --git a/test/rdoc/code_object/include_test.rb b/test/rdoc/code_object/include_test.rb
index c49e1824ba..967dec00cb 100644
--- a/test/rdoc/code_object/include_test.rb
+++ b/test/rdoc/code_object/include_test.rb
@@ -8,7 +8,7 @@ def setup
@inc = RDoc::Include.new 'M1', 'comment'
@inc.parent = @m1
- @inc.record_location @top_level
+ @inc.record_location @file
@inc.store = @store
end
@@ -98,11 +98,11 @@ def test_module_extended
def test_store_equals
incl = RDoc::Include.new 'M', nil
- incl.record_location RDoc::TopLevel.new @top_level.name
+ incl.record_location RDoc::File.new @file.name
incl.store = @store
- assert_same @top_level, incl.file
+ assert_same @file, incl.file
assert_same @store, incl.file.store
end
diff --git a/test/rdoc/code_object/method_attr_test.rb b/test/rdoc/code_object/method_attr_test.rb
index bffcb799d3..7ee8c7dafc 100644
--- a/test/rdoc/code_object/method_attr_test.rb
+++ b/test/rdoc/code_object/method_attr_test.rb
@@ -179,14 +179,14 @@ def test_pretty_print
temp_dir do |tmpdir|
s = RDoc::RI::Store.new(RDoc::Options.new, path: tmpdir)
- top_level = s.add_file 'file.rb'
+ file = s.add_file 'file.rb'
meth_bang = RDoc::AnyMethod.new nil, 'method!'
- meth_bang.record_location top_level
+ meth_bang.record_location file
meth_bang_alias = RDoc::Alias.new nil, 'method!', 'method_bang', ''
- meth_bang_alias.record_location top_level
+ meth_bang_alias.record_location file
- klass = top_level.add_class RDoc::NormalClass, 'Object'
+ klass = file.add_class RDoc::NormalClass, 'Object'
klass.add_method meth_bang
meth_bang.add_alias meth_bang_alias, klass
diff --git a/test/rdoc/code_object/normal_class_test.rb b/test/rdoc/code_object/normal_class_test.rb
index 431ca4b3f1..72aefe385b 100644
--- a/test/rdoc/code_object/normal_class_test.rb
+++ b/test/rdoc/code_object/normal_class_test.rb
@@ -4,10 +4,10 @@
class RDocNormalClassTest < XrefTestCase
def test_ancestors
- klass = @top_level.add_class RDoc::NormalClass, 'Klass'
+ klass = @file.add_class RDoc::NormalClass, 'Klass'
incl = RDoc::Include.new 'Incl', ''
- sub_klass = @top_level.add_class RDoc::NormalClass, 'SubClass'
+ sub_klass = @file.add_class RDoc::NormalClass, 'SubClass'
sub_klass.superclass = klass
sub_klass.add_include incl
@@ -15,9 +15,9 @@ def test_ancestors
end
def test_ancestors_multilevel
- c1 = @top_level.add_class RDoc::NormalClass, 'Outer'
- c2 = @top_level.add_class RDoc::NormalClass, 'Middle', c1.full_name
- c3 = @top_level.add_class RDoc::NormalClass, 'Inner', c2.full_name
+ c1 = @file.add_class RDoc::NormalClass, 'Outer'
+ c2 = @file.add_class RDoc::NormalClass, 'Middle', c1.full_name
+ c3 = @file.add_class RDoc::NormalClass, 'Inner', c2.full_name
assert_equal [c2, c1, @object, 'BasicObject'], c3.ancestors
end
@@ -30,9 +30,9 @@ def test_aref
def test_direct_ancestors
incl = RDoc::Include.new 'Incl', ''
- c1 = @top_level.add_class RDoc::NormalClass, 'Outer'
- c2 = @top_level.add_class RDoc::NormalClass, 'Middle', c1.full_name
- c3 = @top_level.add_class RDoc::NormalClass, 'Inner', c2.full_name
+ c1 = @file.add_class RDoc::NormalClass, 'Outer'
+ c2 = @file.add_class RDoc::NormalClass, 'Middle', c1.full_name
+ c3 = @file.add_class RDoc::NormalClass, 'Inner', c2.full_name
c3.add_include incl
assert_equal [incl.name, c2], c3.direct_ancestors
diff --git a/test/rdoc/code_object/normal_module_test.rb b/test/rdoc/code_object/normal_module_test.rb
index 0a45b950f6..310f5b8ce3 100644
--- a/test/rdoc/code_object/normal_module_test.rb
+++ b/test/rdoc/code_object/normal_module_test.rb
@@ -10,15 +10,15 @@ def setup
end
def test_ancestors_module
- top_level = @store.add_file 'file.rb'
- mod = top_level.add_module RDoc::NormalModule, 'Mod'
+ file = @store.add_file 'file.rb'
+ mod = file.add_module RDoc::NormalModule, 'Mod'
incl = RDoc::Include.new 'Incl', ''
mod.add_include incl
assert_equal [incl.name], mod.ancestors
- mod2 = top_level.add_module RDoc::NormalModule, 'Inc2'
+ mod2 = file.add_module RDoc::NormalModule, 'Inc2'
inc2 = RDoc::Include.new 'Inc2', ''
mod.add_include inc2
assert_equal [mod2, incl.name], mod.ancestors
diff --git a/test/rdoc/generator/aliki/highlight_c_test.rb b/test/rdoc/generator/aliki/highlight_c_test.rb
index 4d7a1089db..20d65e7489 100644
--- a/test/rdoc/generator/aliki/highlight_c_test.rb
+++ b/test/rdoc/generator/aliki/highlight_c_test.rb
@@ -11,13 +11,13 @@
end
class RDocGeneratorAlikiHighlightCTest < Test::Unit::TestCase
- HIGHLIGHT_C_JS_PATH = File.expand_path(
+ HIGHLIGHT_C_JS_PATH = ::File.expand_path(
'../../../../lib/rdoc/generator/template/aliki/js/c_highlighter.js',
__dir__
)
HIGHLIGHT_C_JS = begin
- highlight_c_js = File.read(HIGHLIGHT_C_JS_PATH)
+ highlight_c_js = ::File.read(HIGHLIGHT_C_JS_PATH)
# We need to modify the JS slightly to make it work in the context of a test.
highlight_c_js.gsub(
diff --git a/test/rdoc/generator/aliki_test.rb b/test/rdoc/generator/aliki_test.rb
index 8d3ba737c4..9207b78c5b 100644
--- a/test/rdoc/generator/aliki_test.rb
+++ b/test/rdoc/generator/aliki_test.rb
@@ -12,15 +12,15 @@ def setup
@options = RDoc::Options.new
@options.option_parser = OptionParser.new
- @tmpdir = File.join Dir.tmpdir, "test_rdoc_generator_aliki_#{$$}"
+ @tmpdir = ::File.join Dir.tmpdir, "test_rdoc_generator_aliki_#{$$}"
FileUtils.mkdir_p @tmpdir
Dir.chdir @tmpdir
@options.op_dir = @tmpdir
@options.generator = RDoc::Generator::Aliki
$LOAD_PATH.each do |path|
- aliki_dir = File.join path, 'rdoc/generator/template/aliki/'
- next unless File.directory? aliki_dir
+ aliki_dir = ::File.join path, 'rdoc/generator/template/aliki/'
+ next unless ::File.directory? aliki_dir
@options.template_dir = aliki_dir
break
end
@@ -30,9 +30,9 @@ def setup
@g = @options.generator.new @store, @options
@rdoc.generator = @g
- @top_level = @store.add_file 'file.rb'
- @top_level.parser = RDoc::Parser::Ruby
- @klass = @top_level.add_class RDoc::NormalClass, 'Klass'
+ @file = @store.add_file 'file.rb'
+ @file.parser = RDoc::Parser::Ruby
+ @klass = @file.add_class RDoc::NormalClass, 'Klass'
@meth = RDoc::AnyMethod.new nil, 'method'
@meth_with_html_tag_yield = RDoc::AnyMethod.new nil, 'method_with_html_tag_yield'
@@ -68,15 +68,15 @@ def test_write_style_sheet_copies_css_and_js_only
assert_file 'js/c_highlighter.js'
# Aliki should NOT have fonts (unlike Darkfish)
- refute File.exist?('css/fonts.css'), 'Aliki should not copy fonts.css'
- refute File.exist?('fonts'), 'Aliki should not copy fonts directory'
+ refute ::File.exist?('css/fonts.css'), 'Aliki should not copy fonts.css'
+ refute ::File.exist?('fonts'), 'Aliki should not copy fonts directory'
end
# Aliki-specific: verify version query strings on asset references
def test_asset_version_query_strings
@g.generate
- content = File.binread('index.html')
+ content = ::File.binread('index.html')
# CSS should have version query string
assert_match %r{css/rdoc\.css\?v=#{Regexp.escape(RDoc::VERSION)}}, content
@@ -91,7 +91,7 @@ def test_open_graph_meta_tags_for_index
@options.title = "My Ruby Project"
@g.generate
- content = File.binread('index.html')
+ content = ::File.binread('index.html')
assert_match %r{ }, content
assert_match %r{ }, content
@@ -99,13 +99,13 @@ def test_open_graph_meta_tags_for_index
end
def test_open_graph_meta_tags_for_class
- top_level = @store.add_file 'file.rb'
- top_level.add_class @klass.class, @klass.name
- @klass.add_comment "A useful class for doing things.", top_level
+ file = @store.add_file 'file.rb'
+ file.add_class @klass.class, @klass.name
+ @klass.add_comment "A useful class for doing things.", file
@g.generate
- content = File.binread('Klass.html')
+ content = ::File.binread('Klass.html')
assert_match %r{ }, content
@@ -116,7 +116,7 @@ def test_twitter_meta_tags_for_index
@options.title = "My Ruby Project"
@g.generate
- content = File.binread('index.html')
+ content = ::File.binread('index.html')
assert_match %r{ }, content
assert_match %r{ }, content
@@ -124,27 +124,27 @@ def test_twitter_meta_tags_for_index
end
def test_twitter_meta_tags_for_class
- top_level = @store.add_file 'file.rb'
- top_level.add_class @klass.class, @klass.name
- @klass.add_comment "A useful class for doing things.", top_level
+ file = @store.add_file 'file.rb'
+ file.add_class @klass.class, @klass.name
+ @klass.add_comment "A useful class for doing things.", file
@g.generate
- content = File.binread('Klass.html')
+ content = ::File.binread('Klass.html')
assert_match %r{ }, content
assert_match %r{ }, content
end
def test_meta_tags_multiline_format
- top_level = @store.add_file 'file.rb'
- top_level.add_class @klass.class, @klass.name
+ file = @store.add_file 'file.rb'
+ file.add_class @klass.class, @klass.name
inner = @klass.add_class RDoc::NormalClass, 'Inner'
- inner.add_comment "This is a normal class.", top_level
+ inner.add_comment "This is a normal class.", file
@g.generate
- content = File.binread('Klass/Inner.html')
+ content = ::File.binread('Klass/Inner.html')
# Aliki formats meta tags across multiple lines
assert_match %r{name="keywords"\s+content="ruby,class,Klass::Inner"}m, content
@@ -153,9 +153,9 @@ def test_meta_tags_multiline_format
def test_template_stylesheets_with_version
css = Tempfile.create(%W[custom .css], Dir.mktmpdir('tmp', '.'))
- File.write(css, '')
+ ::File.write(css, '')
css.close
- base = File.basename(css)
+ base = ::File.basename(css)
@options.template_stylesheets << css
@@ -163,16 +163,16 @@ def test_template_stylesheets_with_version
assert_file base
# Aliki includes version in query string for custom stylesheets too
- assert_match %r{href="\./#{Regexp.escape(base)}\?v=#{Regexp.escape(RDoc::VERSION)}"}, File.binread('index.html')
+ assert_match %r{href="\./#{Regexp.escape(base)}\?v=#{Regexp.escape(RDoc::VERSION)}"}, ::File.binread('index.html')
end
def test_generated_method_with_html_tag_yield_escapes_xss
- top_level = @store.add_file 'file.rb'
- top_level.add_class @klass.class, @klass.name
+ file = @store.add_file 'file.rb'
+ file.add_class @klass.class, @klass.name
@g.generate
- content = File.binread('Klass.html')
+ content = ::File.binread('Klass.html')
# Script tags in yield params should be escaped
assert_match %r{%<<script>alert\("atui"\)</script>>}, content
@@ -183,7 +183,7 @@ def test_title_escape_prevents_xss
@options.title = ''
@g.generate
- content = File.binread('index.html')
+ content = ::File.binread('index.html')
# Title should be HTML escaped
assert_match %r{
<script>alert\("xss"\)</script> }, content
@@ -192,7 +192,7 @@ def test_title_escape_prevents_xss
def test_generate
@klass.add_class RDoc::NormalClass, 'Inner'
- @klass.add_comment "Test class documentation", @top_level
+ @klass.add_comment "Test class documentation", @file
@g.generate
@@ -207,7 +207,7 @@ def test_generate
assert_file 'js/aliki.js'
# Verify HTML structure
- index = File.binread('index.html')
+ index = ::File.binread('index.html')
assert_match %r{}, index
assert_match %r{}, index
@@ -219,13 +219,13 @@ def test_canonical_url
@store.options.canonical_root = @options.canonical_root = "https://example.com/docs/"
@g.generate
- index_content = File.binread('index.html')
+ index_content = ::File.binread('index.html')
assert_include index_content, ' '
# Open Graph should also include canonical URL
assert_match %r{ }, index_content
- inner_content = File.binread('Klass/Inner.html')
+ inner_content = ::File.binread('Klass/Inner.html')
assert_include inner_content, ' '
end
@@ -244,7 +244,7 @@ def test_html_lang_from_locale
@options.locale = RDoc::I18n::Locale.new 'ja'
@g.generate
- content = File.binread('index.html')
+ content = ::File.binread('index.html')
assert_include content, ''
end
end
diff --git a/test/rdoc/generator/darkfish_test.rb b/test/rdoc/generator/darkfish_test.rb
index 1f0236ad8f..8bed42d8fc 100644
--- a/test/rdoc/generator/darkfish_test.rb
+++ b/test/rdoc/generator/darkfish_test.rb
@@ -12,15 +12,15 @@ def setup
@options = RDoc::Options.new
@options.option_parser = OptionParser.new
- @tmpdir = File.join Dir.tmpdir, "test_rdoc_generator_darkfish_#{$$}"
+ @tmpdir = ::File.join Dir.tmpdir, "test_rdoc_generator_darkfish_#{$$}"
FileUtils.mkdir_p @tmpdir
Dir.chdir @tmpdir
@options.op_dir = @tmpdir
@options.generator = RDoc::Generator::Darkfish
$LOAD_PATH.each do |path|
- darkfish_dir = File.join path, 'rdoc/generator/template/darkfish/'
- next unless File.directory? darkfish_dir
+ darkfish_dir = ::File.join path, 'rdoc/generator/template/darkfish/'
+ next unless ::File.directory? darkfish_dir
@options.template_dir = darkfish_dir
break
end
@@ -30,16 +30,16 @@ def setup
@g = @options.generator.new @store, @options
@rdoc.generator = @g
- @top_level = @store.add_file 'file.rb'
- @top_level.parser = RDoc::Parser::Ruby
- @klass = @top_level.add_class RDoc::NormalClass, 'Klass'
+ @file = @store.add_file 'file.rb'
+ @file.parser = RDoc::Parser::Ruby
+ @klass = @file.add_class RDoc::NormalClass, 'Klass'
@alias_constant = RDoc::Constant.new 'A', nil, ''
- @alias_constant.record_location @top_level
+ @alias_constant.record_location @file
- @top_level.add_constant @alias_constant
+ @file.add_constant @alias_constant
- @klass.add_module_alias @klass, @klass.name, @alias_constant, @top_level
+ @klass.add_module_alias @klass, @klass.name, @alias_constant, @file
@meth = RDoc::AnyMethod.new nil, 'method'
@meth_bang = RDoc::AnyMethod.new nil, 'method!'
@@ -52,7 +52,7 @@ def setup
@klass.add_method @meth_with_html_tag_yield
@klass.add_attribute @attr
- @ignored = @top_level.add_class RDoc::NormalClass, 'Ignored'
+ @ignored = @file.add_class RDoc::NormalClass, 'Ignored'
@ignored.ignore
@store.complete :private
@@ -70,10 +70,10 @@ def teardown
end
def test_generate
- top_level = @store.add_file 'file.rb'
- top_level.add_class @klass.class, @klass.name
+ file = @store.add_file 'file.rb'
+ file.add_class @klass.class, @klass.name
@klass.add_class RDoc::NormalClass, 'Inner'
- @klass.add_comment <<~RDOC, top_level
+ @klass.add_comment <<~RDOC, file
= Heading 1
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
== Heading 1.1
@@ -107,14 +107,14 @@ def test_generate
encoding = Regexp.escape Encoding::UTF_8.name
- assert_match %r% %, File.binread('index.html')
- assert_match %r% %, File.binread('Object.html')
+ assert_match %r% %, ::File.binread('index.html')
+ assert_match %r% %, ::File.binread('Object.html')
- refute_match(/Ignored/, File.binread('index.html'))
- summary = File.binread('index.html')[%r[.*]m]
+ refute_match(/Ignored/, ::File.binread('index.html'))
+ summary = ::File.binread('index.html')[%r[.*]m]
assert_match(%r[Klass/Inner\.html".*>Inner<], summary)
- klass = File.binread('Klass.html')
+ klass = ::File.binread('Klass.html')
klassnav = klass[%r[.*]m]
assert_match(
%r[
\s*\s*\s*Heading 1 \s* \s*Heading 1<\/a>(?!\.)/,
klass[%r[]m])
- toc = File.binread('table_of_contents.html')
+ toc = ::File.binread('table_of_contents.html')
assert_match(
%r[ Heading 1 ]m,
toc[%r[.*(?=Table of Contents"
assert_include index_html, 'Heading 1 '
@@ -177,8 +177,8 @@ def test_generate_index_with_main_page
end
def test_generate_index_without_main_page
- top_level = @store.add_file 'file.rb'
- top_level.comment = <<~RDOC
+ file = @store.add_file 'file.rb'
+ file.comment = <<~RDOC
= Heading 1
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
== Heading 1.1
@@ -209,7 +209,7 @@ def test_generate_index_without_main_page
assert_hard_link 'fonts/SourceCodePro-Bold.ttf'
assert_hard_link 'fonts/SourceCodePro-Regular.ttf'
- index_html = File.binread('index.html')
+ index_html = ::File.binread('index.html')
# If there is no main page, the index page should not have a table of contents
assert_not_include index_html, "Table of Contents "
@@ -222,21 +222,21 @@ def test_generate_page
@g.generate
assert_file 'outer_rdoc.html'
assert_file 'outer/inner_rdoc.html'
- index = File.binread('index.html')
+ index = ::File.binread('index.html')
re = %r[outer .*? ]m
assert_match(re, index)
summary = index[re]
assert_match %r[inner ], summary
re = %r[outer .*? ]m
- assert_match(re, File.binread('outer_rdoc.html'))
+ assert_match(re, ::File.binread('outer_rdoc.html'))
re = %r[outer .*? ]m
- assert_match(re, File.binread('outer/inner_rdoc.html'))
+ assert_match(re, ::File.binread('outer/inner_rdoc.html'))
end
def test_generate_dry_run
@g.dry_run = true
- top_level = @store.add_file 'file.rb'
- top_level.add_class @klass.class, @klass.name
+ file = @store.add_file 'file.rb'
+ file.add_class @klass.class, @klass.name
@g.generate
@@ -251,8 +251,8 @@ def test_generate_static
FileUtils.touch 'file/file.txt'
@options.static_path = [
- File.expand_path('dir'),
- File.expand_path('file/file.txt'),
+ ::File.expand_path('dir'),
+ ::File.expand_path('file/file.txt'),
]
@g.generate
@@ -265,7 +265,7 @@ def test_generate_static_dry_run
FileUtils.mkdir 'static'
FileUtils.touch 'static/image.png'
- @options.static_path = [File.expand_path('static')]
+ @options.static_path = [::File.expand_path('static')]
@g.dry_run = true
@g.generate
@@ -274,8 +274,8 @@ def test_generate_static_dry_run
end
def test_install_rdoc_static_file
- src = Pathname File.expand_path(__FILE__, @pwd)
- dst = File.join @tmpdir, File.basename(src)
+ src = Pathname ::File.expand_path(__FILE__, @pwd)
+ dst = ::File.join @tmpdir, ::File.basename(src)
options = {}
@g.install_rdoc_static_file src, dst, options
@@ -286,7 +286,7 @@ def test_install_rdoc_static_file
def test_install_rdoc_static_file_missing
src = Pathname(__FILE__) + 'nonexistent'
- dst = File.join @tmpdir, File.basename(src)
+ dst = ::File.join @tmpdir, ::File.basename(src)
options = {}
@g.install_rdoc_static_file src, dst, options
@@ -299,7 +299,7 @@ def test_setup
assert_equal [@klass_alias, @ignored, @klass, @object],
@g.classes.sort_by { |klass| klass.full_name }
- assert_equal [@top_level], @g.files
+ assert_equal [@file], @g.files
assert_equal [@meth, @meth, @meth_bang, @meth_bang, @meth_with_html_tag_yield, @meth_with_html_tag_yield], @g.methods
assert_equal [@klass_alias, @klass, @object], @g.modsort
end
@@ -333,12 +333,12 @@ def test_template_for_partial
end
def test_generated_method_with_html_tag_yield
- top_level = @store.add_file 'file.rb'
- top_level.add_class @klass.class, @klass.name
+ file = @store.add_file 'file.rb'
+ file.add_class @klass.class, @klass.name
@g.generate
- path = File.join @tmpdir, 'A.html'
+ path = ::File.join @tmpdir, 'A.html'
f = open(path)
internal_file = f.read
@@ -353,12 +353,12 @@ def test_generated_method_with_html_tag_yield
def test_generated_filename_with_html_tag
filename = '">should be escaped'
begin # in @tmpdir
- File.write(filename, '')
+ ::File.write(filename, '')
rescue SystemCallError
# ", <, > chars are prohibited as filename
return
else
- File.unlink(filename)
+ ::File.unlink(filename)
end
@store.add_file filename
doc = @store.all_files.last
@@ -367,7 +367,7 @@ def test_generated_filename_with_html_tag
@g.generate
Dir.glob("*.html", base: @tmpdir) do |html|
- File.binread(File.join(@tmpdir, html)).scan(/.*should be escaped.*/) do |line|
+ ::File.binread(::File.join(@tmpdir, html)).scan(/.*should be escaped.*/) do |line|
assert_not_include line, "", html
end
end
@@ -375,9 +375,9 @@ def test_generated_filename_with_html_tag
def test_template_stylesheets
css = Tempfile.create(%W'hoge .css', Dir.mktmpdir('tmp', '.'))
- File.write(css, '')
+ ::File.write(css, '')
css.close
- base = File.basename(css)
+ base = ::File.basename(css)
refute_file(base)
@options.template_stylesheets << css
@@ -385,13 +385,13 @@ def test_template_stylesheets
@g.generate
assert_file base
- assert_include File.binread('index.html'), %Q[href="./#{base}"]
+ assert_include ::File.binread('index.html'), %Q[href="./#{base}"]
end
def test_html_lang
@g.generate
- content = File.binread("index.html")
+ content = ::File.binread("index.html")
assert_include(content, '')
end
@@ -399,7 +399,7 @@ def test_html_lang_from_locale
@options.locale = RDoc::I18n::Locale.new 'ja'
@g.generate
- content = File.binread("index.html")
+ content = ::File.binread("index.html")
assert_include(content, '')
end
@@ -408,7 +408,7 @@ def test_title
@options.title = title
@g.generate
- assert_main_title(File.binread('index.html'), title)
+ assert_main_title(::File.binread('index.html'), title)
end
def test_title_escape
@@ -416,28 +416,28 @@ def test_title_escape
@options.title = title
@g.generate
- assert_main_title(File.binread('index.html'), title)
+ assert_main_title(::File.binread('index.html'), title)
end
def test_meta_tags_for_index
@options.title = "My awesome Ruby project"
@g.generate
- content = File.binread("index.html")
+ content = ::File.binread("index.html")
assert_include(content, ' ')
assert_include(content, ' ')
end
def test_meta_tags_for_classes
- top_level = @store.add_file("file.rb")
- top_level.add_class(@klass.class, @klass.name)
+ file = @store.add_file("file.rb")
+ file.add_class(@klass.class, @klass.name)
inner = @klass.add_class(RDoc::NormalClass, "Inner")
- inner.add_comment("This is a normal class. It is fully documented.", top_level)
+ inner.add_comment("This is a normal class. It is fully documented.", file)
@g.generate
- content = File.binread("Klass/Inner.html")
+ content = ::File.binread("Klass/Inner.html")
assert_include(content, ' ')
assert_include(
content,
@@ -446,8 +446,8 @@ def test_meta_tags_for_classes
end
def test_meta_tags_for_rdoc_files
- top_level = @store.add_file("CONTRIBUTING.rdoc", parser: RDoc::Parser::Simple)
- top_level.comment = <<~RDOC
+ file = @store.add_file("CONTRIBUTING.rdoc", parser: RDoc::Parser::Simple)
+ file.comment = <<~RDOC
= Contributing
Here are the instructions for contributing. Begin by installing Ruby.
@@ -455,7 +455,7 @@ def test_meta_tags_for_rdoc_files
@g.generate
- content = File.binread("CONTRIBUTING_rdoc.html")
+ content = ::File.binread("CONTRIBUTING_rdoc.html")
assert_include(content, ' ')
assert_include(
content,
@@ -465,8 +465,8 @@ def test_meta_tags_for_rdoc_files
end
def test_meta_tags_for_markdown_files_paragraph
- top_level = @store.add_file("README.md", parser: RDoc::Parser::Simple)
- top_level.comment = <<~MARKDOWN
+ file = @store.add_file("README.md", parser: RDoc::Parser::Simple)
+ file.comment = <<~MARKDOWN
# Distributed Ruby: dRuby
dRuby is a distributed object system for Ruby. It allows an object in one
@@ -475,7 +475,7 @@ def test_meta_tags_for_markdown_files_paragraph
@g.generate
- content = File.binread("README_md.html")
+ content = ::File.binread("README_md.html")
assert_include(
content,
" ')
assert_include(
content,
@@ -504,25 +504,25 @@ def test_meta_tags_for_markdown_files
end
def test_meta_tags_for_raw_pages
- top_level = @store.add_file("MyPage", parser: RDoc::Parser::Simple)
+ file = @store.add_file("MyPage", parser: RDoc::Parser::Simple)
comment = RDoc::Comment.new('this is a comment')
comment.document = RDoc::Markup::Document.new(RDoc::Markup::Paragraph.new('this is a comment'))
- top_level.comment = comment
+ file.comment = comment
@g.generate
- content = File.binread("MyPage.html")
+ content = ::File.binread("MyPage.html")
assert_include(content, ' ')
assert_include(content, ' ')
end
def test_meta_tags_for_empty_document
- top_level = @store.add_file("MyPage", parser: RDoc::Parser::Simple)
- top_level.comment = RDoc::Comment.from_document(RDoc::Markup::Document.new)
+ file = @store.add_file("MyPage", parser: RDoc::Parser::Simple)
+ file.comment = RDoc::Comment.from_document(RDoc::Markup::Document.new)
@g.generate
- content = File.binread("MyPage.html")
+ content = ::File.binread("MyPage.html")
assert_include(content, ' ')
assert_include(
content,
@@ -534,20 +534,20 @@ def test_canonical_url_for_index
@store.options.canonical_root = @options.canonical_root = "https://docs.ruby-lang.org/en/master/"
@g.generate
- content = File.binread("index.html")
+ content = ::File.binread("index.html")
assert_include(content, ' ')
end
def test_canonical_url_for_classes
- top_level = @store.add_file("file.rb")
- top_level.add_class(@klass.class, @klass.name)
+ file = @store.add_file("file.rb")
+ file.add_class(@klass.class, @klass.name)
@klass.add_class(RDoc::NormalClass, "Inner")
@store.options.canonical_root = @options.canonical_root = "https://docs.ruby-lang.org/en/master/"
@g.generate
- content = File.binread("Klass/Inner.html")
+ content = ::File.binread("Klass/Inner.html")
assert_include(content, ' ')
end
@@ -558,7 +558,7 @@ def test_canonical_url_for_rdoc_files
@store.options.canonical_root = @options.canonical_root = "https://docs.ruby-lang.org/en/master/"
@g.generate
- content = File.binread("CONTRIBUTING_rdoc.html")
+ content = ::File.binread("CONTRIBUTING_rdoc.html")
assert_include(content, ' ')
end
@@ -571,18 +571,18 @@ def assert_hard_link(filename)
assert_file filename
src = @g.template_dir + '_head.rhtml'
- dst = File.join @tmpdir, 'hardlinktest'
+ dst = ::File.join @tmpdir, 'hardlinktest'
begin
FileUtils.ln src, dst
- nlink = File.stat(dst).nlink if File.identical? src, dst
+ nlink = ::File.stat(dst).nlink if ::File.identical? src, dst
FileUtils.rm dst
return if nlink == 1
rescue SystemCallError
return
end
- assert_operator File.stat(filename).nlink, :>, 1,
+ assert_operator ::File.stat(filename).nlink, :>, 1,
"#{filename} is not hard-linked"
end
diff --git a/test/rdoc/generator/json_index/searcher_test.rb b/test/rdoc/generator/json_index/searcher_test.rb
index d5f0635ef7..236c4a5c46 100644
--- a/test/rdoc/generator/json_index/searcher_test.rb
+++ b/test/rdoc/generator/json_index/searcher_test.rb
@@ -16,11 +16,11 @@ class RDocGeneratorJsonIndexSearcherTest < Test::Unit::TestCase
def setup
@context = MiniRacer::Context.new
- searcher_js_path = File.expand_path(
+ searcher_js_path = ::File.expand_path(
'../../../../lib/rdoc/generator/template/json_index/js/searcher.js',
__dir__
)
- searcher_js = File.read(searcher_js_path)
+ searcher_js = ::File.read(searcher_js_path)
@context.eval(searcher_js)
end
diff --git a/test/rdoc/generator/json_index_test.rb b/test/rdoc/generator/json_index_test.rb
index 6157b49881..779aaf0133 100644
--- a/test/rdoc/generator/json_index_test.rb
+++ b/test/rdoc/generator/json_index_test.rb
@@ -26,26 +26,26 @@ def setup
@rdoc.options = @options
@rdoc.generator = @g
- @top_level = @store.add_file 'file.rb'
- @top_level.parser = RDoc::Parser::Ruby
+ @file = @store.add_file 'file.rb'
+ @file.parser = RDoc::Parser::Ruby
- @klass = @top_level.add_class RDoc::NormalClass, 'C'
+ @klass = @file.add_class RDoc::NormalClass, 'C'
@meth = @klass.add_method RDoc::AnyMethod.new(nil, 'meth')
- @meth.record_location @top_level
+ @meth.record_location @file
@nest_klass = @klass.add_class RDoc::NormalClass, 'D'
- @nest_klass.record_location @top_level
+ @nest_klass.record_location @file
@nest_meth = @nest_klass.add_method RDoc::AnyMethod.new(nil, 'meth')
- @ignored = @top_level.add_class RDoc::NormalClass, 'Ignored'
+ @ignored = @file.add_class RDoc::NormalClass, 'Ignored'
@ignored.ignore
@page = @store.add_file 'page.rdoc'
@page.parser = RDoc::Parser::Simple
- @top_levels = [@top_level, @page].sort
+ @files = [@file, @page].sort
@klasses = [@klass, @nest_klass, @ignored]
Dir.chdir @tmpdir
@@ -87,14 +87,14 @@ def test_generate
assert_file 'js/navigation.js'
assert_file 'js/search_index.js'
- srcdir = File.expand_path('lib/rdoc', @pwd)
- if !File.directory? srcdir
+ srcdir = ::File.expand_path('lib/rdoc', @pwd)
+ if !::File.directory? srcdir
# for Ruby core repository
- srcdir = File.expand_path("../../../lib/rdoc", __FILE__)
+ 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')
+ orig_file = Pathname(::File.join srcdir, 'generator/template/json_index/js/navigation.js')
+ generated_file = Pathname(::File.join @tmpdir, 'js/navigation.js')
# The following assertion for the generated file's modified time randomly
# fails in a ppc64le environment.
@@ -112,7 +112,7 @@ def test_generate
assert_equal orig_file.mtime.inspect, generated_file.mtime.inspect,
'.js files should be the same timestamp of original'
- json = File.read 'js/search_index.js'
+ json = ::File.read 'js/search_index.js'
json =~ /\Avar search_data = /
@@ -162,7 +162,7 @@ def test_generate_search_index_with_reproducible_builds
@g.generate
assert_file 'js/search_index.js'
- generated_search_index = Pathname(File.join @tmpdir, '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
@@ -184,7 +184,7 @@ def test_generate_gzipped
assert_file 'js/search_index.js'
assert_file 'js/search_index.js.gz'
- json = File.open('js/search_index.js.gz', 'rb') {|gzip|
+ json = ::File.open('js/search_index.js.gz', 'rb') {|gzip|
Zlib::GzipReader.new(gzip).read
}
@@ -241,11 +241,11 @@ def test_generate_utf_8
text = "5\xB0"
text = RDoc::Encoding.change_encoding text, Encoding::ISO_8859_1
- @klass.add_comment comment(text), @top_level
+ @klass.add_comment comment(text), @file
@g.generate
- json = File.read 'js/search_index.js'
+ json = ::File.read 'js/search_index.js'
json.force_encoding Encoding::UTF_8
json =~ /\Avar search_data = /
@@ -290,7 +290,7 @@ def test_generate_utf_8
end
def test_index_classes
- @g.reset @top_levels, @klasses
+ @g.reset @files, @klasses
@g.index_classes
@@ -312,7 +312,7 @@ def test_index_classes_nodoc
@meth.document_self = false
@nest_meth.document_self = false
- @g.reset @top_levels, @klasses
+ @g.reset @files, @klasses
@g.index_classes
@@ -326,7 +326,7 @@ def test_index_classes_nodoc
end
def test_index_methods
- @g.reset @top_levels, @klasses
+ @g.reset @files, @klasses
@g.index_methods
@@ -343,7 +343,7 @@ def test_index_methods
end
def test_index_pages
- @g.reset @top_levels, @klasses
+ @g.reset @files, @klasses
@g.index_pages
diff --git a/test/rdoc/generator/pot_test.rb b/test/rdoc/generator/pot_test.rb
index 558e3a16a0..df896856d8 100644
--- a/test/rdoc/generator/pot_test.rb
+++ b/test/rdoc/generator/pot_test.rb
@@ -7,24 +7,24 @@ def setup
super
@options = RDoc::Options.new
- @tmpdir = File.join Dir.tmpdir, "test_rdoc_generator_pot_#{$$}"
+ @tmpdir = ::File.join Dir.tmpdir, "test_rdoc_generator_pot_#{$$}"
FileUtils.mkdir_p @tmpdir
@generator = RDoc::Generator::POT.new @store, @options
- @top_level = @store.add_file 'file.rb'
- @klass = @top_level.add_class RDoc::NormalClass, 'Object'
- @klass.add_comment 'This is a class', @top_level
+ @file = @store.add_file 'file.rb'
+ @klass = @file.add_class RDoc::NormalClass, 'Object'
+ @klass.add_comment 'This is a class', @file
@klass.add_section 'This is a section', comment('This is a section comment')
@const = RDoc::Constant.new "CONSTANT", "29", "This is a constant"
@meth = RDoc::AnyMethod.new nil, 'method'
- @meth.record_location @top_level
+ @meth.record_location @file
@meth.comment = 'This is a method'
@attr = RDoc::Attr.new nil, 'attr', 'RW', ''
- @attr.record_location @top_level
+ @attr.record_location @file
@attr.comment = 'This is an attribute'
@klass.add_constant @const
@@ -44,7 +44,7 @@ def teardown
def test_generate
@generator.generate
- assert_equal <<-POT, File.read(File.join(@tmpdir, 'rdoc.pot'))
+ assert_equal <<-POT, ::File.read(::File.join(@tmpdir, 'rdoc.pot'))
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
diff --git a/test/rdoc/generator/ri_test.rb b/test/rdoc/generator/ri_test.rb
index ca4ee58f9e..79f90e0210 100644
--- a/test/rdoc/generator/ri_test.rb
+++ b/test/rdoc/generator/ri_test.rb
@@ -10,22 +10,22 @@ def setup
@options.encoding = Encoding::UTF_8
@store.encoding = Encoding::UTF_8
- @tmpdir = File.join Dir.tmpdir, "test_rdoc_generator_ri_#{$$}"
+ @tmpdir = ::File.join Dir.tmpdir, "test_rdoc_generator_ri_#{$$}"
FileUtils.mkdir_p @tmpdir
@g = RDoc::Generator::RI.new @store, @options
- @top_level = @store.add_file 'file.rb'
- @klass = @top_level.add_class RDoc::NormalClass, 'Object'
+ @file = @store.add_file 'file.rb'
+ @klass = @file.add_class RDoc::NormalClass, 'Object'
@meth = RDoc::AnyMethod.new nil, 'method'
- @meth.record_location @top_level
+ @meth.record_location @file
@meth_bang = RDoc::AnyMethod.new nil, 'method!'
- @meth_bang.record_location @top_level
+ @meth_bang.record_location @file
@attr = RDoc::Attr.new nil, 'attr', 'RW', ''
- @attr.record_location @top_level
+ @attr.record_location @file
@klass.add_method @meth
@klass.add_method @meth_bang
@@ -44,13 +44,13 @@ def teardown
def test_generate
@g.generate
- assert_file File.join(@tmpdir, 'cache.ri')
+ assert_file ::File.join(@tmpdir, 'cache.ri')
- assert_file File.join(@tmpdir, 'Object', 'cdesc-Object.ri')
+ assert_file ::File.join(@tmpdir, 'Object', 'cdesc-Object.ri')
- assert_file File.join(@tmpdir, 'Object', 'attr-i.ri')
- assert_file File.join(@tmpdir, 'Object', 'method-i.ri')
- assert_file File.join(@tmpdir, 'Object', 'method%21-i.ri')
+ assert_file ::File.join(@tmpdir, 'Object', 'attr-i.ri')
+ assert_file ::File.join(@tmpdir, 'Object', 'method-i.ri')
+ assert_file ::File.join(@tmpdir, 'Object', 'method%21-i.ri')
store = RDoc::RI::Store.new(@options, path: @tmpdir)
store.load_cache
@@ -64,13 +64,13 @@ def test_generate_dry_run
@store.dry_run = true
@g = RDoc::Generator::RI.new @store, @options
- top_level = @store.add_file 'file.rb'
- top_level.add_class @klass.class, @klass.name
+ file = @store.add_file 'file.rb'
+ file.add_class @klass.class, @klass.name
@g.generate
- refute_file File.join(@tmpdir, 'cache.ri')
- refute_file File.join(@tmpdir, 'Object')
+ refute_file ::File.join(@tmpdir, 'cache.ri')
+ refute_file ::File.join(@tmpdir, 'Object')
end
end
diff --git a/test/rdoc/markup/pre_process_test.rb b/test/rdoc/markup/pre_process_test.rb
index b84ecfdd20..866831b6d6 100644
--- a/test/rdoc/markup/pre_process_test.rb
+++ b/test/rdoc/markup/pre_process_test.rb
@@ -8,10 +8,10 @@ def setup
super
@tempfile = Tempfile.new 'test_rdoc_markup_pre_process'
- @file_name = File.basename @tempfile.path
- @dir = File.dirname @tempfile.path
+ @file_name = ::File.basename @tempfile.path
+ @dir = ::File.dirname @tempfile.path
- @pp = RDoc::Markup::PreProcess.new @tempfile.path, [@dir, File.expand_path('..', File.dirname(__FILE__))]
+ @pp = RDoc::Markup::PreProcess.new @tempfile.path, [@dir, ::File.expand_path('..', ::File.dirname(__FILE__))]
end
def teardown
diff --git a/test/rdoc/parser/c_test.rb b/test/rdoc/parser/c_test.rb
index 03157119c9..2654985dba 100644
--- a/test/rdoc/parser/c_test.rb
+++ b/test/rdoc/parser/c_test.rb
@@ -49,7 +49,7 @@ def setup
@tempfile = Tempfile.new self.class.name
filename = @tempfile.path
- @top_level = @store.add_file filename
+ @file = @store.add_file filename
@fn = filename
@options = RDoc::Options.new
@options.verbosity = 2
@@ -127,8 +127,8 @@ def test_known_classes
end
def test_initialize
- some_ext = @top_level.add_class RDoc::NormalClass, 'SomeExt'
- @top_level.add_class RDoc::SingleClass, 'SomeExtSingle'
+ some_ext = @file.add_class RDoc::NormalClass, 'SomeExt'
+ @file.add_class RDoc::SingleClass, 'SomeExtSingle'
@store.cache[:c_class_variables] = {
@fn => { 'cSomeExt' => 'SomeExt' }
@@ -138,7 +138,7 @@ def test_initialize
@fn => { 'cSomeExtSingle' => 'SomeExtSingle' }
}
- parser = RDoc::Parser::C.new @top_level, '', @options, @stats
+ parser = RDoc::Parser::C.new @file, '', @options, @stats
expected = { 'cSomeExt' => some_ext }
assert_equal expected, parser.classes
@@ -188,7 +188,7 @@ def assert_do_attr(flags)
assert_equal 'accessor', accessor.name
assert_equal 'RW', accessor.rw
assert_equal 'This is an accessor', accessor.comment.text
- assert_equal @top_level, accessor.file
+ assert_equal @file, accessor.file
reader = attrs.shift
assert_equal 'reader', reader.name
@@ -242,8 +242,8 @@ def test_do_aliases
assert_equal 'bleh', methods.last.name
assert_equal 'blah', methods.last.is_alias_for.name
- assert_equal @top_level, methods.last.is_alias_for.file
- assert_equal @top_level, methods.last.file
+ assert_equal @file, methods.last.is_alias_for.file
+ assert_equal @file, methods.last.file
end
def test_do_aliases_singleton
@@ -528,7 +528,7 @@ def test_do_constants
constants = klass.constants
assert !klass.constants.empty?
- assert_equal @top_level, constants.first.file
+ assert_equal @file, constants.first.file
constants = constants.map { |c| [c.name, c.value, c.comment.text] }
@@ -599,7 +599,7 @@ def test_do_constants_global
constants = klass.constants
assert !klass.constants.empty?
- assert_equal @top_level, constants.first.file
+ assert_equal @file, constants.first.file
constants = constants.map { |c| [c.name, c.value, c.comment.text] }
assert_equal ['ANSWER', 'INT2FIX(42)', "Toplevel const "],
@@ -688,7 +688,7 @@ def test_do_includes
incl = klass.includes.first
assert_equal 'Inc', incl.name
assert_equal '', incl.comment.text
- assert_equal @top_level, incl.file
+ assert_equal @file, incl.file
end
# HACK parsing warning instead of setting up in file
@@ -818,7 +818,7 @@ def test_do_singleton_class_undocumentable
def test_do_missing
parser = util_parser
- klass_a = @top_level.add_class RDoc::ClassModule, 'A'
+ klass_a = @file.add_class RDoc::ClassModule, 'A'
parser.classes['a'] = klass_a
parser.enclosure_dependencies['c'] << 'b'
@@ -838,7 +838,7 @@ def test_do_missing
def test_do_missing_cycle
parser = util_parser
- klass_a = @top_level.add_class RDoc::ClassModule, 'A'
+ klass_a = @file.add_class RDoc::ClassModule, 'A'
parser.classes['a'] = klass_a
parser.enclosure_dependencies['c'] << 'b'
@@ -928,7 +928,7 @@ def test_find_attr_comment_document_attr_overlap
end
def test_find_class_comment
- @options.rdoc_include << File.dirname(__FILE__)
+ @options.rdoc_include << ::File.dirname(__FILE__)
content = <<-EOF
/*
@@ -1521,7 +1521,7 @@ def test_find_modifiers_nodoc
end
def test_find_modifiers_yields
- comment = RDoc::Comment.new <<-COMMENT, @top_level, :c
+ comment = RDoc::Comment.new <<-COMMENT, @file, :c
/* :yields: a, b
*
* Blah
@@ -1558,10 +1558,10 @@ def test_handle_method_args_minus_1
parser.handle_method 'method', 'rb_cObject', 'm', 'rb_m', -1
- m = @top_level.find_module_named('Object').method_list.first
+ m = @file.find_module_named('Object').method_list.first
assert_equal 'm', m.name
- assert_equal @top_level, m.file
+ assert_equal @file, m.file
assert_equal 7, m.line
assert_equal '(p1)', m.params
@@ -1572,7 +1572,7 @@ def test_handle_method_args_0
parser.handle_method 'method', 'rb_cBasicObject', '==', 'rb_obj_equal', 0
- bo = @top_level.find_module_named 'BasicObject'
+ bo = @file.find_module_named 'BasicObject'
assert_equal 1, bo.method_list.length
@@ -1586,7 +1586,7 @@ def test_handle_method_args_1
parser.handle_method 'method', 'rb_cBasicObject', '==', 'rb_obj_equal', 1
- bo = @top_level.find_module_named 'BasicObject'
+ bo = @file.find_module_named 'BasicObject'
assert_equal 1, bo.method_list.length
@@ -1600,7 +1600,7 @@ def test_handle_method_args_2
parser.handle_method 'method', 'rb_cBasicObject', '==', 'rb_obj_equal', 2
- bo = @top_level.find_module_named 'BasicObject'
+ bo = @file.find_module_named 'BasicObject'
assert_equal 1, bo.method_list.length
@@ -1616,7 +1616,7 @@ def test_handle_method_args_minus_2
parser.handle_method 'method', 'rb_cBasicObject', '==', 'rb_obj_equal', -2
- bo = @top_level.find_module_named 'BasicObject'
+ bo = @file.find_module_named 'BasicObject'
assert_equal 1, bo.method_list.length
@@ -1631,7 +1631,7 @@ def test_handle_method_initialize
parser.handle_method('private_method', 'rb_cBasicObject',
'initialize', 'rb_obj_dummy', -1)
- bo = @top_level.find_module_named 'BasicObject'
+ bo = @file.find_module_named 'BasicObject'
assert_equal 1, bo.method_list.length
@@ -1660,15 +1660,15 @@ def test_look_for_directives_in
comment = RDoc::Comment.new "* :other: not_handled\n"
- parser.look_for_directives_in @top_level, comment
+ parser.look_for_directives_in @file, comment
assert_empty comment.text
- assert_equal 'not_handled', @top_level.metadata['other']
+ assert_equal 'not_handled', @file.metadata['other']
end
def test_load_variable_map
- some_ext = @top_level.add_class RDoc::NormalClass, 'SomeExt'
- @top_level.add_class RDoc::NormalClass, 'OtherExt'
+ some_ext = @file.add_class RDoc::NormalClass, 'SomeExt'
+ @file.add_class RDoc::NormalClass, 'OtherExt'
@store.cache[:c_class_variables][@fn] = { 'cSomeExt' => 'SomeExt' }
@store.cache[:c_class_variables]['other.c'] = { 'cOtherExt' => 'OtherExt' }
@@ -1704,8 +1704,8 @@ def test_load_variable_map_legacy
end
def test_load_variable_map_singleton
- @top_level.add_class RDoc::NormalClass, 'SomeExt'
- @top_level.add_class RDoc::NormalClass, 'OtherExt'
+ @file.add_class RDoc::NormalClass, 'SomeExt'
+ @file.add_class RDoc::NormalClass, 'OtherExt'
@store.cache[:c_singleton_class_variables][@fn] =
{ 'cSomeExt' => 'SomeExt' }
@@ -1725,7 +1725,7 @@ def test_load_variable_map_singleton
end
def test_load_variable_map_trim
- a = @top_level.add_class RDoc::NormalClass, 'A'
+ a = @file.add_class RDoc::NormalClass, 'A'
@store.cache[:c_class_variables][@fn] = {
'cA' => 'A',
@@ -2026,7 +2026,7 @@ def test_scan_method_copy
*
* Return the path as a String.
*
- * to_path is implemented so Pathname objects are usable with File.open, etc.
+ * to_path is implemented so Pathname objects are usable with ::File.open, etc.
*/
static VALUE
path_to_s(VALUE self) { }
@@ -2224,7 +2224,7 @@ def util_get_class(content, name = nil)
end
def util_parser(content = '')
- RDoc::Parser::C.new @top_level, content, @options, @stats
+ RDoc::Parser::C.new @file, content, @options, @stats
end
end
diff --git a/test/rdoc/parser/changelog_test.rb b/test/rdoc/parser/changelog_test.rb
index 562a1c96e3..e6ec8cc0ac 100644
--- a/test/rdoc/parser/changelog_test.rb
+++ b/test/rdoc/parser/changelog_test.rb
@@ -7,7 +7,7 @@ def setup
super
@tempfile = Tempfile.new 'ChangeLog'
- @top_level = @store.add_file @tempfile.path
+ @file = @store.add_file @tempfile.path
@options = RDoc::Options.new
@stats = RDoc::Stats.new @store, 0
end
@@ -78,7 +78,7 @@ def test_create_document
expected =
doc(
- head(1, File.basename(@tempfile.path)),
+ head(1, ::File.basename(@tempfile.path)),
blank_line,
head(2, '2012-12-04'),
blank_line,
@@ -94,7 +94,7 @@ def test_create_document
blank_line,
list(:NOTE, item('e', para('five')), item('f', para('six'))))
- expected.file = @top_level
+ expected.file = @file
document = parser.create_document(groups)
@@ -307,7 +307,7 @@ def test_scan
parser.scan
expected = doc(
- head(1, File.basename(@tempfile.path)),
+ head(1, ::File.basename(@tempfile.path)),
blank_line,
head(2, '2012-12-04'),
blank_line,
@@ -324,9 +324,9 @@ def test_scan
list(:NOTE,
item('vm_exec.c', para('check VM_COLLECT_USAGE_DETAILS.'))))
- expected.file = @top_level
+ expected.file = @file
- assert_equal expected, @top_level.comment.parse
+ assert_equal expected, @file.comment.parse
end
def test_scan_git
@@ -388,7 +388,7 @@ def test_scan_git
parser.scan
expected = doc(
- head(1, File.basename(@tempfile.path)),
+ head(1, ::File.basename(@tempfile.path)),
blank_line,
head(2, '2021-01-24'),
blank_line,
@@ -428,9 +428,9 @@ def test_scan_git
head(5, 'Solution'),
para('Call new_args on this case.')]))
- expected.file = @top_level
+ expected.file = @file
- assert_equal expected, @top_level.comment.parse
+ assert_equal expected, @file.comment.parse
end
def test_scan_git_commit_date
@@ -455,7 +455,7 @@ def test_scan_git_commit_date
parser.scan
expected = doc(
- head(1, File.basename(@tempfile.path)),
+ head(1, ::File.basename(@tempfile.path)),
blank_line,
head(2, "2021-01-07"),
blank_line,
@@ -468,13 +468,13 @@ def test_scan_git_commit_date
'2021-01-07 10:21:34 +0900',
[list(:BULLET, item(nil, para("2021-01-07 [ci skip]")))]))
- expected.file = @top_level
+ expected.file = @file
- assert_equal expected, @top_level.comment.parse
+ assert_equal expected, @file.comment.parse
end
def util_parser(content = '')
- RDoc::Parser::ChangeLog.new @top_level, content, @options, @stats
+ RDoc::Parser::ChangeLog.new @file, content, @options, @stats
end
def log_entry(*a)
diff --git a/test/rdoc/parser/markdown_test.rb b/test/rdoc/parser/markdown_test.rb
index 194d105b49..f6fc161c5a 100644
--- a/test/rdoc/parser/markdown_test.rb
+++ b/test/rdoc/parser/markdown_test.rb
@@ -11,7 +11,7 @@ def setup
@tempfile = Tempfile.new self.class.name
filename = @tempfile.path
- @top_level = @store.add_file filename
+ @file = @store.add_file filename
@fn = filename
@options = RDoc::Options.new
@stats = RDoc::Stats.new @store, 0
@@ -47,15 +47,15 @@ def test_scan
expected =
@RM::Document.new(
@RM::Paragraph.new('it _really_ works'))
- expected.file = @top_level
+ expected.file = @file
parser.scan
- assert_equal expected, @top_level.comment.parse
+ assert_equal expected, @file.comment.parse
end
def util_parser(content)
- RDoc::Parser::Markdown.new @top_level, content, @options, @stats
+ RDoc::Parser::Markdown.new @file, content, @options, @stats
end
end
diff --git a/test/rdoc/parser/parser_test.rb b/test/rdoc/parser/parser_test.rb
index 590aeeef91..510e735e2c 100644
--- a/test/rdoc/parser/parser_test.rb
+++ b/test/rdoc/parser/parser_test.rb
@@ -8,37 +8,37 @@ def setup
super
@RP = RDoc::Parser
- @binary_dat_fixture_path = File.expand_path '../../binary.dat', __FILE__
+ @binary_dat_fixture_path = ::File.expand_path '../../binary.dat', __FILE__
@options = RDoc::Options.new
end
def test_class_binary_eh_ISO_2022_JP
- iso_2022_jp = File.join Dir.tmpdir, "test_rdoc_parser_#{$$}.rd"
+ iso_2022_jp = ::File.join Dir.tmpdir, "test_rdoc_parser_#{$$}.rd"
- File.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
refute @RP.binary? iso_2022_jp
ensure
- File.unlink iso_2022_jp
+ ::File.unlink iso_2022_jp
end
def test_class_binary_eh_marshal
- marshal = File.join Dir.tmpdir, "test_rdoc_parser_#{$$}.marshal"
- File.open marshal, 'wb' do |io|
+ marshal = ::File.join Dir.tmpdir, "test_rdoc_parser_#{$$}.marshal"
+ ::File.open marshal, 'wb' do |io|
io.write Marshal.dump('')
io.write 'lots of text ' * 500
end
assert @RP.binary?(marshal)
ensure
- File.unlink marshal
+ ::File.unlink marshal
end
def test_class_binary_japanese_text
- file_name = File.expand_path '../../test.ja.txt', __FILE__
+ file_name = ::File.expand_path '../../test.ja.txt', __FILE__
refute @RP.binary?(file_name)
end
@@ -47,7 +47,7 @@ def test_class_binary_large_japanese_rdoc
begin
extenc, Encoding.default_external =
Encoding.default_external, Encoding::US_ASCII
- file_name = File.expand_path '../../test.ja.largedoc', __FILE__
+ file_name = ::File.expand_path '../../test.ja.largedoc', __FILE__
assert !@RP.binary?(file_name)
ensure
Encoding.default_external = extenc
@@ -56,29 +56,29 @@ def test_class_binary_large_japanese_rdoc
end
def test_class_binary_japanese_rdoc
- file_name = File.expand_path '../../test.ja.rdoc', __FILE__
+ file_name = ::File.expand_path '../../test.ja.rdoc', __FILE__
refute @RP.binary?(file_name)
end
def test_class_can_parse
assert_equal @RP.can_parse(__FILE__), @RP::Ruby
- readme_file_name = File.expand_path '../../test.txt', __FILE__
+ readme_file_name = ::File.expand_path '../../test.txt', __FILE__
assert_equal @RP::Simple, @RP.can_parse(readme_file_name)
assert_equal @RP::Simple, @RP.can_parse(@binary_dat_fixture_path)
- jtest_file_name = File.expand_path '../../test.ja.txt', __FILE__
+ jtest_file_name = ::File.expand_path '../../test.ja.txt', __FILE__
assert_equal @RP::Simple, @RP.can_parse(jtest_file_name)
- jtest_rdoc_file_name = File.expand_path '../../test.ja.rdoc', __FILE__
+ jtest_rdoc_file_name = ::File.expand_path '../../test.ja.rdoc', __FILE__
assert_equal @RP::Simple, @RP.can_parse(jtest_rdoc_file_name)
- readme_file_name = File.expand_path '../../README', __FILE__
+ readme_file_name = ::File.expand_path '../../README', __FILE__
assert_equal @RP::Simple, @RP.can_parse(readme_file_name)
- jtest_largerdoc_file_name = File.expand_path '../../test.ja.largedoc', __FILE__
+ jtest_largerdoc_file_name = ::File.expand_path '../../test.ja.largedoc', __FILE__
assert_equal @RP::Simple, @RP.can_parse(jtest_largerdoc_file_name)
@RP.alias_extension 'rdoc', 'largedoc'
@@ -86,12 +86,12 @@ def test_class_can_parse
end
def test_class_for_executable
- with_top_level("app", "#!/usr/bin/env ruby -w\n") do |top_level, content|
- parser = @RP.for top_level, content, @options, :stats
+ with_top_level("app", "#!/usr/bin/env ruby -w\n") do |file, content|
+ parser = @RP.for file, content, @options, :stats
assert_kind_of RDoc::Parser::Ruby, parser
- assert_equal top_level.absolute_name, parser.file_name
+ assert_equal file.absolute_name, parser.file_name
end
end
@@ -100,14 +100,14 @@ def test_class_for_forbidden
tf = Tempfile.open 'forbidden' do |io|
begin
- File.chmod 0000, io.path
+ ::File.chmod 0000, io.path
forbidden = @store.add_file io.path
parser = @RP.for forbidden, '', @options, :stats
assert_nil parser
ensure
- File.chmod 0400, io.path
+ ::File.chmod 0400, io.path
end
io
end
@@ -115,8 +115,8 @@ def test_class_for_forbidden
end
def test_class_for_modeline
- with_top_level("NEWS", "# -*- rdoc -*-\n= NEWS\n") do |top_level, content|
- parser = @RP.for top_level, content, @options, :stats
+ with_top_level("NEWS", "# -*- rdoc -*-\n= NEWS\n") do |file, content|
+ parser = @RP.for file, content, @options, :stats
assert_kind_of RDoc::Parser::Simple, parser
@@ -125,9 +125,9 @@ def test_class_for_modeline
end
def test_can_parse_modeline
- readme_ext = File.join Dir.tmpdir, "README.EXT.#{$$}"
+ readme_ext = ::File.join Dir.tmpdir, "README.EXT.#{$$}"
- File.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."
@@ -135,13 +135,13 @@ def test_can_parse_modeline
assert_equal RDoc::Parser::Simple, @RP.can_parse(readme_ext)
ensure
- File.unlink readme_ext
+ ::File.unlink readme_ext
end
def test_can_parse_modeline_c
- readme_inc = File.join Dir.tmpdir, "README.inc.#{$$}"
+ readme_inc = ::File.join Dir.tmpdir, "README.inc.#{$$}"
- File.open readme_inc, 'w' do |io|
+ ::File.open readme_inc, 'w' do |io|
io.puts "/* README.inc - -*- c -*- created at: Mon Aug 7 16:45:54 JST 1995 */"
io.puts
io.puts "/* This document explains how to make extension libraries for Ruby. */"
@@ -149,21 +149,21 @@ def test_can_parse_modeline_c
assert_equal RDoc::Parser::C, @RP.can_parse(readme_inc)
ensure
- File.unlink readme_inc
+ ::File.unlink readme_inc
end
##
# Selenium hides a .jar file using a .txt extension.
def test_class_can_parse_zip
- hidden_zip = File.expand_path '../../hidden.zip.txt', __FILE__
+ hidden_zip = ::File.expand_path '../../hidden.zip.txt', __FILE__
assert_nil @RP.can_parse(hidden_zip)
end
def test_check_modeline
- readme_ext = File.join Dir.tmpdir, "README.EXT.#{$$}"
+ readme_ext = ::File.join Dir.tmpdir, "README.EXT.#{$$}"
- File.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."
@@ -171,25 +171,25 @@ def test_check_modeline
assert_equal 'rdoc', @RP.check_modeline(readme_ext)
ensure
- File.unlink readme_ext
+ ::File.unlink readme_ext
end
def test_check_modeline_coding
- readme_ext = File.join Dir.tmpdir, "README.EXT.#{$$}"
+ readme_ext = ::File.join Dir.tmpdir, "README.EXT.#{$$}"
- File.open readme_ext, 'w' do |io|
+ ::File.open readme_ext, 'w' do |io|
io.puts "# -*- coding: utf-8 -*-"
end
assert_nil @RP.check_modeline readme_ext
ensure
- File.unlink readme_ext
+ ::File.unlink readme_ext
end
def test_check_modeline_with_other
- readme_ext = File.join Dir.tmpdir, "README.EXT.#{$$}"
+ readme_ext = ::File.join Dir.tmpdir, "README.EXT.#{$$}"
- File.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."
@@ -197,31 +197,31 @@ def test_check_modeline_with_other
assert_equal 'rdoc', @RP.check_modeline(readme_ext)
ensure
- File.unlink readme_ext
+ ::File.unlink readme_ext
end
def test_check_modeline_no_modeline
- readme_ext = File.join Dir.tmpdir, "README.EXT.#{$$}"
+ readme_ext = ::File.join Dir.tmpdir, "README.EXT.#{$$}"
- File.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
assert_nil @RP.check_modeline(readme_ext)
ensure
- File.unlink readme_ext
+ ::File.unlink readme_ext
end
def test_class_for_binary
- dat_fixture = File.read(@binary_dat_fixture_path)
- with_top_level("binary.dat", dat_fixture) do |top_level, content|
- assert_nil @RP.for(top_level, content, @options, nil)
+ dat_fixture = ::File.read(@binary_dat_fixture_path)
+ with_top_level("binary.dat", dat_fixture) do |file, content|
+ assert_nil @RP.for(file, content, @options, nil)
end
end
def test_class_for_markup
- with_top_level("file.rb", "# coding: utf-8 markup: rd") do |top_level, content|
- parser = @RP.for top_level, content, @options, nil
+ with_top_level("file.rb", "# coding: utf-8 markup: rd") do |file, content|
+ parser = @RP.for file, content, @options, nil
assert_kind_of @RP::RD, parser
end
@@ -309,26 +309,26 @@ def test_class_use_markup_unknown
end
def test_initialize
- with_top_level("file.rb", "") do |top_level, content|
- @RP.new top_level, content, @options, nil
+ with_top_level("file.rb", "") do |file, content|
+ @RP.new file, content, @options, nil
- assert_equal @RP, top_level.parser
+ assert_equal @RP, file.parser
end
end
private
def with_top_level(filename, content, &block)
- absoluate_filename = File.join Dir.tmpdir, filename
- File.open absoluate_filename, 'w' do |io|
+ absoluate_filename = ::File.join Dir.tmpdir, filename
+ ::File.open absoluate_filename, 'w' do |io|
io.write content
end
- top_level = RDoc::TopLevel.new absoluate_filename
+ file = RDoc::File.new absoluate_filename
- yield(top_level, content)
+ yield(file, content)
ensure
- File.unlink absoluate_filename
+ ::File.unlink absoluate_filename
end
end
diff --git a/test/rdoc/parser/prism_ruby_test.rb b/test/rdoc/parser/prism_ruby_test.rb
index e393f70e3e..d9c702ad70 100644
--- a/test/rdoc/parser/prism_ruby_test.rb
+++ b/test/rdoc/parser/prism_ruby_test.rb
@@ -11,13 +11,13 @@ def setup
@tempfile = Tempfile.new self.class.name
@filename = @tempfile.path
- @top_level = @store.add_file @filename
+ @file = @store.add_file @filename
@options = RDoc::Options.new
@options.quiet = true
@options.option_parser = OptionParser.new
- @comment = RDoc::Comment.new '', @top_level
+ @comment = RDoc::Comment.new '', @file
@stats = RDoc::Stats.new @store, 0
end
@@ -32,7 +32,7 @@ def test_look_for_directives_in_section
util_parser <<~RUBY
# :section: new section
RUBY
- section = @top_level.current_section
+ section = @file.current_section
assert_equal 'new section', section.title
end
@@ -41,7 +41,7 @@ def test_look_for_directives_in_commented
# how to make a section:
# # :section: new section
RUBY
- section = @top_level.current_section
+ section = @file.current_section
assert_nil section.title
end
@@ -49,7 +49,7 @@ def test_look_for_directives_in_unhandled
util_parser <<~RUBY
# :unhandled: blah
RUBY
- assert_equal 'blah', @top_level.metadata['unhandled']
+ assert_equal 'blah', @file.metadata['unhandled']
end
def test_block_comment
@@ -65,7 +65,7 @@ class A
def f; end
end
RUBY
- klass = @top_level.classes.first
+ klass = @file.classes.first
meth = klass.method_list.first
assert_equal 'foo', klass.comment.text.strip
assert_equal "bar\nbaz", meth.comment.text.strip
@@ -77,10 +77,10 @@ def test_module
module Foo
end
RUBY
- mod = @top_level.modules.first
+ mod = @file.modules.first
assert_equal 'Foo', mod.full_name
assert_equal 'my module', mod.comment.text
- assert_equal [@top_level], mod.in_files
+ assert_equal [@file], mod.in_files
end
def test_nested_module_with_colon
@@ -113,10 +113,10 @@ def test_class
class Foo
end
RUBY
- klass = @top_level.classes.first
+ klass = @file.classes.first
assert_equal 'Foo', klass.full_name
assert_equal 'my class', klass.comment.text
- assert_equal [@top_level], klass.in_files
+ assert_equal [@file], klass.in_files
assert_equal 2, klass.line
end
@@ -164,7 +164,7 @@ class C < String
def m2; end
end
RUBY
- classes = @top_level.classes
+ classes = @file.classes
assert_equal 3, classes.size
_a, b, c = classes
assert_equal 'A', b.superclass.full_name
@@ -181,7 +181,7 @@ class A; end
class B; end
class C; end
RUBY
- _a, b, c = @top_level.classes
+ _a, b, c = @file.classes
assert_equal 'Object', b.superclass
assert_equal 'Object', c.superclass
@@ -203,7 +203,7 @@ class A; end
class B; end
class C; end
RUBY
- _object, _a, b, c = @top_level.classes
+ _object, _a, b, c = @file.classes
# If Object exists, superclass will be a NormalClass(Object) instead of string "Object"
assert_equal 'Object', b.superclass.full_name
assert_equal 'Object', c.superclass.full_name
@@ -239,7 +239,7 @@ class C3 < A::B; end
class A::C4 < A::B; end
RUBY
- mod = @top_level.modules.first
+ mod = @file.modules.first
classes = mod.classes
assert_equal ['A::B', 'A::C1', 'A::C2', 'A::C3', 'A::C4'], classes.map(&:full_name)
assert_equal ['A::B', 'A::B', 'A::A::B', 'A::B'], classes.drop(1).map(&:superclass).map(&:full_name)
@@ -306,8 +306,8 @@ module A; end
module B; end
end
RUBY
- klass = @top_level.classes.first
- mod = @top_level.modules.first
+ klass = @file.classes.first
+ mod = @file.modules.first
assert_equal 'comment', klass.comment.text.strip
assert_equal 'comment', mod.comment.text.strip
assert_equal ['Foo::A'], klass.classes.select(&:document_self).map(&:full_name)
@@ -322,8 +322,8 @@ class Bar < Foo
class Baz < (any expression)
end
RUBY
- assert_equal ['Foo', 'Bar', 'Baz'], @top_level.classes.map(&:full_name)
- foo, bar, baz = @top_level.classes
+ assert_equal ['Foo', 'Bar', 'Baz'], @file.classes.map(&:full_name)
+ foo, bar, baz = @file.classes
assert_equal foo, bar.superclass
assert_equal '(any expression)', baz.superclass
end
@@ -370,7 +370,7 @@ def initialize(*args)
'initialize(*args)', 'initialize(*args)',
'initialize(*args)'
]
- arglists = @top_level.classes.map { |c| c.method_list.first.arglists }
+ arglists = @file.classes.map { |c| c.method_list.first.arglists }
assert_equal expected, arglists
end
@@ -383,8 +383,8 @@ module D::Baz; end
class A; end
class X < C; end
RUBY
- assert_equal ['A', 'C', 'X'], @top_level.classes.map(&:full_name)
- assert_equal ['B', 'D'], @top_level.modules.map(&:full_name)
+ assert_equal ['A', 'C', 'X'], @file.classes.map(&:full_name)
+ assert_equal ['B', 'D'], @file.modules.map(&:full_name)
end
def test_parenthesized_cdecl
@@ -453,9 +453,9 @@ class Foo
assert_equal 3, one.line
assert_equal 8, two.line
assert_equal 15, three.line
- assert_equal @top_level, one.file
- assert_equal @top_level, two.file
- assert_equal @top_level, three.file
+ assert_equal @file, one.file
+ assert_equal @file, two.file
+ assert_equal @file, three.file
end
def test_invalid_meta_method
@@ -572,9 +572,9 @@ def three x; end
assert_equal 3, one.line
assert_equal 5, two.line
assert_equal 7, three.line
- assert_equal @top_level, one.file
- assert_equal @top_level, two.file
- assert_equal @top_level, three.file
+ assert_equal @file, one.file
+ assert_equal @file, two.file
+ assert_equal @file, three.file
end
def test_method_with_modifier_if_unless
@@ -608,7 +608,7 @@ def foo; end
foo = object.method_list.first
assert_equal 'Object#foo', foo.full_name
assert_equal 'comment', foo.comment.text.strip
- assert_equal @top_level, foo.file
+ assert_equal @file, foo.file
end
def test_meta_method
@@ -626,7 +626,7 @@ class Foo
assert_equal 'Foo#method_foo', method.full_name
assert_equal 'my method', method.comment.text.strip
assert_equal 4, method.line
- assert_equal @top_level, method.file
+ assert_equal @file, method.file
end
def test_first_comment_is_not_a_meta_method
@@ -659,7 +659,7 @@ class Foo
assert_equal 'Foo#unknown', method.full_name
assert_equal 'my method', method.comment.text.strip
assert_equal 4, method.line
- assert_equal @top_level, method.file
+ assert_equal @file, method.file
end
def test_meta_define_method
@@ -688,7 +688,7 @@ class << self
assert_equal [false, false, true], klass.method_list.map(&:singleton)
assert_equal ['comment 1', 'comment 2', 'comment 3'], klass.method_list.map { |m| m.comment.text.strip }
assert_equal [4, 7, 13], klass.method_list.map(&:line)
- assert_equal [@top_level] * 3, klass.method_list.map(&:file)
+ assert_equal [@file] * 3, klass.method_list.map(&:file)
end
def test_method_definition_nested_inside_block
@@ -758,7 +758,7 @@ def f6; end # :yields:
end
RUBY
- klass = @top_level.classes.first
+ klass = @file.classes.first
methods = klass.method_list
expected = [
'f1(a, &b)',
@@ -804,7 +804,7 @@ def method2(*args); end
end
RUBY
- klass = @top_level.classes.first
+ klass = @file.classes.first
methods = klass.method_list
assert_equal ['method1(a, b, c)', 'method2(d, e, f)', 'method3(g, h)'], methods.map(&:arglists)
end
@@ -1221,7 +1221,7 @@ def bar; end
public :bar
end
RUBY
- foo, foo2, bar, bar2 = @top_level.classes.first.method_list
+ foo, foo2, bar, bar2 = @file.classes.first.method_list
assert_equal 'foo', foo.name
assert_equal 'bar', bar.name
assert_equal 'foo2', foo2.name
@@ -1247,7 +1247,7 @@ def foo; end
alias_method 42, :foo
end
RUBY
- assert_equal ['foo'], @top_level.classes.first.method_list.map(&:name)
+ assert_equal ['foo'], @file.classes.first.method_list.map(&:name)
end
def test_alias_method_stopdoc_nodoc
@@ -1261,7 +1261,7 @@ def foo; end
alias_method :foo4, :foo
end
RUBY
- assert_equal ['foo', 'foo4'], @top_level.classes.first.method_list.map(&:name)
+ assert_equal ['foo', 'foo4'], @file.classes.first.method_list.map(&:name)
end
def test_attributes
@@ -1309,7 +1309,7 @@ class Foo
assert_equal [5, 5], [r1.line, r2.line]
assert_equal [7, 7], [w1.line, w2.line]
assert_equal [9, 9], [rw1.line, rw2.line]
- assert_equal [@top_level] * 8, [a1, a2, r1, r2, w1, w2, rw1, rw2].map(&:file)
+ assert_equal [@file] * 8, [a1, a2, r1, r2, w1, w2, rw1, rw2].map(&:file)
end
def test_undocumentable_attributes
@@ -1475,7 +1475,7 @@ class Foo
assert_equal ['readers', 'readers'], [r1.comment.text, r2.comment.text]
assert_equal ['writers', 'writers'], [w1.comment.text, w2.comment.text]
assert_equal ['accessors', 'accessors'], [rw1.comment.text, rw2.comment.text]
- assert_equal [@top_level] * 8, [a1, a2, r1, r2, w1, w2, rw1, rw2].map(&:file)
+ assert_equal [@file] * 8, [a1, a2, r1, r2, w1, w2, rw1, rw2].map(&:file)
end
def test_meta_attributes_named
@@ -1530,7 +1530,7 @@ class Foo
assert_equal 'comment r', r.comment.text
assert_equal 'comment w', w.comment.text
assert_equal 'comment rw', rw.comment.text
- assert_equal [@top_level] * 4, [a, r, w, rw].map(&:file)
+ assert_equal [@file] * 4, [a, r, w, rw].map(&:file)
end
def test_constant
@@ -1554,15 +1554,15 @@ class Bar; end
end
G = (any expression 8)
RUBY
- foo = @top_level.classes.first
+ foo = @file.classes.first
bar = foo.classes.first
- object = @top_level.find_class_or_module('Object')
+ object = @file.find_class_or_module('Object')
assert_equal ['A', 'D', 'E', 'F'], foo.constants.map(&:name) unless accept_legacy_bug?
assert_equal '(any expression 1)', foo.constants.first.value
assert_equal ['B'], bar.constants.map(&:name)
assert_equal ['C', 'G'], object.constants.map(&:name) unless accept_legacy_bug?
all_constants = foo.constants + bar.constants + object.constants
- assert_equal [@top_level] * 7, all_constants.map(&:file) unless accept_legacy_bug?
+ assert_equal [@file] * 7, all_constants.map(&:file) unless accept_legacy_bug?
assert_equal [2, 12, 13, 14, 7, 8, 18], all_constants.map(&:line) unless accept_legacy_bug?
end
@@ -1580,7 +1580,7 @@ module Foo
Foo::B = 2
Foo::D = 2
RUBY
- mod = @top_level.modules.first
+ mod = @file.modules.first
assert_equal ['A', 'B', 'C', 'D'], mod.constants.map(&:name)
assert_equal [false, true, true, false], mod.constants.map(&:received_nodoc)
end
@@ -1615,7 +1615,7 @@ def test_constant_assignment_to_undefined_module_path
util_parser <<~RUBY
A::B::C = 1
RUBY
- a = @top_level.find_module_named 'A'
+ a = @file.find_module_named 'A'
b = a.find_module_named 'B'
c = b.constants.first
assert_equal 'A::B::C', c.full_name
@@ -1630,7 +1630,7 @@ class Bar; end
C = Foo::Bar
end
RUBY
- klass = @top_level.classes.first
+ klass = @file.classes.first
assert_equal [], klass.modules.map(&:full_name)
assert_equal ['Foo::Bar', 'Foo::A', 'Foo::C'], klass.classes.map(&:full_name)
assert_equal ['Foo::A', 'Foo::C'], klass.constants.map(&:full_name)
@@ -1740,7 +1740,7 @@ class << self
end
RUBY
- klass = @top_level.classes.first
+ klass = @file.classes.first
assert_equal [], klass.includes.map(&:name)
assert_equal ['I'], klass.extends.map(&:name)
end
@@ -1788,7 +1788,7 @@ class A
include 42, C # Maybe not Module#include
end
RUBY
- klass = @top_level.classes.first
+ klass = @file.classes.first
assert_equal ['A', 'B'], klass.includes.map(&:name)
end
@@ -1800,7 +1800,7 @@ def test_require
require "\#{embed}"
require (any expression)
RUBY
- assert_equal ['foo/bar'], @top_level.requires.map(&:name)
+ assert_equal ['foo/bar'], @file.requires.map(&:name)
end
def test_statements_identifier_alias_method_before_original_method
@@ -1821,22 +1821,22 @@ def foo(); end
end
RUBY
- foo = @top_level.classes.first.method_list[0]
+ foo = @file.classes.first.method_list[0]
assert_equal 'foo', foo.name
- foo2 = @top_level.classes.first.method_list[1]
+ foo2 = @file.classes.first.method_list[1]
assert_equal 'foo2', foo2.name
assert_equal 'foo', foo2.is_alias_for.name
- foo3 = @top_level.classes.first.method_list[2]
+ foo3 = @file.classes.first.method_list[2]
assert_equal 'foo3', foo3.name
assert_equal 'foo', foo3.is_alias_for.name
- foo4 = @top_level.classes.first.method_list.last
+ foo4 = @file.classes.first.method_list.last
assert_equal 'foo4', foo4.name
assert_equal 'foo', foo4.is_alias_for.name
- assert_equal 'unknown', @top_level.classes.first.external_aliases[0].old_name
+ assert_equal 'unknown', @file.classes.first.external_aliases[0].old_name
end
def test_class_definition_encountered_after_class_reference
@@ -1855,7 +1855,7 @@ class Foo < IO
assert_empty @store.modules_hash
assert_empty @store.all_modules
- klass = @top_level.classes.first
+ klass = @file.classes.first
assert_equal 'Foo', klass.full_name
assert_equal 'IO', klass.superclass
@@ -1873,11 +1873,11 @@ module Foo
end
RUBY
- mod = @top_level.modules.first
+ mod = @file.modules.first
expected = [
- RDoc::Comment.new('comment a', @top_level),
- RDoc::Comment.new('comment b', @top_level)
+ RDoc::Comment.new('comment a', @file),
+ RDoc::Comment.new('comment b', @file)
]
assert_equal expected, mod.comment_location.map { |c, _l| c }
@@ -1909,7 +1909,7 @@ class B; end
class C; end
RUBY
- assert_equal ['A'], @top_level.classes.reject(&:ignored?).map(&:name)
+ assert_equal ['A'], @file.classes.reject(&:ignored?).map(&:name)
end
def test_section
@@ -1935,7 +1935,7 @@ def m5; end
def m6; end
end
RUBY
- foo = @top_level.classes.first
+ foo = @file.classes.first
bar = foo.modules.first
assert_equal ['section1', nil, 'section2', 'section2'], foo.attributes.map { |m| m.section.title }
assert_equal ['section1', nil, 'section2', 'section2'], foo.method_list.map { |m| m.section.title }
@@ -1973,7 +1973,7 @@ def m5; end
# :method: m6
end
RUBY
- klass = @top_level.classes.first
+ klass = @file.classes.first
assert_equal ['cat1', nil, nil, nil], klass.attributes.map { |m| m.section.title }
assert_equal [nil, 'cat2', nil, nil, 'cat3', 'cat4'], klass.method_list.map { |m| m.section.title }
end
@@ -1997,7 +1997,7 @@ def d; end
# :method: f
end
RUBY
- mod = @top_level.modules.first
+ mod = @file.modules.first
assert_equal ['a', 'f'], mod.method_list.map(&:name)
end
@@ -2039,7 +2039,7 @@ def ω() end
RUBY
util_parser content
assert_equal Encoding::UTF_8, content.encoding
- method = @top_level.classes.first.method_list.first
+ method = @file.classes.first.method_list.first
assert_equal 'comment ω', method.comment.text.strip
assert_equal 'ω', method.name
end
@@ -2053,7 +2053,7 @@ class Foo
add_my_method :foo
end
RUBY
- foo = @top_level.classes.first.method_list.first
+ foo = @file.classes.first.method_list.first
assert_equal 'foo', foo.name
assert_equal 'this is my method', foo.comment.text
assert_equal Encoding::CP852, foo.comment.text.encoding
@@ -2078,7 +2078,7 @@ def m
end
RUBY
- c = @top_level.classes.first
+ c = @file.classes.first
assert_equal 'rd', c.comment.format
assert_equal 'rd', c.method_list.first.comment.format
end
@@ -2096,7 +2096,7 @@ def m2; end
end
RUBY
- c = @top_level.classes.first
+ c = @file.classes.first
assert_equal 'rdoc', c.comment.format
@@ -2118,7 +2118,7 @@ class C
end
RUBY
- c = @top_level.classes.first
+ c = @file.classes.first
m = c.method_list.first
@@ -2131,7 +2131,7 @@ class C
list(:NOTE,
item(%w[field],
para('A field name.'))))
- expected.file = @top_level
+ expected.file = @file
assert_equal expected, m.comment.parse
end
@@ -2151,7 +2151,7 @@ def m1; end
def m2; end
end
RUBY
- klass = @top_level.classes.first
+ klass = @file.classes.first
m1, m2 = klass.method_list
assert_equal 'Public', m1.section.title
assert_equal 'Internal', m2.section.title
@@ -2183,7 +2183,7 @@ def m2; end
end
RUBY
- m1, m2 = @top_level.classes.first.method_list
+ m1, m2 = @file.classes.first.method_list
assert_equal "foo1\nbar1", m1.call_seq.chomp
assert_equal "ARGF.readlines(a)\nARGF.readlines(b)\nARGF.readlines(c)\nARGF.readlines(d)", m2.call_seq.chomp
end
@@ -2197,7 +2197,7 @@ def accept_legacy_bug?
end
def util_parser(content)
- @parser = RDoc::Parser::PrismRuby.new @top_level, content, @options, @stats
+ @parser = RDoc::Parser::PrismRuby.new @file, content, @options, @stats
@parser.scan
end
end
@@ -2211,7 +2211,7 @@ def accept_legacy_bug?
end
def util_parser(content)
- @parser = RDoc::Parser::Ruby.new @top_level, content, @options, @stats
+ @parser = RDoc::Parser::Ruby.new @file, content, @options, @stats
@parser.scan
end
end unless ENV['RDOC_USE_PRISM_PARSER']
diff --git a/test/rdoc/parser/rd_test.rb b/test/rdoc/parser/rd_test.rb
index d45b64b99a..55f2741bf0 100644
--- a/test/rdoc/parser/rd_test.rb
+++ b/test/rdoc/parser/rd_test.rb
@@ -11,7 +11,7 @@ def setup
@tempfile = Tempfile.new self.class.name
filename = @tempfile.path
- @top_level = @store.add_file filename
+ @file = @store.add_file filename
@fn = filename
@options = RDoc::Options.new
@stats = RDoc::Stats.new @store, 0
@@ -41,15 +41,15 @@ def test_scan
parser = util_parser 'it ((*really*)) works'
expected = doc(para('it really works'))
- expected.file = @top_level
+ expected.file = @file
parser.scan
- assert_equal expected, @top_level.comment.parse
+ assert_equal expected, @file.comment.parse
end
def util_parser(content)
- RDoc::Parser::RD.new @top_level, content, @options, @stats
+ RDoc::Parser::RD.new @file, content, @options, @stats
end
end
diff --git a/test/rdoc/parser/ruby_test.rb b/test/rdoc/parser/ruby_test.rb
index e4546b80db..968ee250a6 100644
--- a/test/rdoc/parser/ruby_test.rb
+++ b/test/rdoc/parser/ruby_test.rb
@@ -16,14 +16,14 @@ def setup
@tempfile2 = Tempfile.new self.class.name
@filename2 = @tempfile2.path
- @top_level = @store.add_file @filename
- @top_level2 = @store.add_file @filename2
+ @file = @store.add_file @filename
+ @file2 = @store.add_file @filename2
@options = RDoc::Options.new
@options.quiet = true
@options.option_parser = OptionParser.new
- @comment = RDoc::Comment.new '', @top_level
+ @comment = RDoc::Comment.new '', @file
@stats = RDoc::Stats.new @store, 0
end
@@ -45,7 +45,7 @@ class C; end
comment = p.collect_first_comment
- assert_equal RDoc::Comment.new("# first\n", @top_level), comment
+ assert_equal RDoc::Comment.new("# first\n", @file), comment
end
def test_collect_first_comment_encoding
@@ -75,7 +75,7 @@ class C; end
comment = parser.collect_first_comment
- assert_equal RDoc::Comment.new("first\n", @top_level), comment
+ assert_equal RDoc::Comment.new("first\n", @file), comment
end
def test_get_class_or_module
@@ -92,7 +92,7 @@ def test_get_class_or_module
b = @store.find_module_named('B')
assert_equal b, cont
- assert_equal [@top_level], b.in_files
+ assert_equal [@file], b.in_files
assert_equal 'C', name_t[:text]
assert_equal 'B::C', given_name
@@ -108,7 +108,7 @@ def test_get_class_or_module
end
def test_get_class_or_module_document_children
- ctxt = @top_level.add_class RDoc::NormalClass, 'A'
+ ctxt = @file.add_class RDoc::NormalClass, 'A'
ctxt.stop_doc
util_parser('B::C').get_class_or_module ctxt
@@ -116,7 +116,7 @@ def test_get_class_or_module_document_children
b = @store.find_module_named('A::B')
assert b.ignored?
- d = @top_level.add_class RDoc::NormalClass, 'A::D'
+ d = @file.add_class RDoc::NormalClass, 'A::D'
util_parser('D::E').get_class_or_module ctxt
@@ -172,7 +172,7 @@ def test_get_symbol_or_name
end
def test_suppress_parents
- a = @top_level.add_class RDoc::NormalClass, 'A'
+ a = @file.add_class RDoc::NormalClass, 'A'
b = a.add_class RDoc::NormalClass, 'B'
c = b.add_class RDoc::NormalClass, 'C'
@@ -186,9 +186,9 @@ def test_suppress_parents
end
def test_suppress_parents_documented
- a = @top_level.add_class RDoc::NormalClass, 'A'
+ a = @file.add_class RDoc::NormalClass, 'A'
b = a.add_class RDoc::NormalClass, 'B'
- b.add_comment RDoc::Comment.new("hello"), @top_level
+ b.add_comment RDoc::Comment.new("hello"), @file
c = b.add_class RDoc::NormalClass, 'C'
util_parser ''
@@ -203,21 +203,21 @@ def test_suppress_parents_documented
def test_look_for_directives_in_attr
util_parser ""
- comment = RDoc::Comment.new "# :attr: my_attr\n", @top_level
+ comment = RDoc::Comment.new "# :attr: my_attr\n", @file
- @parser.look_for_directives_in @top_level, comment
+ @parser.look_for_directives_in @file, comment
assert_equal "# :attr: my_attr\n", comment.text
- comment = RDoc::Comment.new "# :attr_reader: my_method\n", @top_level
+ comment = RDoc::Comment.new "# :attr_reader: my_method\n", @file
- @parser.look_for_directives_in @top_level, comment
+ @parser.look_for_directives_in @file, comment
assert_equal "# :attr_reader: my_method\n", comment.text
- comment = RDoc::Comment.new "# :attr_writer: my_method\n", @top_level
+ comment = RDoc::Comment.new "# :attr_writer: my_method\n", @file
- @parser.look_for_directives_in @top_level, comment
+ @parser.look_for_directives_in @file, comment
assert_equal "# :attr_writer: my_method\n", comment.text
end
@@ -225,14 +225,14 @@ def test_look_for_directives_in_attr
def test_look_for_directives_in_commented
util_parser ""
- comment = RDoc::Comment.new <<-COMMENT, @top_level
+ comment = RDoc::Comment.new <<-COMMENT, @file
# how to make a section:
# # :section: new section
COMMENT
- @parser.look_for_directives_in @top_level, comment
+ @parser.look_for_directives_in @file, comment
- section = @top_level.current_section
+ section = @file.current_section
assert_nil section.title
assert_nil section.comment
@@ -243,15 +243,15 @@ def test_look_for_directives_in_commented
def test_look_for_directives_in_method
util_parser ""
- comment = RDoc::Comment.new "# :method: my_method\n", @top_level
+ comment = RDoc::Comment.new "# :method: my_method\n", @file
- @parser.look_for_directives_in @top_level, comment
+ @parser.look_for_directives_in @file, comment
assert_equal "# :method: my_method\n", comment.text
- comment = RDoc::Comment.new "# :singleton-method: my_method\n", @top_level
+ comment = RDoc::Comment.new "# :singleton-method: my_method\n", @file
- @parser.look_for_directives_in @top_level, comment
+ @parser.look_for_directives_in @file, comment
assert_equal "# :singleton-method: my_method\n", comment.text
end
@@ -259,16 +259,16 @@ def test_look_for_directives_in_method
def test_look_for_directives_in_section
util_parser ""
- comment = RDoc::Comment.new <<-COMMENT, @top_level
+ comment = RDoc::Comment.new <<-COMMENT, @file
# :section: new section
# woo stuff
COMMENT
- @parser.look_for_directives_in @top_level, comment
+ @parser.look_for_directives_in @file, comment
- section = @top_level.current_section
+ section = @file.current_section
assert_equal 'new section', section.title
- assert_equal [comment("# woo stuff\n", @top_level)], section.comments
+ assert_equal [comment("# woo stuff\n", @file)], section.comments
assert_empty comment
end
@@ -276,18 +276,18 @@ def test_look_for_directives_in_section
def test_look_for_directives_in_unhandled
util_parser ""
- comment = RDoc::Comment.new "# :unhandled: blah\n", @top_level
+ comment = RDoc::Comment.new "# :unhandled: blah\n", @file
- @parser.look_for_directives_in @top_level, comment
+ @parser.look_for_directives_in @file, comment
- assert_equal 'blah', @top_level.metadata['unhandled']
+ assert_equal 'blah', @file.metadata['unhandled']
end
def test_parse_for_in
klass = RDoc::NormalClass.new 'Foo'
- klass.parent = @top_level
+ klass.parent = @file
- comment = RDoc::Comment.new '', @top_level
+ comment = RDoc::Comment.new '', @file
util_parser < 2, :char_no => 1, :kind => :on_comment,
- :text => "# File #{@top_level.relative_name}, line 2"
+ :text => "# File #{@file.relative_name}, line 2"
},
{ :line_no => 0, :char_no => 0, :kind => :on_nl, :text => "\n" },
{ :line_no => 1, :char_no => 1, :kind => :on_sp, :text => '' }
@@ -1377,7 +1377,7 @@ def test_parse_comment_method
def test_parse_comment_method_args
klass = RDoc::NormalClass.new 'Foo'
- klass.parent = @top_level
+ klass.parent = @file
util_parser "\n"
@@ -1394,10 +1394,10 @@ def test_parse_comment_method_args
def test_parse_comment_method_stopdoc
klass = RDoc::NormalClass.new 'Foo'
- klass.parent = @top_level
+ klass.parent = @file
klass.stop_doc
- comment = RDoc::Comment.new "##\n# :method: foo\n# my method\n", @top_level
+ comment = RDoc::Comment.new "##\n# :method: foo\n# my method\n", @file
util_parser "\n"
@@ -1409,7 +1409,7 @@ def test_parse_comment_method_stopdoc
end
def test_parse_constant
- klass = @top_level.add_class RDoc::NormalClass, 'Foo'
+ klass = @file.add_class RDoc::NormalClass, 'Foo'
util_parser "A = v"
@@ -1420,12 +1420,12 @@ def test_parse_constant
foo = klass.constants.first
assert_equal 'A', foo.name
- assert_equal @top_level, foo.file
+ assert_equal @file, foo.file
assert_equal 1, foo.line
end
def test_parse_constant_attrasgn
- klass = @top_level.add_class RDoc::NormalClass, 'Foo'
+ klass = @file.add_class RDoc::NormalClass, 'Foo'
util_parser "A[k] = v"
@@ -1437,7 +1437,7 @@ def test_parse_constant_attrasgn
end
def test_parse_constant_alias
- klass = @top_level.add_class RDoc::NormalClass, 'Foo'
+ klass = @file.add_class RDoc::NormalClass, 'Foo'
klass.add_class RDoc::NormalClass, 'B'
util_parser "A = B"
@@ -1453,8 +1453,8 @@ def test_parse_constant_alias
end
def test_parse_constant_alias_same_name
- foo = @top_level.add_class RDoc::NormalClass, 'Foo'
- @top_level.add_class RDoc::NormalClass, 'Bar'
+ foo = @file.add_class RDoc::NormalClass, 'Foo'
+ @file.add_class RDoc::NormalClass, 'Bar'
bar = foo.add_class RDoc::NormalClass, 'Bar'
assert @store.find_class_or_module('::Bar')
@@ -1469,7 +1469,7 @@ def test_parse_constant_alias_same_name
end
def test_parse_constant_in_method
- klass = @top_level.add_class RDoc::NormalClass, 'Foo'
+ klass = @file.add_class RDoc::NormalClass, 'Foo'
util_parser 'A::B = v'
@@ -1484,7 +1484,7 @@ def test_parse_constant_in_method
end
def test_parse_constant_rescue
- klass = @top_level.add_class RDoc::NormalClass, 'Foo'
+ klass = @file.add_class RDoc::NormalClass, 'Foo'
util_parser "A => e"
@@ -1500,7 +1500,7 @@ def test_parse_constant_rescue
end
def test_parse_constant_stopdoc
- klass = @top_level.add_class RDoc::NormalClass, 'Foo'
+ klass = @file.add_class RDoc::NormalClass, 'Foo'
klass.stop_doc
util_parser "A = v"
@@ -1521,11 +1521,11 @@ def test_parse_comment_nested
tk = @parser.get_tk
- parsed = @parser.parse_constant @top_level, tk, 'comment'
+ parsed = @parser.parse_constant @file, tk, 'comment'
assert parsed
- a = @top_level.find_module_named 'A'
+ a = @file.find_module_named 'A'
b = a.find_module_named 'B'
c = b.constants.first
@@ -1606,9 +1606,9 @@ class Klass3
def test_parse_extend_or_include_extend
klass = RDoc::NormalClass.new 'C'
- klass.parent = @top_level
+ klass.parent = @file
- comment = RDoc::Comment.new "# my extend\n", @top_level, :ruby
+ comment = RDoc::Comment.new "# my extend\n", @file, :ruby
util_parser "extend I"
@@ -1621,14 +1621,14 @@ def test_parse_extend_or_include_extend
ext = klass.extends.first
assert_equal 'I', ext.name
assert_equal 'my extend', ext.comment.text
- assert_equal @top_level, ext.file
+ assert_equal @file, ext.file
end
def test_parse_extend_or_include_include
klass = RDoc::NormalClass.new 'C'
- klass.parent = @top_level
+ klass.parent = @file
- comment = RDoc::Comment.new "# my include\n", @top_level, :ruby
+ comment = RDoc::Comment.new "# my include\n", @file, :ruby
util_parser "include I"
@@ -1641,14 +1641,14 @@ def test_parse_extend_or_include_include
incl = klass.includes.first
assert_equal 'I', incl.name
assert_equal 'my include', incl.comment.text
- assert_equal @top_level, incl.file
+ assert_equal @file, incl.file
end
def test_parse_meta_method
klass = RDoc::NormalClass.new 'Foo'
- klass.parent = @top_level
+ klass.parent = @file
- comment = RDoc::Comment.new "##\n# my method\n", @top_level, :ruby
+ comment = RDoc::Comment.new "##\n# my method\n", @file, :ruby
util_parser "add_my_method :foo, :bar\nadd_my_method :baz"
@@ -1659,7 +1659,7 @@ def test_parse_meta_method
foo = klass.method_list.first
assert_equal 'foo', foo.name
assert_equal 'my method', foo.comment.text
- assert_equal @top_level, foo.file
+ assert_equal @file, foo.file
assert_equal 1, foo.line
assert_equal [], foo.aliases
@@ -1681,7 +1681,7 @@ def test_parse_meta_method
stream = [
{
:line_no => 1, :char_no => 1, :kind => :on_comment,
- :text => "# File #{@top_level.relative_name}, line 1"
+ :text => "# File #{@file.relative_name}, line 1"
},
{ :line_no => 0, :char_no => 0, :kind => :on_nl, :text => "\n" },
{ :line_no => 1, :char_no => 1, :kind => :on_sp, :text => '' },
@@ -1707,9 +1707,9 @@ def test_parse_meta_method
def test_parse_meta_method_block
klass = RDoc::NormalClass.new 'Foo'
- klass.parent = @top_level
+ klass.parent = @file
- comment = RDoc::Comment.new "##\n# my method\n", @top_level
+ comment = RDoc::Comment.new "##\n# my method\n", @file
content = <<-CONTENT
inline(:my_method) do |*args|
@@ -1731,7 +1731,7 @@ def test_parse_meta_method_block
def test_parse_meta_method_define_method
klass = RDoc::NormalClass.new 'Foo'
- comment = RDoc::Comment.new "##\n# my method\n", @top_level, :ruby
+ comment = RDoc::Comment.new "##\n# my method\n", @file, :ruby
util_parser "define_method :foo do end"
@@ -1742,15 +1742,15 @@ def test_parse_meta_method_define_method
foo = klass.method_list.first
assert_equal 'foo', foo.name
assert_equal 'my method', foo.comment.text
- assert_equal @top_level, foo.file
+ assert_equal @file, foo.file
end
def test_parse_meta_method_name
klass = RDoc::NormalClass.new 'Foo'
- klass.parent = @top_level
+ klass.parent = @file
comment =
- RDoc::Comment.new "##\n# :method: woo_hoo!\n# my method\n", @top_level, :ruby
+ RDoc::Comment.new "##\n# :method: woo_hoo!\n# my method\n", @file, :ruby
util_parser "add_my_method :foo, :bar\nadd_my_method :baz"
@@ -1761,15 +1761,15 @@ def test_parse_meta_method_name
foo = klass.method_list.first
assert_equal 'woo_hoo!', foo.name
assert_equal 'my method', foo.comment.text
- assert_equal @top_level, foo.file
+ assert_equal @file, foo.file
end
def test_parse_meta_method_singleton
klass = RDoc::NormalClass.new 'Foo'
- klass.parent = @top_level
+ klass.parent = @file
comment =
- RDoc::Comment.new "##\n# :singleton-method:\n# my method\n", @top_level, :ruby
+ RDoc::Comment.new "##\n# :singleton-method:\n# my method\n", @file, :ruby
util_parser "add_my_method :foo, :bar\nadd_my_method :baz"
@@ -1781,16 +1781,16 @@ def test_parse_meta_method_singleton
assert_equal 'foo', foo.name
assert_equal true, foo.singleton, 'singleton method'
assert_equal 'my method', foo.comment.text
- assert_equal @top_level, foo.file
+ assert_equal @file, foo.file
end
def test_parse_meta_method_singleton_name
klass = RDoc::NormalClass.new 'Foo'
- klass.parent = @top_level
+ klass.parent = @file
comment =
RDoc::Comment.new "##\n# :singleton-method: woo_hoo!\n# my method\n",
- @top_level, :ruby
+ @file, :ruby
util_parser "add_my_method :foo, :bar\nadd_my_method :baz"
@@ -1802,12 +1802,12 @@ def test_parse_meta_method_singleton_name
assert_equal 'woo_hoo!', foo.name
assert_equal true, foo.singleton, 'singleton method'
assert_equal 'my method', foo.comment.text
- assert_equal @top_level, foo.file
+ assert_equal @file, foo.file
end
def test_parse_meta_method_string_name
klass = RDoc::NormalClass.new 'Foo'
- comment = RDoc::Comment.new "##\n# my method\n", @top_level, :ruby
+ comment = RDoc::Comment.new "##\n# my method\n", @file, :ruby
util_parser "add_my_method 'foo'"
@@ -1818,15 +1818,15 @@ def test_parse_meta_method_string_name
foo = klass.method_list.first
assert_equal 'foo', foo.name
assert_equal 'my method', foo.comment.text
- assert_equal @top_level, foo.file
+ assert_equal @file, foo.file
end
def test_parse_meta_method_stopdoc
klass = RDoc::NormalClass.new 'Foo'
- klass.parent = @top_level
+ klass.parent = @file
klass.stop_doc
- comment = RDoc::Comment.new "##\n# my method\n", @top_level
+ comment = RDoc::Comment.new "##\n# my method\n", @file
util_parser "add_my_method :foo, :bar\nadd_my_method :baz"
@@ -1839,7 +1839,7 @@ def test_parse_meta_method_stopdoc
def test_parse_meta_method_unknown
klass = RDoc::NormalClass.new 'Foo'
- comment = RDoc::Comment.new "##\n# my method\n", @top_level, :ruby
+ comment = RDoc::Comment.new "##\n# my method\n", @file, :ruby
util_parser "add_my_method ('foo')"
@@ -1850,14 +1850,14 @@ def test_parse_meta_method_unknown
foo = klass.method_list.first
assert_equal 'unknown', foo.name
assert_equal 'my method', foo.comment.text
- assert_equal @top_level, foo.file
+ assert_equal @file, foo.file
end
def test_parse_method
klass = RDoc::NormalClass.new 'Foo'
- klass.parent = @top_level
+ klass.parent = @file
- comment = RDoc::Comment.new "##\n# my method\n", @top_level, :ruby
+ comment = RDoc::Comment.new "##\n# my method\n", @file, :ruby
util_parser "def foo() :bar end"
@@ -1868,7 +1868,7 @@ def test_parse_method
foo = klass.method_list.first
assert_equal 'foo', foo.name
assert_equal 'my method', foo.comment.text
- assert_equal @top_level, foo.file
+ assert_equal @file, foo.file
assert_equal 1, foo.line
assert_equal [], foo.aliases
@@ -1890,7 +1890,7 @@ def test_parse_method
stream = [
{
:line_no => 1, :char_no => 1, :kind => :on_comment,
- :text => "# File #{@top_level.relative_name}, line 1" },
+ :text => "# File #{@file.relative_name}, line 1" },
{ :line_no => 0, :char_no => 0, :kind => :on_nl, :text => "\n" },
{ :line_no => 1, :char_no => 1, :kind => :on_sp, :text => '' },
{ :line_no => 1, :char_no => 0, :kind => :on_kw, :text => 'def' },
@@ -1916,9 +1916,9 @@ def test_parse_method
def test_parse_redefinable_methods
klass = RDoc::NormalClass.new 'Foo'
- klass.parent = @top_level
+ klass.parent = @file
- comment = RDoc::Comment.new "", @top_level
+ comment = RDoc::Comment.new "", @file
redefinable_ops = %w[| ^ & <=> == === =~ > >= < <= << >> + - * / % ** ~ +@ -@ [] []= ` ! != !~]
redefinable_ops.each do |redefinable_op|
@@ -1979,7 +1979,7 @@ def self.[]=; end
def test_parse_method_alias
klass = RDoc::NormalClass.new 'Foo'
- klass.parent = @top_level
+ klass.parent = @file
util_parser "def m() alias a b; end"
@@ -1992,7 +1992,7 @@ def test_parse_method_alias
def test_parse_method_ampersand
klass = RDoc::NormalClass.new 'Foo'
- klass.parent = @top_level
+ klass.parent = @file
util_parser "def self.&\nend"
@@ -2007,7 +2007,7 @@ def test_parse_method_ampersand
def test_parse_method_constant
c = RDoc::Constant.new 'CONST', nil, ''
- m = @top_level.add_class RDoc::NormalModule, 'M'
+ m = @file.add_class RDoc::NormalModule, 'M'
m.add_constant c
util_parser "def CONST.m() end"
@@ -2025,7 +2025,7 @@ def test_parse_method_false
tk = @parser.get_tk
- @parser.parse_method @top_level, RDoc::Parser::Ruby::NORMAL, tk, @comment
+ @parser.parse_method @file, RDoc::Parser::Ruby::NORMAL, tk, @comment
klass = @store.find_class_named 'FalseClass'
@@ -2035,7 +2035,7 @@ def test_parse_method_false
def test_parse_method_funky
klass = RDoc::NormalClass.new 'Foo'
- klass.parent = @top_level
+ klass.parent = @file
util_parser "def (blah).foo() :bar end"
@@ -2051,9 +2051,9 @@ def test_parse_method_gvar
tk = @parser.get_tk
- @parser.parse_method @top_level, RDoc::Parser::Ruby::NORMAL, tk, @comment
+ @parser.parse_method @file, RDoc::Parser::Ruby::NORMAL, tk, @comment
- assert @top_level.method_list.empty?
+ assert @file.method_list.empty?
end
def test_parse_method_gvar_insane
@@ -2061,9 +2061,9 @@ def test_parse_method_gvar_insane
tk = @parser.get_tk
- @parser.parse_method @top_level, RDoc::Parser::Ruby::NORMAL, tk, @comment
+ @parser.parse_method @file, RDoc::Parser::Ruby::NORMAL, tk, @comment
- assert @top_level.method_list.empty?
+ assert @file.method_list.empty?
assert_empty @store.all_classes
@@ -2074,7 +2074,7 @@ def test_parse_method_gvar_insane
def test_parse_method_internal_gvar
klass = RDoc::NormalClass.new 'Foo'
- klass.parent = @top_level
+ klass.parent = @file
util_parser "def foo() def $blah.bar() end end"
@@ -2087,7 +2087,7 @@ def test_parse_method_internal_gvar
def test_parse_method_internal_ivar
klass = RDoc::NormalClass.new 'Foo'
- klass.parent = @top_level
+ klass.parent = @file
util_parser "def foo() def @blah.bar() end end"
@@ -2100,7 +2100,7 @@ def test_parse_method_internal_ivar
def test_parse_method_internal_lvar
klass = RDoc::NormalClass.new 'Foo'
- klass.parent = @top_level
+ klass.parent = @file
util_parser "def foo() def blah.bar() end end"
@@ -2116,7 +2116,7 @@ def test_parse_method_nil
tk = @parser.get_tk
- @parser.parse_method @top_level, RDoc::Parser::Ruby::NORMAL, tk, @comment
+ @parser.parse_method @file, RDoc::Parser::Ruby::NORMAL, tk, @comment
klass = @store.find_class_named 'NilClass'
@@ -2126,7 +2126,7 @@ def test_parse_method_nil
def test_parse_method_nodoc
klass = RDoc::NormalClass.new 'Foo'
- klass.parent = @top_level
+ klass.parent = @file
util_parser "def foo # :nodoc:\nend"
@@ -2139,7 +2139,7 @@ def test_parse_method_nodoc
def test_parse_method_nodoc_track
klass = RDoc::NormalClass.new 'Foo'
- klass.parent = @top_level
+ klass.parent = @file
@options.visibility = :nodoc
@@ -2154,7 +2154,7 @@ def test_parse_method_nodoc_track
def test_parse_method_no_parens
klass = RDoc::NormalClass.new 'Foo'
- klass.parent = @top_level
+ klass.parent = @file
util_parser "def foo arg1, arg2 = {}\nend"
@@ -2164,12 +2164,12 @@ def test_parse_method_no_parens
foo = klass.method_list.first
assert_equal '(arg1, arg2 = {})', foo.params
- assert_equal @top_level, foo.file
+ assert_equal @file, foo.file
end
def test_parse_method_parameters_comment
klass = RDoc::NormalClass.new 'Foo'
- klass.parent = @top_level
+ klass.parent = @file
util_parser "def foo arg1, arg2 # some useful comment\nend"
@@ -2183,7 +2183,7 @@ def test_parse_method_parameters_comment
def test_parse_method_parameters_comment_continue
klass = RDoc::NormalClass.new 'Foo'
- klass.parent = @top_level
+ klass.parent = @file
util_parser "def foo arg1, arg2, # some useful comment\narg3\nend"
@@ -2197,7 +2197,7 @@ def test_parse_method_parameters_comment_continue
def test_parse_method_parameters_with_paren_comment_continue
klass = RDoc::NormalClass.new 'Foo'
- klass.parent = @top_level
+ klass.parent = @file
util_parser "def foo(arg1, arg2, # some useful comment\narg3)\nend"
@@ -2211,7 +2211,7 @@ def test_parse_method_parameters_with_paren_comment_continue
def test_parse_method_star
klass = RDoc::NormalClass.new 'Foo'
- klass.parent = @top_level
+ klass.parent = @file
util_parser "def self.*\nend"
@@ -2226,10 +2226,10 @@ def test_parse_method_star
def test_parse_method_stopdoc
klass = RDoc::NormalClass.new 'Foo'
- klass.parent = @top_level
+ klass.parent = @file
klass.stop_doc
- comment = RDoc::Comment.new "##\n# my method\n", @top_level
+ comment = RDoc::Comment.new "##\n# my method\n", @file
util_parser "def foo() :bar end"
@@ -2241,7 +2241,7 @@ def test_parse_method_stopdoc
end
def test_parse_method_toplevel
- klass = @top_level
+ klass = @file
util_parser "def foo arg1, arg2\nend"
@@ -2253,11 +2253,11 @@ def test_parse_method_toplevel
foo = object.method_list.first
assert_equal 'Object#foo', foo.full_name
- assert_equal @top_level, foo.file
+ assert_equal @file, foo.file
end
def test_parse_method_toplevel_class
- klass = @top_level
+ klass = @file
util_parser "def Object.foo arg1, arg2\nend"
@@ -2276,7 +2276,7 @@ def test_parse_method_true
tk = @parser.get_tk
- @parser.parse_method @top_level, RDoc::Parser::Ruby::NORMAL, tk, @comment
+ @parser.parse_method @file, RDoc::Parser::Ruby::NORMAL, tk, @comment
klass = @store.find_class_named 'TrueClass'
@@ -2286,7 +2286,7 @@ def test_parse_method_true
def test_parse_method_utf8
klass = RDoc::NormalClass.new 'Foo'
- klass.parent = @top_level
+ klass.parent = @file
method = "def ω() end"
@@ -2305,7 +2305,7 @@ def test_parse_method_utf8
def test_parse_method_dummy
util_parser ".method() end"
- @parser.parse_method_dummy @top_level
+ @parser.parse_method_dummy @file
assert_nil @parser.get_tk
end
@@ -2332,9 +2332,9 @@ def blah
end
CODE
- @parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL, nil
+ @parser.parse_statements @file, RDoc::Parser::Ruby::NORMAL, nil
- foo = @top_level.modules.first
+ foo = @file.modules.first
assert_equal 'Foo', foo.full_name, 'module Foo'
methods = foo.method_list
@@ -2355,9 +2355,9 @@ def bar
end
CODE
- @parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL, nil
+ @parser.parse_statements @file, RDoc::Parser::Ruby::NORMAL, nil
- c = @top_level.classes.first
+ c = @file.classes.first
assert_equal 'C', c.full_name, 'class C'
methods = c.method_list
@@ -2380,9 +2380,9 @@ class C
end
CODE
- @parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL, nil
+ @parser.parse_statements @file, RDoc::Parser::Ruby::NORMAL, nil
- a = @top_level.classes.first
+ a = @file.classes.first
assert_equal 'A', a.full_name, 'class A'
assert_equal 2, a.classes.length
b = a.classes[0]
@@ -2392,13 +2392,13 @@ class C
end
def test_parse_statements_class_nested
- comment = RDoc::Comment.new "##\n# my method\n", @top_level
+ comment = RDoc::Comment.new "##\n# my method\n", @file
util_parser "module Foo\n#{comment.text}class Bar\nend\nend"
- @parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL
+ @parser.parse_statements @file, RDoc::Parser::Ruby::NORMAL
- foo = @top_level.modules.first
+ foo = @file.modules.first
assert_equal 'Foo', foo.full_name, 'module Foo'
bar = foo.classes.first
@@ -2409,9 +2409,9 @@ def test_parse_statements_class_nested
def test_parse_statements_def_percent_string_pound
util_parser "class C\ndef a\n%r{#}\n%r{\#{}}\nend\ndef b() end\nend"
- @parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL
+ @parser.parse_statements @file, RDoc::Parser::Ruby::NORMAL
- x = @top_level.classes.first
+ x = @file.classes.first
assert_equal 2, x.method_list.length
a = x.method_list.first
@@ -2459,16 +2459,16 @@ class Foo
util_parser content
- @parser.parse_statements @top_level
+ @parser.parse_statements @file
- foo = @top_level.classes.first.method_list.first
+ foo = @file.classes.first.method_list.first
assert_equal 'foo', foo.name
assert_equal 'this is my method', foo.comment.text
assert_equal Encoding::CP852, foo.comment.text.encoding
end
def test_parse_statements_enddoc
- klass = @top_level.add_class RDoc::NormalClass, 'Foo'
+ klass = @file.add_class RDoc::NormalClass, 'Foo'
util_parser "\n# :enddoc:"
@@ -2481,7 +2481,7 @@ def test_parse_statements_enddoc_top_level
util_parser "\n# :enddoc:"
assert_throws :eof do
- @parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL, nil
+ @parser.parse_statements @file, RDoc::Parser::Ruby::NORMAL, nil
end
end
@@ -2496,9 +2496,9 @@ class Foo
util_parser content
- @parser.parse_statements @top_level
+ @parser.parse_statements @file
- foo = @top_level.classes.first.method_list.first
+ foo = @file.classes.first.method_list.first
assert_equal 'foo', foo.name
end
@@ -2512,15 +2512,15 @@ def foo() end
util_parser content
- @parser.parse_statements @top_level
+ @parser.parse_statements @file
- foo = @top_level.classes.first.method_list[0]
+ foo = @file.classes.first.method_list[0]
assert_equal 'foo', foo.name
- foo2 = @top_level.classes.first.method_list.last
+ foo2 = @file.classes.first.method_list.last
assert_equal 'foo2', foo2.name
assert_equal 'foo', foo2.is_alias_for.name
- assert @top_level.classes.first.aliases.empty?
+ assert @file.classes.first.aliases.empty?
end
def test_parse_statements_identifier_alias_method_before_original_method
@@ -2545,24 +2545,24 @@ def foo()
util_parser content
- @parser.parse_statements @top_level
+ @parser.parse_statements @file
- foo = @top_level.classes.first.method_list[0]
+ foo = @file.classes.first.method_list[0]
assert_equal 'foo', foo.name
- foo2 = @top_level.classes.first.method_list[1]
+ foo2 = @file.classes.first.method_list[1]
assert_equal 'foo2', foo2.name
assert_equal 'foo', foo2.is_alias_for.name
- foo3 = @top_level.classes.first.method_list[2]
+ foo3 = @file.classes.first.method_list[2]
assert_equal 'foo3', foo3.name
assert_equal 'foo', foo3.is_alias_for.name
- foo4 = @top_level.classes.first.method_list.last
+ foo4 = @file.classes.first.method_list.last
assert_equal 'foo4', foo4.name
assert_equal 'foo', foo4.is_alias_for.name
- assert_equal 'unknown', @top_level.classes.first.external_aliases[0].old_name
+ assert_equal 'unknown', @file.classes.first.external_aliases[0].old_name
end
def test_parse_statements_identifier_args
@@ -2570,9 +2570,9 @@ def test_parse_statements_identifier_args
util_parser "module M\n#{comment}def_delegator :a, :b, :b\nend"
- @parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL
+ @parser.parse_statements @file, RDoc::Parser::Ruby::NORMAL
- m = @top_level.modules.first
+ m = @file.modules.first
assert_equal 'M', m.full_name
b = m.method_list.first
@@ -2631,51 +2631,51 @@ class Foo
util_parser content
- @parser.parse_statements @top_level
+ @parser.parse_statements @file
- constants = @top_level.classes.first.constants
+ constants = @file.classes.first.constants
constant = constants[0]
assert_equal 'FIRST_CONSTANT', constant.name
assert_equal '5', constant.value
- assert_equal @top_level, constant.file
+ assert_equal @file, constant.file
constant = constants[1]
assert_equal 'SECOND_CONSTANT', constant.name
assert_equal "[\n1,\n2,\n3\n]", constant.value
- assert_equal @top_level, constant.file
+ assert_equal @file, constant.file
constant = constants[2]
assert_equal 'THIRD_CONSTANT', constant.name
assert_equal "{\n:foo => 'bar',\n:x => 'y'\n}", constant.value
- assert_equal @top_level, constant.file
+ assert_equal @file, constant.file
constant = constants[3]
assert_equal 'FOURTH_CONSTANT', constant.name
assert_equal "SECOND_CONSTANT.map do |element|\nelement + 1\nelement + 2\nend", constant.value
- assert_equal @top_level, constant.file
+ assert_equal @file, constant.file
constant = constants[4]
assert_equal 'FIFTH_CONSTANT', constant.name
assert_equal 'SECOND_CONSTANT.map { |element| element + 1 }', constant.value
- assert_equal @top_level, constant.file
+ assert_equal @file, constant.file
# TODO: parse as class
constant = constants[5]
assert_equal 'SIXTH_CONSTANT', constant.name
assert_equal sixth_constant.lines.map(&:strip).join("\n"), constant.value
- assert_equal @top_level, constant.file
+ assert_equal @file, constant.file
# TODO: parse as method
constant = constants[6]
assert_equal 'SEVENTH_CONSTANT', constant.name
assert_equal "proc { |i| begin i end }", constant.value
- assert_equal @top_level, constant.file
+ assert_equal @file, constant.file
constant = constants[7]
assert_equal 'EIGHTH_CONSTANT', constant.name
assert_equal "\"a\" \\\n\"b\"", constant.value
- assert_equal @top_level, constant.file
+ assert_equal @file, constant.file
end
def test_parse_statements_identifier_attr
@@ -2683,9 +2683,9 @@ def test_parse_statements_identifier_attr
util_parser content
- @parser.parse_statements @top_level
+ @parser.parse_statements @file
- foo = @top_level.classes.first.attributes.first
+ foo = @file.classes.first.attributes.first
assert_equal 'foo', foo.name
assert_equal 'R', foo.rw
end
@@ -2695,9 +2695,9 @@ def test_parse_statements_identifier_attr_accessor
util_parser content
- @parser.parse_statements @top_level
+ @parser.parse_statements @file
- foo = @top_level.classes.first.attributes.first
+ foo = @file.classes.first.attributes.first
assert_equal 'foo', foo.name
assert_equal 'RW', foo.rw
end
@@ -2714,8 +2714,8 @@ class C
end
RUBY
- @parser.parse_statements @top_level
- c = @top_level.classes.first
+ @parser.parse_statements @file
+ c = @file.classes.first
assert_equal %w[a b], c.method_list.map { |m| m.name }
end
@@ -2725,9 +2725,9 @@ def test_parse_statements_identifier_include
util_parser content
- @parser.parse_statements @top_level
+ @parser.parse_statements @file
- foo = @top_level.classes.first
+ foo = @file.classes.first
assert_equal 'Foo', foo.name
assert_equal 1, foo.includes.length
end
@@ -2737,9 +2737,9 @@ def test_parse_statements_identifier_module_function
util_parser content
- @parser.parse_statements @top_level
+ @parser.parse_statements @file
- foo, s_foo = @top_level.modules.first.method_list
+ foo, s_foo = @file.modules.first.method_list
assert_equal 'foo', foo.name, 'instance method name'
assert_equal :private, foo.visibility, 'instance method visibility'
assert_equal false, foo.singleton, 'instance method singleton'
@@ -2754,9 +2754,9 @@ def test_parse_statements_identifier_private
util_parser content
- @parser.parse_statements @top_level
+ @parser.parse_statements @file
- foo = @top_level.classes.first.method_list.first
+ foo = @file.classes.first.method_list.first
assert_equal 'foo', foo.name
assert_equal :private, foo.visibility
end
@@ -2775,9 +2775,9 @@ class DateTime < Date
util_parser content
- @parser.parse_statements @top_level
+ @parser.parse_statements @file
- date, date_time = @top_level.classes.sort_by { |c| c.full_name }
+ date, date_time = @file.classes.sort_by { |c| c.full_name }
date_now = date.method_list.first
date_time_now = date_time.method_list.sort_by { |m| m.full_name }.first
@@ -2800,10 +2800,10 @@ class DateTime < Date
util_parser content
- @parser.parse_statements @top_level
+ @parser.parse_statements @file
# TODO sort classes by default
- date, date_time = @top_level.classes.sort_by { |c| c.full_name }
+ date, date_time = @file.classes.sort_by { |c| c.full_name }
date_now = date.method_list.first
date_time_now = date_time.method_list.sort_by { |m| m.full_name }.first
@@ -2836,7 +2836,7 @@ def blah()
@parser.scan
- foo = @top_level.classes.first
+ foo = @file.classes.first
assert_equal 'Foo', foo.full_name
blah = foo.method_list.first
@@ -2859,7 +2859,7 @@ def self.& end
@parser.scan
- foo = @top_level.classes.first
+ foo = @file.classes.first
assert_equal 'Foo', foo.full_name
blah = foo.method_list.first
@@ -2888,7 +2888,7 @@ def blah()
@parser.scan
- foo = @top_level.classes.first
+ foo = @file.classes.first
assert_equal 'Foo', foo.full_name
blah = foo.method_list.first
@@ -2917,7 +2917,7 @@ def blah()
@parser.scan
- foo = @top_level.classes.first
+ foo = @file.classes.first
assert_equal 'Foo', foo.full_name
blah = foo.method_list.first
@@ -2928,15 +2928,15 @@ def blah()
def test_parse_heredoc_end
code = "A = < true or false
@@ -53,7 +53,7 @@ def test_extract_call_seq
end
def test_extract_call_seq_blank
- comment = RDoc::Comment.new <<-COMMENT, @top_level
+ comment = RDoc::Comment.new <<-COMMENT, @file
call-seq:
bla => true or false
@@ -63,7 +63,7 @@ def test_extract_call_seq_blank
end
def test_extract_call_seq_commented
- comment = RDoc::Comment.new <<-COMMENT, @top_level
+ comment = RDoc::Comment.new <<-COMMENT, @file
# call-seq:
# bla => true or false
#
@@ -74,7 +74,7 @@ def test_extract_call_seq_commented
end
def test_extract_call_seq_no_blank
- comment = RDoc::Comment.new <<-COMMENT, @top_level
+ comment = RDoc::Comment.new <<-COMMENT, @file
call-seq:
bla => true or false
COMMENT
@@ -83,7 +83,7 @@ def test_extract_call_seq_no_blank
end
def test_extract_call_seq_undent
- comment = RDoc::Comment.new <<-COMMENT, @top_level
+ comment = RDoc::Comment.new <<-COMMENT, @file
call-seq:
bla => true or false
moar comment
@@ -217,7 +217,7 @@ def test_initialize_copy
end
def test_location
- assert_equal @top_level, @comment.location
+ assert_equal @file, @comment.location
end
def test_normalize
@@ -274,7 +274,7 @@ def test_text_equals
end
def test_text_equals_no_text
- c = RDoc::Comment.new nil, @top_level
+ c = RDoc::Comment.new nil, @file
c.document = @RM::Document.new
e = assert_raise RDoc::Error do
@@ -306,26 +306,26 @@ def test_parse
expected = @RM::Document.new(
@RM::Paragraph.new('this is a comment'))
- expected.file = @top_level
+ expected.file = @file
assert_equal expected, parsed
assert_same parsed, @comment.parse
end
def test_parse_rd
- c = comment 'it ((*works*))'
+ c = comment 'it ((*works*))', @file
c.format = 'rd'
expected =
@RM::Document.new(
@RM::Paragraph.new('it works '))
- expected.file = @top_level
+ expected.file = @file
assert_equal expected, c.parse
end
def test_remove_private_encoding
- comment = RDoc::Comment.new <<-EOS, @top_level
+ comment = RDoc::Comment.new <<-EOS, @file
# This is text
#--
# this is private
@@ -352,13 +352,13 @@ def test_remove_private_hash
end
def test_remove_private_hash_trail
- comment = RDoc::Comment.new <<-EOS, @top_level
+ comment = RDoc::Comment.new <<-EOS, @file
# This is text
#--
# this is private
EOS
- expected = RDoc::Comment.new <<-EOS, @top_level
+ expected = RDoc::Comment.new <<-EOS, @file
# This is text
EOS
@@ -368,14 +368,14 @@ def test_remove_private_hash_trail
end
def test_remove_private_long
- comment = RDoc::Comment.new <<-EOS, @top_level
+ comment = RDoc::Comment.new <<-EOS, @file
#-----
#++
# this is text
#-----
EOS
- expected = RDoc::Comment.new <<-EOS, @top_level
+ expected = RDoc::Comment.new <<-EOS, @file
# this is text
EOS
@@ -385,7 +385,7 @@ def test_remove_private_long
end
def test_remove_private_rule
- comment = RDoc::Comment.new <<-EOS, @top_level
+ comment = RDoc::Comment.new <<-EOS, @file
# This is text with a rule:
# ---
# this is also text
@@ -428,7 +428,7 @@ def test_remove_private_star2
end
def test_remove_private_toggle
- comment = RDoc::Comment.new <<-EOS, @top_level
+ comment = RDoc::Comment.new <<-EOS, @file
# This is text
#--
# this is private
@@ -436,7 +436,7 @@ def test_remove_private_toggle
# This is text again.
EOS
- expected = RDoc::Comment.new <<-EOS, @top_level
+ expected = RDoc::Comment.new <<-EOS, @file
# This is text
# This is text again.
EOS
@@ -447,7 +447,7 @@ def test_remove_private_toggle
end
def test_remove_private_toggle_encoding
- comment = RDoc::Comment.new <<-EOS, @top_level
+ comment = RDoc::Comment.new <<-EOS, @file
# This is text
#--
# this is private
@@ -463,7 +463,7 @@ def test_remove_private_toggle_encoding
end
def test_remove_private_toggle_encoding_ruby_bug?
- comment = RDoc::Comment.new <<-EOS, @top_level
+ comment = RDoc::Comment.new <<-EOS, @file
#--
# this is private
#++
diff --git a/test/rdoc/rdoc_context_section_test.rb b/test/rdoc/rdoc_context_section_test.rb
index 179ea95014..2890ea1124 100644
--- a/test/rdoc/rdoc_context_section_test.rb
+++ b/test/rdoc/rdoc_context_section_test.rb
@@ -6,12 +6,12 @@ class RDocContextSectionTest < RDoc::TestCase
def setup
super
- @top_level = @store.add_file 'file.rb'
+ @file = @store.add_file 'file.rb'
- @klass = @top_level.add_class RDoc::NormalClass, 'Object'
+ @klass = @file.add_class RDoc::NormalClass, 'Object'
@S = RDoc::Context::Section
- @s = @S.new @klass, 'section', comment('# comment', @top_level, :ruby)
+ @s = @S.new @klass, 'section', comment('# comment', @file, :ruby)
end
def test_add_comment
@@ -49,7 +49,7 @@ def test_aref
end
def test_eql_eh
- other = @S.new @klass, 'other', comment('# comment', @top_level)
+ other = @S.new @klass, 'other', comment('# comment', @file)
assert @s.eql? @s
assert @s.eql? @s.dup
@@ -57,7 +57,7 @@ def test_eql_eh
end
def test_equals
- other = @S.new @klass, 'other', comment('# comment', @top_level)
+ other = @S.new @klass, 'other', comment('# comment', @file)
assert_equal @s, @s
assert_equal @s, @s.dup
@@ -73,7 +73,7 @@ def test_extract_comment
end
def test_hash
- other = @S.new @klass, 'other', comment('# comment', @top_level)
+ other = @S.new @klass, 'other', comment('# comment', @file)
assert_equal @s.hash, @s.hash
assert_equal @s.hash, @s.dup.hash
@@ -83,7 +83,7 @@ def test_hash
def test_marshal_dump
loaded = Marshal.load Marshal.dump @s
- expected = doc RDoc::Comment.new('comment', @top_level).parse
+ expected = doc RDoc::Comment.new('comment', @file).parse
assert_equal 'section', loaded.title
assert_equal expected, loaded.parse
@@ -109,7 +109,7 @@ def test_marshal_load_version_0
"[\x06I\"\fcomment\x06;\x06F:\n@fileI" +
"\"\ffile.rb\x06;\x06F;\n0"
- expected = doc RDoc::Comment.new('comment', @top_level).parse
+ expected = doc RDoc::Comment.new('comment', @file).parse
assert_equal 'section', loaded.title
assert_equal expected, loaded.parse
@@ -123,7 +123,7 @@ def test_remove_comment_array
@s.add_comment other_comment
- @s.remove_comment comment('bogus', @top_level)
+ @s.remove_comment comment('bogus', @file)
assert_equal [other_comment], @s.comments
end
@@ -137,7 +137,7 @@ def test_remove_comment_document
loaded = Marshal.load Marshal.dump @s
- loaded.remove_comment comment('bogus', @top_level)
+ loaded.remove_comment comment('bogus', @file)
assert_equal doc(other_comment.parse), loaded.parse
end
diff --git a/test/rdoc/rdoc_context_test.rb b/test/rdoc/rdoc_context_test.rb
index a6ad176218..318e2f68dc 100644
--- a/test/rdoc/rdoc_context_test.rb
+++ b/test/rdoc/rdoc_context_test.rb
@@ -48,12 +48,12 @@ def test_add
end
def test_add_alias_method_attr
- top_level = @store.add_file 'file.rb'
+ file = @store.add_file 'file.rb'
attr = RDoc::Attr.new nil, 'old_name', 'R', ''
as = RDoc::Alias.new nil, 'old_name', 'new_name', 'comment'
- as.record_location top_level
+ as.record_location file
as.parent = @context
@context.add_attribute attr
@@ -64,17 +64,17 @@ def test_add_alias_method_attr
assert_equal %w[old_name new_name], @context.attributes.map { |m| m.name }
new = @context.attributes.last
- assert_equal top_level, new.file
+ assert_equal file, new.file
end
def test_add_alias_method
- top_level = @store.add_file 'file.rb'
+ file = @store.add_file 'file.rb'
meth = RDoc::AnyMethod.new nil, 'old_name'
meth.singleton = false
as = RDoc::Alias.new nil, 'old_name', 'new_name', 'comment'
- as.record_location top_level
+ as.record_location file
as.parent = @context
@context.add_method meth
@@ -85,7 +85,7 @@ def test_add_alias_method
assert_equal %w[old_name new_name], @context.method_list.map { |m| m.name }
new = @context.method_list.last
- assert_equal top_level, new.file
+ assert_equal file, new.file
end
def test_add_alias_method_singleton
@@ -166,9 +166,9 @@ def test_add_class_upgrade
'c1 modules'
assert_includes @store.all_classes.map { |k| k.full_name }, 'C1::Klass',
- 'TopLevel classes'
+ 'File classes'
refute_includes @store.all_modules.map { |k| k.full_name }, 'C1::Klass',
- 'TopLevel modules'
+ 'File modules'
end
def test_add_constant
@@ -290,15 +290,15 @@ def test_add_module_alias
def test_add_module_alias_top_level
store = RDoc::Store.new(RDoc::Options.new)
- top_level = store.add_file 'file.rb'
+ file = store.add_file 'file.rb'
- klass = top_level.add_class RDoc::NormalClass, 'Klass'
+ klass = file.add_class RDoc::NormalClass, 'Klass'
klass.comment = 'klass comment'
- object = top_level.add_class RDoc::NormalClass, 'Object'
+ object = file.add_class RDoc::NormalClass, 'Object'
a = RDoc::Constant.new 'A', '', ''
- top_level.add_module_alias klass, klass.name, a, top_level
+ file.add_module_alias klass, klass.name, a, file
refute_empty object.constants
@@ -320,26 +320,26 @@ def test_add_require
@c1.add_require req
assert_empty @c1.requires
- assert_includes @c1.top_level.requires, req
+ assert_includes @c1.file_context.requires, req
end
def test_add_section
default_section = @context.sections.first
- @context.add_section nil, comment('comment', @top_level)
+ @context.add_section nil, comment('comment', @file)
assert_equal 1, @context.sections.length
- assert_equal [comment("comment", @top_level)],
+ assert_equal [comment("comment", @file)],
@context.sections.first.comments
- @context.add_section nil, comment('new comment', @top_level)
+ @context.add_section nil, comment('new comment', @file)
assert_equal 1, @context.sections.length
- assert_equal [comment('comment', @top_level),
- comment('new comment', @top_level)],
+ assert_equal [comment('comment', @file),
+ comment('new comment', @file)],
@context.sections.first.comments
- @context.add_section 'other', comment('', @top_level)
+ @context.add_section 'other', comment('', @file)
assert_equal 2, @context.sections.length
@@ -379,7 +379,7 @@ def test_add_to_temporary_section
incl = RDoc::Include.new 'Name', 'comment'
arr = []
section =
- @context.add_section 'temporary', RDoc::Comment.new('', @top_level)
+ @context.add_section 'temporary', RDoc::Comment.new('', @file)
@context.temporary_section = section
@context.add_to arr, incl
@@ -430,7 +430,7 @@ def test_current_section
default_section = @context.current_section
new_section =
- @context.add_section 'other', RDoc::Comment.new('', @top_level)
+ @context.add_section 'other', RDoc::Comment.new('', @file)
@context.temporary_section = new_section
assert_equal new_section, @context.current_section
@@ -850,11 +850,11 @@ def test_section_contents_unused
def test_set_current_section
default_section = @context.sections.first
- @context.set_current_section nil, RDoc::Comment.new('', @top_level)
+ @context.set_current_section nil, RDoc::Comment.new('', @file)
assert_equal default_section, @context.current_section
- @context.set_current_section 'other', RDoc::Comment.new('', @top_level)
+ @context.set_current_section 'other', RDoc::Comment.new('', @file)
new_section = @context.sections.find { |section|
section != default_section
diff --git a/test/rdoc/rdoc_cross_reference_test.rb b/test/rdoc/rdoc_cross_reference_test.rb
index e536a67a89..599a7c740a 100644
--- a/test/rdoc/rdoc_cross_reference_test.rb
+++ b/test/rdoc/rdoc_cross_reference_test.rb
@@ -115,7 +115,7 @@ def test_resolve_class
end
def test_resolve_file
- assert_ref @top_level, 'xref_data.rb'
+ assert_ref @file, 'xref_data.rb'
end
def test_resolve_method
diff --git a/test/rdoc/rdoc_encoding_test.rb b/test/rdoc/rdoc_encoding_test.rb
index 4a264f5efb..54bce5838a 100644
--- a/test/rdoc/rdoc_encoding_test.rb
+++ b/test/rdoc/rdoc_encoding_test.rb
@@ -86,7 +86,7 @@ def test_class_read_file_encoding_force_transcode
end
def test_class_read_file_encoding_guess
- path = File.expand_path '../test.ja.txt', __FILE__
+ path = ::File.expand_path '../test.ja.txt', __FILE__
content = RDoc::Encoding.read_file path, Encoding::UTF_8
assert_equal Encoding::UTF_8, content.encoding
diff --git a/test/rdoc/rdoc_top_level_test.rb b/test/rdoc/rdoc_file_test.rb
similarity index 73%
rename from test/rdoc/rdoc_top_level_test.rb
rename to test/rdoc/rdoc_file_test.rb
index a785abf06e..3046f31920 100644
--- a/test/rdoc/rdoc_top_level_test.rb
+++ b/test/rdoc/rdoc_file_test.rb
@@ -1,24 +1,24 @@
# frozen_string_literal: true
require_relative 'xref_test_case'
-class RDocTopLevelTest < XrefTestCase
+class RDocFileTest < XrefTestCase
def setup
super
- @top_level = @store.add_file 'path/top_level.rb'
- @top_level.parser = RDoc::Parser::Ruby
+ @file = @store.add_file 'path/file.rb'
+ @file.parser = RDoc::Parser::Ruby
end
def test_initialize
- t = RDoc::TopLevel.new 'path/file.rb'
+ t = RDoc::File.new 'path/file.rb'
assert_equal 'path/file.rb', t.absolute_name
assert_equal 'path/file.rb', t.relative_name
end
def test_initialize_relative
- t = RDoc::TopLevel.new 'path/file.rb', 'file.rb'
+ t = RDoc::File.new 'path/file.rb', 'file.rb'
assert_equal 'path/file.rb', t.absolute_name
assert_equal 'file.rb', t.relative_name
@@ -26,109 +26,109 @@ def test_initialize_relative
def test_add_alias
a = RDoc::Alias.new nil, 'old', 'new', nil
- @top_level.add_alias a
+ @file.add_alias a
object = @store.find_class_named 'Object'
expected = { '#old' => [a] }
assert_equal expected, object.unmatched_alias_lists
- assert_includes object.in_files, @top_level
+ assert_includes object.in_files, @file
end
def test_add_alias_nodoc
- @top_level.document_self = false
+ @file.document_self = false
a = RDoc::Alias.new nil, 'old', 'new', nil
- @top_level.add_alias a
+ @file.add_alias a
object = @store.find_class_named('Object')
assert_empty object.unmatched_alias_lists
- assert_includes object.in_files, @top_level
+ assert_includes object.in_files, @file
end
def test_add_constant
const = RDoc::Constant.new 'C', nil, nil
- @top_level.add_constant const
+ @file.add_constant const
object = @store.find_class_named 'Object'
assert_equal [const], object.constants
- assert_includes object.in_files, @top_level
+ assert_includes object.in_files, @file
end
def test_add_constant_nodoc
- @top_level.document_self = false
+ @file.document_self = false
const = RDoc::Constant.new 'C', nil, nil
- @top_level.add_constant const
+ @file.add_constant const
object = @store.find_class_named 'Object'
assert_empty object.constants
- assert_includes object.in_files, @top_level
+ assert_includes object.in_files, @file
end
def test_add_include
include = RDoc::Include.new 'C', nil
- @top_level.add_include include
+ @file.add_include include
object = @store.find_class_named 'Object'
assert_equal [include], object.includes
- assert_includes object.in_files, @top_level
+ assert_includes object.in_files, @file
end
def test_add_include_nodoc
- @top_level.document_self = false
+ @file.document_self = false
include = RDoc::Include.new 'C', nil
- @top_level.add_include include
+ @file.add_include include
object = @store.find_class_named('Object')
assert_empty object.includes
- assert_includes object.in_files, @top_level
+ assert_includes object.in_files, @file
end
def test_add_method
method = RDoc::AnyMethod.new nil, 'm'
- @top_level.add_method method
+ @file.add_method method
object = @store.find_class_named 'Object'
assert_equal [@c10_method, @c11_method, method], object.method_list
- assert_includes object.in_files, @top_level
+ assert_includes object.in_files, @file
end
def test_add_method_stopdoc
- @top_level.document_self = false
+ @file.document_self = false
method = RDoc::AnyMethod.new nil, 'm'
- @top_level.add_method method
+ @file.add_method method
object = @store.find_class_named('Object')
assert_equal [@c10_method, @c11_method], object.method_list
- assert_includes object.in_files, @top_level
+ assert_includes object.in_files, @file
end
def test_base_name
- assert_equal 'top_level.rb', @top_level.base_name
+ assert_equal 'file.rb', @file.base_name
end
def test_display_eh
- assert @top_level.display?
+ assert @file.display?
end
def test_eql_eh
- top_level2 = @store.add_file 'path/top_level.rb'
+ file2 = @store.add_file 'path/file.rb'
other_level = @store.add_file 'path/other_level.rb'
- assert_operator @top_level, :eql?, top_level2
+ assert_operator @file, :eql?, file2
- refute_operator other_level, :eql?, @top_level
+ refute_operator other_level, :eql?, @file
end
def test_equals2
- top_level2 = @store.add_file 'path/top_level.rb'
+ file2 = @store.add_file 'path/file.rb'
other_level = @store.add_file 'path/other_level.rb'
- assert_equal @top_level, top_level2
+ assert_equal @file, file2
- refute_equal other_level, @top_level
+ refute_equal other_level, @file
end
def test_find_class_or_module
@@ -139,29 +139,29 @@ def test_find_class_or_module
end
def test_full_name
- assert_equal 'path/top_level.rb', @top_level.full_name
+ assert_equal 'path/file.rb', @file.full_name
end
def test_hash
- tl2 = @store.add_file 'path/top_level.rb'
- tl3 = @store.add_file 'other/top_level.rb'
+ tl2 = @store.add_file 'path/file.rb'
+ tl3 = @store.add_file 'other/file.rb'
- assert_equal @top_level.hash, tl2.hash
- refute_equal @top_level.hash, tl3.hash
+ assert_equal @file.hash, tl2.hash
+ refute_equal @file.hash, tl3.hash
end
def test_http_url
- assert_equal 'path/top_level_rb.html', @top_level.http_url
+ assert_equal 'path/file_rb.html', @file.http_url
other_level = @store.add_file 'path.other/level.rb'
assert_equal 'path_other/level_rb.html', other_level.http_url
end
def test_path
- assert_equal 'path/top_level_rb.html', @top_level.path
+ assert_equal 'path/file_rb.html', @file.path
@options.file_path_prefix = 'file'
- assert_equal 'file/path/top_level_rb.html', @top_level.path
+ assert_equal 'file/path/file_rb.html', @file.path
end
def test_marshal_dump
@@ -186,6 +186,7 @@ def test_marshal_dump
end
def test_marshal_load_version_0
+ # Uses RDoc::TopLevel to test backwards compatibility with old marshal data
loaded = Marshal.load "\x04\bU:\x13RDoc::TopLevel" +
"[\ti\x00I\"\x0FREADME.txt\x06:\x06EF" +
"c\x19RDoc::Parser::Simple" +
@@ -208,11 +209,11 @@ def test_marshal_load_version_0
end
def test_name
- assert_equal 'top_level.rb', @top_level.name
+ assert_equal 'file.rb', @file.name
end
def test_page_name
- assert_equal 'top_level', @top_level.page_name
+ assert_equal 'file', @file.page_name
tl = @store.add_file 'README.ja'
diff --git a/test/rdoc/rdoc_i18n_locale_test.rb b/test/rdoc/rdoc_i18n_locale_test.rb
index cfbc7c5bb2..d2359b3af8 100644
--- a/test/rdoc/rdoc_i18n_locale_test.rb
+++ b/test/rdoc/rdoc_i18n_locale_test.rb
@@ -7,7 +7,7 @@ def setup
super
@locale = locale('fr')
- @tmpdir = File.join Dir.tmpdir, "test_rdoc_i18n_locale_#{$$}"
+ @tmpdir = ::File.join Dir.tmpdir, "test_rdoc_i18n_locale_#{$$}"
FileUtils.mkdir_p @tmpdir
@locale_dir = @tmpdir
@@ -23,7 +23,7 @@ def test_name
end
def test_load_nonexistent_po
- locale = File.join(@locale_dir, 'nonexsitent-locale')
+ locale = ::File.join(@locale_dir, 'nonexsitent-locale')
refute_file locale
refute @locale.load(locale)
end
@@ -35,9 +35,9 @@ def test_load_existent_po
omit 'gettext gem is not found'
end
- fr_locale_dir = File.join @locale_dir, 'fr'
+ fr_locale_dir = ::File.join @locale_dir, 'fr'
FileUtils.mkdir_p fr_locale_dir
- File.open File.join(fr_locale_dir, 'rdoc.po'), 'w' do |po|
+ ::File.open ::File.join(fr_locale_dir, 'rdoc.po'), 'w' do |po|
po.puts <<-PO
msgid ""
msgstr ""
diff --git a/test/rdoc/rdoc_markdown_test_test.rb b/test/rdoc/rdoc_markdown_test_test.rb
index c28fe6bebd..3e9f1d11ef 100644
--- a/test/rdoc/rdoc_markdown_test_test.rb
+++ b/test/rdoc/rdoc_markdown_test_test.rb
@@ -7,7 +7,7 @@
class RDocMarkdownTestTest < RDoc::TestCase
- MARKDOWN_TEST_PATH = File.expand_path '../MarkdownTest_1.0.3/', __FILE__
+ MARKDOWN_TEST_PATH = ::File.expand_path '../MarkdownTest_1.0.3/', __FILE__
def setup
super
@@ -16,7 +16,7 @@ def setup
end
def test_amps_and_angle_encoding
- input = File.read "#{MARKDOWN_TEST_PATH}/Amps and angle encoding.text"
+ input = ::File.read "#{MARKDOWN_TEST_PATH}/Amps and angle encoding.text"
doc = @parser.parse input
@@ -38,7 +38,7 @@ def test_amps_and_angle_encoding
end
def test_auto_links
- input = File.read "#{MARKDOWN_TEST_PATH}/Auto links.text"
+ input = ::File.read "#{MARKDOWN_TEST_PATH}/Auto links.text"
doc = @parser.parse input
@@ -61,7 +61,7 @@ def test_auto_links
end
def test_backslash_escapes
- input = File.read "#{MARKDOWN_TEST_PATH}/Backslash escapes.text"
+ input = ::File.read "#{MARKDOWN_TEST_PATH}/Backslash escapes.text"
doc = @parser.parse input
@@ -159,7 +159,7 @@ def test_backslash_escapes
end
def test_blockquotes_with_code_blocks
- input = File.read "#{MARKDOWN_TEST_PATH}/Blockquotes with code blocks.text"
+ input = ::File.read "#{MARKDOWN_TEST_PATH}/Blockquotes with code blocks.text"
doc = @parser.parse input
@@ -179,7 +179,7 @@ def test_blockquotes_with_code_blocks
end
def test_code_blocks
- input = File.read "#{MARKDOWN_TEST_PATH}/Code Blocks.text"
+ input = ::File.read "#{MARKDOWN_TEST_PATH}/Code Blocks.text"
doc = @parser.parse input
@@ -201,7 +201,7 @@ def test_code_blocks
end
def test_code_spans
- input = File.read "#{MARKDOWN_TEST_PATH}/Code Spans.text"
+ input = ::File.read "#{MARKDOWN_TEST_PATH}/Code Spans.text"
doc = @parser.parse input
@@ -215,7 +215,7 @@ def test_code_spans
end
def test_hard_wrapped_paragraphs_with_list_like_lines
- input = File.read "#{MARKDOWN_TEST_PATH}/Hard-wrapped paragraphs with list-like lines.text"
+ input = ::File.read "#{MARKDOWN_TEST_PATH}/Hard-wrapped paragraphs with list-like lines.text"
doc = @parser.parse input
@@ -233,7 +233,7 @@ def test_hard_wrapped_paragraphs_with_list_like_lines
end
def test_horizontal_rules
- input = File.read "#{MARKDOWN_TEST_PATH}/Horizontal rules.text"
+ input = ::File.read "#{MARKDOWN_TEST_PATH}/Horizontal rules.text"
doc = @parser.parse input
@@ -285,7 +285,7 @@ def test_horizontal_rules
end
def test_inline_html_advanced
- input = File.read "#{MARKDOWN_TEST_PATH}/Inline HTML (Advanced).text"
+ input = ::File.read "#{MARKDOWN_TEST_PATH}/Inline HTML (Advanced).text"
@parser.html = true
@@ -312,7 +312,7 @@ def test_inline_html_advanced
end
def test_inline_html_simple
- input = File.read "#{MARKDOWN_TEST_PATH}/Inline HTML (Simple).text"
+ input = ::File.read "#{MARKDOWN_TEST_PATH}/Inline HTML (Simple).text"
@parser.html = true
@@ -367,7 +367,7 @@ def test_inline_html_simple
end
def test_inline_html_comments
- input = File.read "#{MARKDOWN_TEST_PATH}/Inline HTML comments.text"
+ input = ::File.read "#{MARKDOWN_TEST_PATH}/Inline HTML comments.text"
doc = @parser.parse input
@@ -389,7 +389,7 @@ def test_inline_html_comments
end
def test_links_inline_style
- input = File.read "#{MARKDOWN_TEST_PATH}/Links, inline style.text"
+ input = ::File.read "#{MARKDOWN_TEST_PATH}/Links, inline style.text"
doc = @parser.parse input
@@ -406,7 +406,7 @@ def test_links_inline_style
end
def test_links_reference_style
- input = File.read "#{MARKDOWN_TEST_PATH}/Links, reference style.text"
+ input = ::File.read "#{MARKDOWN_TEST_PATH}/Links, reference style.text"
doc = @parser.parse input
@@ -453,7 +453,7 @@ def test_links_reference_style
end
def test_links_shortcut_references
- input = File.read "#{MARKDOWN_TEST_PATH}/Links, shortcut references.text"
+ input = ::File.read "#{MARKDOWN_TEST_PATH}/Links, shortcut references.text"
doc = @parser.parse input
@@ -468,7 +468,7 @@ def test_links_shortcut_references
end
def test_literal_quotes_in_titles
- input = File.read "#{MARKDOWN_TEST_PATH}/Literal quotes in titles.text"
+ input = ::File.read "#{MARKDOWN_TEST_PATH}/Literal quotes in titles.text"
doc = @parser.parse input
@@ -482,7 +482,7 @@ def test_literal_quotes_in_titles
end
def test_markdown_documentation_basics
- input = File.read "#{MARKDOWN_TEST_PATH}/Markdown Documentation - Basics.text"
+ input = ::File.read "#{MARKDOWN_TEST_PATH}/Markdown Documentation - Basics.text"
doc = @parser.parse input
@@ -782,7 +782,7 @@ def test_markdown_documentation_basics
end
def test_markdown_documentation_syntax
- input = File.read "#{MARKDOWN_TEST_PATH}/Markdown Documentation - Syntax.text"
+ input = ::File.read "#{MARKDOWN_TEST_PATH}/Markdown Documentation - Syntax.text"
doc = @parser.parse input
@@ -1679,7 +1679,7 @@ def test_markdown_documentation_syntax
end
def test_nested_blockquotes
- input = File.read "#{MARKDOWN_TEST_PATH}/Nested blockquotes.text"
+ input = ::File.read "#{MARKDOWN_TEST_PATH}/Nested blockquotes.text"
doc = @parser.parse input
@@ -1695,7 +1695,7 @@ def test_nested_blockquotes
end
def test_ordered_and_unordered_lists
- input = File.read "#{MARKDOWN_TEST_PATH}/Ordered and unordered lists.text"
+ input = ::File.read "#{MARKDOWN_TEST_PATH}/Ordered and unordered lists.text"
doc = @parser.parse input
@@ -1816,7 +1816,7 @@ def test_ordered_and_unordered_lists
end
def test_strong_and_em_together
- input = File.read "#{MARKDOWN_TEST_PATH}/Strong and em together.text"
+ input = ::File.read "#{MARKDOWN_TEST_PATH}/Strong and em together.text"
doc = @parser.parse input
@@ -1831,7 +1831,7 @@ def test_strong_and_em_together
end
def test_tabs
- input = File.read "#{MARKDOWN_TEST_PATH}/Tabs.text"
+ input = ::File.read "#{MARKDOWN_TEST_PATH}/Tabs.text"
doc = @parser.parse input
@@ -1864,7 +1864,7 @@ def test_tabs
end
def test_tidiness
- input = File.read "#{MARKDOWN_TEST_PATH}/Tidiness.text"
+ input = ::File.read "#{MARKDOWN_TEST_PATH}/Tidiness.text"
doc = @parser.parse input
diff --git a/test/rdoc/rdoc_options_test.rb b/test/rdoc/rdoc_options_test.rb
index be87b39d78..55cacc6047 100644
--- a/test/rdoc/rdoc_options_test.rb
+++ b/test/rdoc/rdoc_options_test.rb
@@ -108,7 +108,7 @@ def test_to_yaml_trim_paths
FileUtils.touch 'file'
Dir.chdir 'project' do
- subdir = File.expand_path 'subdir'
+ subdir = ::File.expand_path 'subdir'
FileUtils.mkdir 'subdir'
@options.parse %w[
--copy subdir
@@ -179,10 +179,10 @@ def test_init_with_trim_paths
end
def test_parse_copy_files_file_relative
- file = File.basename __FILE__
- expected = File.expand_path __FILE__
+ file = ::File.basename __FILE__
+ expected = ::File.expand_path __FILE__
- Dir.chdir File.expand_path('..', __FILE__) do
+ Dir.chdir ::File.expand_path('..', __FILE__) do
@options.parse %W[--copy-files #{file}]
assert_equal [expected], @options.static_path
@@ -190,9 +190,9 @@ def test_parse_copy_files_file_relative
end
def test_parse_copy_files_file_absolute
- @options.parse %W[--copy-files #{File.expand_path __FILE__}]
+ @options.parse %W[--copy-files #{::File.expand_path __FILE__}]
- assert_equal [File.expand_path(__FILE__)], @options.static_path
+ assert_equal [::File.expand_path(__FILE__)], @options.static_path
end
def test_parse_copy_files_directory_relative
@@ -262,7 +262,7 @@ def test_parse_dash_p
def test_parse_dash_p_files
out, err = capture_output do
- @options.parse ['-p', File.expand_path(__FILE__)]
+ @options.parse ['-p', ::File.expand_path(__FILE__)]
end
refute @options.pipe
@@ -558,7 +558,7 @@ def test_parse_page_dir_root
Dir.mktmpdir do |dir|
abs_root = dir
- abs_page_dir = File.join dir, 'pages'
+ abs_page_dir = ::File.join dir, 'pages'
FileUtils.mkdir abs_page_dir
out, err = capture_output do
@@ -665,7 +665,7 @@ def test_parse_template_load_path
Dir.mktmpdir do |dir|
$LOAD_PATH << dir
- template_dir = File.join dir, 'rdoc', 'generator', 'template', 'load_path'
+ template_dir = ::File.join dir, 'rdoc', 'generator', 'template', 'load_path'
FileUtils.mkdir_p template_dir
@@ -686,8 +686,8 @@ def test_parse_template_load_path
def test_parse_template_stylesheets
css = nil
Dir.mktmpdir do |dir|
- css = File.join(dir, "hoge.css")
- File.write(css, "")
+ css = ::File.join(dir, "hoge.css")
+ ::File.write(css, "")
out, err = capture_output do
@options.parse %W[--template-stylesheets #{css}]
end
@@ -713,7 +713,7 @@ def test_parse_visibility
end
def test_parse_write_options
- tmpdir = File.join Dir.tmpdir, "test_rdoc_options_#{$$}"
+ tmpdir = ::File.join Dir.tmpdir, "test_rdoc_options_#{$$}"
FileUtils.mkdir_p tmpdir
Dir.chdir tmpdir do
@@ -724,7 +724,7 @@ def test_parse_write_options
assert_equal 0, e.status
- assert File.exist? '.rdoc_options'
+ assert ::File.exist? '.rdoc_options'
end
ensure
FileUtils.rm_rf tmpdir
@@ -836,9 +836,9 @@ def test_write_options
temp_dir do |dir|
@options.write_options
- assert File.exist? '.rdoc_options'
+ assert ::File.exist? '.rdoc_options'
- options = File.read('.rdoc_options')
+ options = ::File.read('.rdoc_options')
options = YAML.safe_load(options, permitted_classes: [Symbol])
assert_equal @options, RDoc::Options.new(options)
end
@@ -883,7 +883,7 @@ def test_load_options
def test_load_options_invalid
temp_dir do
- File.open '.rdoc_options', 'w' do |io|
+ ::File.open '.rdoc_options', 'w' do |io|
io.write "a: !ruby.yaml.org,2002:str |\nfoo"
end
@@ -891,14 +891,14 @@ def test_load_options_invalid
RDoc::Options.load_options
end
- options_file = File.expand_path '.rdoc_options'
+ options_file = ::File.expand_path '.rdoc_options'
assert_equal "#{options_file} is not a valid rdoc options file", e.message
end
end
def test_load_options_empty_file
temp_dir do
- File.open '.rdoc_options', 'w' do |io|
+ ::File.open '.rdoc_options', 'w' do |io|
end
options = RDoc::Options.load_options
@@ -909,7 +909,7 @@ def test_load_options_empty_file
def test_load_options_partial_override
temp_dir do
- File.open '.rdoc_options', 'w' do |io|
+ ::File.open '.rdoc_options', 'w' do |io|
io.puts "markup: Markdown"
io.puts "encoding: iso-8859-1"
io.puts "static_path: [static]"
diff --git a/test/rdoc/rdoc_rdoc_test.rb b/test/rdoc/rdoc_rdoc_test.rb
index f75939cb2d..a3e5a4dce1 100644
--- a/test/rdoc/rdoc_rdoc_test.rb
+++ b/test/rdoc/rdoc_rdoc_test.rb
@@ -16,10 +16,10 @@ def setup
def test_document # functional test
options = RDoc::Options.new
- options.files = [File.expand_path('../xref_data.rb', __FILE__)]
+ options.files = [::File.expand_path('../xref_data.rb', __FILE__)]
options.setup_generator 'ri'
options.main_page = 'MAIN_PAGE.rdoc'
- options.root = Pathname File.expand_path('..', __FILE__)
+ options.root = Pathname ::File.expand_path('..', __FILE__)
options.title = 'title'
rdoc = RDoc::RDoc.new
@@ -31,7 +31,7 @@ def test_document # functional test
rdoc.document options
end
- assert File.directory? 'ri'
+ assert ::File.directory? 'ri'
end
store = rdoc.store
@@ -42,10 +42,10 @@ def test_document # functional test
def test_document_with_dry_run # functional test
options = RDoc::Options.new
- options.files = [File.expand_path('../xref_data.rb', __FILE__)]
+ options.files = [::File.expand_path('../xref_data.rb', __FILE__)]
options.setup_generator 'aliki'
options.main_page = 'MAIN_PAGE.rdoc'
- options.root = Pathname File.expand_path('..', __FILE__)
+ options.root = Pathname ::File.expand_path('..', __FILE__)
options.title = 'title'
options.dry_run = true
@@ -57,7 +57,7 @@ def test_document_with_dry_run # functional test
rdoc.document options
end
- refute File.directory? 'doc'
+ refute ::File.directory? 'doc'
end
assert_includes out, '100%'
@@ -68,8 +68,8 @@ def test_document_with_dry_run # functional test
end
def test_gather_files
- a = File.expand_path __FILE__
- b = File.expand_path '../rdoc_text_test.rb', __FILE__
+ a = ::File.expand_path __FILE__
+ b = ::File.expand_path '../rdoc_text_test.rb', __FILE__
assert_equal [a, b], @rdoc.gather_files([b, a, b])
@@ -106,7 +106,7 @@ def test_handle_pipe_rd
end
def test_normalized_file_list
- test_path = File.expand_path(__FILE__)
+ test_path = ::File.expand_path(__FILE__)
files = temp_dir do |dir|
flag_file = @rdoc.output_flag_file dir
@@ -115,13 +115,13 @@ def test_normalized_file_list
@rdoc.normalized_file_list [test_path, flag_file]
end
- files = files.map { |file, *| File.expand_path file }
+ files = files.map { |file, *| ::File.expand_path file }
assert_equal [test_path], files
end
def test_normalized_file_list_not_modified
- @rdoc.last_modified[__FILE__] = File.stat(__FILE__).mtime
+ @rdoc.last_modified[__FILE__] = ::File.stat(__FILE__).mtime
files = @rdoc.normalized_file_list [__FILE__]
@@ -133,7 +133,7 @@ def test_normalized_file_list_not_modified
def test_normalized_file_list_non_file_directory
dev = File::NULL
omit "#{dev} is not a character special" unless
- File.chardev? dev
+ ::File.chardev? dev
files = nil
@@ -141,7 +141,7 @@ def test_normalized_file_list_non_file_directory
files = @rdoc.normalized_file_list [dev]
end
- files = files.map { |file| File.expand_path file }
+ files = files.map { |file| ::File.expand_path file }
assert_empty files
@@ -153,9 +153,9 @@ def test_normalized_file_list_non_file_directory
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')
+ 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
@@ -164,14 +164,14 @@ def test_normalized_file_list_with_dot_doc
b = Dir.glob(b).first
c = Dir.glob(c).first
- File.write('.document', "a.rb\n""b.rb\n")
+ ::File.write('.document', "a.rb\n""b.rb\n")
expected_files << a
expected_files << b
- @rdoc.normalized_file_list [File.realpath(dir)]
+ @rdoc.normalized_file_list [::File.realpath(dir)]
end
- files = files.map { |file, *| File.expand_path file }
+ files = files.map { |file, *| ::File.expand_path file }
assert_equal expected_files, files
end
@@ -179,9 +179,9 @@ def test_normalized_file_list_with_dot_doc
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')
+ 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
@@ -190,25 +190,25 @@ def test_normalized_file_list_with_dot_doc_overridden_by_exclude_option
b = Dir.glob(b).first
c = Dir.glob(c).first
- File.write('.document', "a.rb\n""b.rb\n")
+ ::File.write('.document', "a.rb\n""b.rb\n")
expected_files << a
@rdoc.options.exclude = /b\.rb$/
- @rdoc.normalized_file_list [File.realpath(dir)]
+ @rdoc.normalized_file_list [::File.realpath(dir)]
end
- files = files.map { |file, *| File.expand_path file }
+ files = files.map { |file, *| ::File.expand_path file }
assert_equal expected_files, files
end
def test_normalized_file_list_with_skipping_tests_enabled
files = temp_dir do |dir|
- @a = File.expand_path('a.rb')
- spec_dir = File.expand_path('spec')
- spec_file = File.expand_path(File.join('spec', 'my_spec.rb'))
- test_dir = File.expand_path('test')
- test_file = File.expand_path(File.join('test', 'my_test.rb'))
+ @a = ::File.expand_path('a.rb')
+ spec_dir = ::File.expand_path('spec')
+ spec_file = ::File.expand_path(::File.join('spec', 'my_spec.rb'))
+ test_dir = ::File.expand_path('test')
+ test_file = ::File.expand_path(::File.join('test', 'my_test.rb'))
FileUtils.touch @a
FileUtils.mkdir_p spec_dir
FileUtils.touch spec_file
@@ -216,20 +216,20 @@ def test_normalized_file_list_with_skipping_tests_enabled
FileUtils.touch test_file
@rdoc.options.skip_tests = true
- @rdoc.normalized_file_list [File.realpath(dir)]
+ @rdoc.normalized_file_list [::File.realpath(dir)]
end
- files = files.map { |file, *| File.expand_path file }
+ files = files.map { |file, *| ::File.expand_path file }
assert_equal [@a], files
end
def test_normalized_file_list_with_skipping_tests_disabled
files = temp_dir do |dir|
- @a = File.expand_path('a.rb')
- spec_dir = File.expand_path('spec')
- @spec_file = File.expand_path(File.join('spec', 'my_spec.rb'))
- test_dir = File.expand_path('test')
- @test_file = File.expand_path(File.join('test', 'my_test.rb'))
+ @a = ::File.expand_path('a.rb')
+ spec_dir = ::File.expand_path('spec')
+ @spec_file = ::File.expand_path(::File.join('spec', 'my_spec.rb'))
+ test_dir = ::File.expand_path('test')
+ @test_file = ::File.expand_path(::File.join('test', 'my_test.rb'))
FileUtils.touch @a
FileUtils.mkdir_p spec_dir
FileUtils.touch @spec_file
@@ -237,10 +237,10 @@ def test_normalized_file_list_with_skipping_tests_disabled
FileUtils.touch @test_file
@rdoc.options.skip_tests = false
- @rdoc.normalized_file_list [File.realpath(dir)]
+ @rdoc.normalized_file_list [::File.realpath(dir)]
end
- files = files.map { |file, *| File.expand_path file }
+ files = files.map { |file, *| ::File.expand_path file }
assert_equal [@a, @spec_file, @test_file], files.sort
end
@@ -250,21 +250,21 @@ def test_parse_file
temp_dir do |dir|
@rdoc.options.root = Pathname(Dir.pwd)
- File.open 'test.txt', 'w' do |io|
+ ::File.open 'test.txt', 'w' do |io|
io.puts 'hi'
end
- top_level = @rdoc.parse_file 'test.txt'
+ file = @rdoc.parse_file 'test.txt'
- assert_equal 'test.txt', top_level.absolute_name
- assert_equal 'test.txt', top_level.relative_name
+ assert_equal 'test.txt', file.absolute_name
+ assert_equal 'test.txt', file.relative_name
end
end
def test_parse_file_binary
@rdoc.store = RDoc::Store.new(@options)
- root = File.dirname __FILE__
+ root = ::File.dirname __FILE__
@rdoc.options.root = Pathname root
@@ -281,23 +281,23 @@ def test_parse_file_binary
def test_parse_file_include_root
@rdoc.store = RDoc::Store.new(@options)
- test_path = File.expand_path('..', __FILE__)
- top_level = nil
+ test_path = ::File.expand_path('..', __FILE__)
+ file = nil
temp_dir do |dir|
@rdoc.options.parse %W[--root #{test_path}]
@rdoc.options.finish
- File.open 'include.txt', 'w' do |io|
+ ::File.open 'include.txt', 'w' do |io|
io.puts ':include: test.txt'
end
out, err = capture_output do
- top_level = @rdoc.parse_file 'include.txt'
+ file = @rdoc.parse_file 'include.txt'
end
assert_empty out
assert_empty err
end
- assert_equal "test file", top_level.comment.text
+ assert_equal "test file", file.comment.text
end
def test_parse_file_page_dir
@@ -308,14 +308,14 @@ def test_parse_file_page_dir
@rdoc.options.page_dir = Pathname('pages')
@rdoc.options.root = Pathname(Dir.pwd)
- File.open 'pages/test.txt', 'w' do |io|
+ ::File.open 'pages/test.txt', 'w' do |io|
io.puts 'hi'
end
- top_level = @rdoc.parse_file 'pages/test.txt'
+ file = @rdoc.parse_file 'pages/test.txt'
- assert_equal 'pages/test.txt', top_level.absolute_name
- assert_equal 'test.txt', top_level.relative_name
+ assert_equal 'pages/test.txt', file.absolute_name
+ assert_equal 'test.txt', file.relative_name
end
end
@@ -327,17 +327,17 @@ def test_parse_file_relative
temp_dir do |dir|
@rdoc.options.root = Pathname(dir)
- File.open 'test.txt', 'w' do |io|
+ ::File.open 'test.txt', 'w' do |io|
io.puts 'hi'
end
- test_txt = File.join dir, 'test.txt'
+ test_txt = ::File.join dir, 'test.txt'
Dir.chdir pwd do
- top_level = @rdoc.parse_file test_txt
+ file = @rdoc.parse_file test_txt
- assert_equal test_txt, top_level.absolute_name
- assert_equal 'test.txt', top_level.relative_name
+ assert_equal test_txt, file.absolute_name
+ assert_equal 'test.txt', file.relative_name
end
end
end
@@ -350,9 +350,9 @@ def test_parse_file_encoding
io.write 'hi'
io.rewind
- top_level = @rdoc.parse_file io.path
+ file = @rdoc.parse_file io.path
- assert_equal Encoding::ISO_8859_1, top_level.absolute_name.encoding
+ assert_equal Encoding::ISO_8859_1, file.absolute_name.encoding
io
end
tf.close!
@@ -368,20 +368,20 @@ def test_parse_file_forbidden
io.write 'hi'
io.rewind
- File.chmod 0000, io.path
+ ::File.chmod 0000, io.path
begin
- top_level = :bug
+ file = :bug
_, err = capture_output do
- top_level = @rdoc.parse_file io.path
+ file = @rdoc.parse_file io.path
end
assert_match "Unable to read #{io.path},", err
- assert_nil top_level
+ assert_nil file
ensure
- File.chmod 0400, io.path
+ ::File.chmod 0400, io.path
end
io
end
@@ -404,7 +404,7 @@ def test_remove_unparseable
def test_remove_unparseable_tags_emacs
temp_dir do
- File.open 'TAGS', 'wb' do |io| # emacs
+ ::File.open 'TAGS', 'wb' do |io| # emacs
io.write "\f\nlib/foo.rb,43\n"
end
@@ -418,7 +418,7 @@ def test_remove_unparseable_tags_emacs
def test_remove_unparseable_tags_vim
temp_dir do
- File.open 'TAGS', 'w' do |io| # emacs
+ ::File.open 'TAGS', 'w' do |io| # emacs
io.write "!_TAG_"
end
@@ -445,14 +445,14 @@ def test_remove_unparseable_CVE_2021_31799
def test_setup_output_dir
Dir.mktmpdir {|d|
- path = File.join d, 'testdir'
+ path = ::File.join d, 'testdir'
last = @rdoc.setup_output_dir path, false
assert_empty last
- assert File.directory? path
- assert File.exist? @rdoc.output_flag_file path
+ assert ::File.directory? path
+ assert ::File.exist? @rdoc.output_flag_file path
}
end
@@ -460,17 +460,17 @@ def test_setup_output_dir_dry_run
@rdoc.options.dry_run = true
Dir.mktmpdir do |d|
- path = File.join d, 'testdir'
+ path = ::File.join d, 'testdir'
@rdoc.setup_output_dir path, false
- refute File.exist? path
+ refute ::File.exist? path
end
end
def test_setup_output_dir_exists
Dir.mktmpdir {|path|
- File.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
@@ -484,7 +484,7 @@ def test_setup_output_dir_exists
def test_setup_output_dir_exists_empty_created_rid
Dir.mktmpdir {|path|
- File.open @rdoc.output_flag_file(path), 'w' do end
+ ::File.open @rdoc.output_flag_file(path), 'w' do end
e = assert_raise RDoc::Error do
@rdoc.setup_output_dir path, false
@@ -523,7 +523,7 @@ def test_update_output_dir
Dir.mktmpdir do |d|
@rdoc.update_output_dir d, Time.now, {}
- assert File.exist? "#{d}/created.rid"
+ assert ::File.exist? "#{d}/created.rid"
end
end
@@ -532,7 +532,7 @@ def test_update_output_dir_dont
@rdoc.options.update_output_dir = false
@rdoc.update_output_dir d, Time.now, {}
- refute File.exist? "#{d}/created.rid"
+ refute ::File.exist? "#{d}/created.rid"
end
end
@@ -541,7 +541,7 @@ def test_update_output_dir_dry_run
@rdoc.options.dry_run = true
@rdoc.update_output_dir d, Time.now, {}
- refute File.exist? "#{d}/created.rid"
+ refute ::File.exist? "#{d}/created.rid"
end
end
@@ -553,9 +553,9 @@ def test_update_output_dir_with_reproducible_time
@rdoc.update_output_dir d, Time.now, {}
- assert File.exist? "#{d}/created.rid"
+ assert ::File.exist? "#{d}/created.rid"
- f = File.open("#{d}/created.rid", 'r')
+ f = ::File.open("#{d}/created.rid", 'r')
head_timestamp = Time.parse f.gets.chomp
f.close
assert_equal ruby_birthday, head_timestamp
@@ -568,7 +568,7 @@ def test_normalized_file_list_removes_created_rid_dir
temp_dir do |d|
FileUtils.mkdir "doc"
flag_file = @rdoc.output_flag_file "doc"
- file = File.join "doc", "test"
+ file = ::File.join "doc", "test"
FileUtils.touch flag_file
FileUtils.touch file
diff --git a/test/rdoc/rdoc_rubygems_hook_test.rb b/test/rdoc/rdoc_rubygems_hook_test.rb
index bb122f0e41..a4e183f20a 100644
--- a/test/rdoc/rdoc_rubygems_hook_test.rb
+++ b/test/rdoc/rdoc_rubygems_hook_test.rb
@@ -14,7 +14,7 @@ def setup
s.rdoc_options = %w[--main MyTitle]
s.extra_rdoc_files = %w[README]
end
- @tempdir = File.realpath(Dir.mktmpdir("test_rubygems_hook_"))
+ @tempdir = ::File.realpath(Dir.mktmpdir("test_rubygems_hook_"))
@orig_envs = %w[
GEM_VENDOR
@@ -31,19 +31,19 @@ def setup
Gem.configuration = nil
- @a.instance_variable_set(:@doc_dir, File.join(@tempdir, "doc"))
- @a.instance_variable_set(:@gem_dir, File.join(@tempdir, "a-2"))
- @a.instance_variable_set(:@full_gem_path, File.join(@tempdir, "a-2"))
- @a.loaded_from = File.join(@tempdir, 'a-2', 'a-2.gemspec')
+ @a.instance_variable_set(:@doc_dir, ::File.join(@tempdir, "doc"))
+ @a.instance_variable_set(:@gem_dir, ::File.join(@tempdir, "a-2"))
+ @a.instance_variable_set(:@full_gem_path, ::File.join(@tempdir, "a-2"))
+ @a.loaded_from = ::File.join(@tempdir, 'a-2', 'a-2.gemspec')
- FileUtils.mkdir_p File.join(@tempdir, 'a-2', 'lib')
- FileUtils.touch File.join(@tempdir, 'a-2', 'README')
- File.open(File.join(@tempdir, 'a-2', 'lib', 'a.rb'), 'w') do |f|
+ FileUtils.mkdir_p ::File.join(@tempdir, 'a-2', 'lib')
+ FileUtils.touch ::File.join(@tempdir, 'a-2', 'README')
+ ::File.open(::File.join(@tempdir, 'a-2', 'lib', 'a.rb'), 'w') do |f|
f.puts '# comment'
f.puts '# :include: include.txt'
f.puts 'class A; end'
end
- File.open(File.join(@tempdir, 'a-2', 'include.txt'), 'w') do |f|
+ ::File.open(::File.join(@tempdir, 'a-2', 'include.txt'), 'w') do |f|
f.puts 'included content'
end
@@ -105,7 +105,7 @@ def test_document
def test_generate
FileUtils.mkdir_p @a.doc_dir
- FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
+ FileUtils.mkdir_p ::File.join(@a.gem_dir, 'lib')
@hook.generate
@@ -130,7 +130,7 @@ def test_generate_all
@hook.generate_ri = true
FileUtils.mkdir_p @a.doc_dir
- FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
+ FileUtils.mkdir_p ::File.join(@a.gem_dir, 'lib')
@hook.generate
@@ -150,7 +150,7 @@ def test_generate_configuration_rdoc_array
Gem.configuration[:rdoc] = %w[-A]
FileUtils.mkdir_p @a.doc_dir
- FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
+ FileUtils.mkdir_p ::File.join(@a.gem_dir, 'lib')
@hook.generate
@@ -163,7 +163,7 @@ def test_generate_configuration_rdoc_string
Gem.configuration[:rdoc] = '-A'
FileUtils.mkdir_p @a.doc_dir
- FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
+ FileUtils.mkdir_p ::File.join(@a.gem_dir, 'lib')
@hook.generate
@@ -179,7 +179,7 @@ def test_generate_default_gem
else
klass = Gem::Specification
end
- @a.loaded_from = File.join klass.default_specifications_dir, 'a.gemspec'
+ @a.loaded_from = ::File.join klass.default_specifications_dir, 'a.gemspec'
end
@hook.generate
@@ -201,14 +201,14 @@ def test_generate_disabled
def test_generate_force
FileUtils.mkdir_p @a.doc_dir 'ri'
FileUtils.mkdir_p @a.doc_dir 'rdoc'
- FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
+ FileUtils.mkdir_p ::File.join(@a.gem_dir, 'lib')
@hook.force = true
@hook.generate
- assert_path_not_exist File.join(@a.doc_dir('rdoc'), 'index.html')
- assert_path_exist File.join(@a.doc_dir('ri'), 'cache.ri')
+ assert_path_not_exist ::File.join(@a.doc_dir('rdoc'), 'index.html')
+ assert_path_exist ::File.join(@a.doc_dir('ri'), 'cache.ri')
end
def test_generate_rubygems_compatible
@@ -217,14 +217,14 @@ def test_generate_rubygems_compatible
RDoc::RubygemsHook.define_singleton_method(:default_gem?) { true }
FileUtils.mkdir_p @a.doc_dir 'ri'
FileUtils.mkdir_p @a.doc_dir 'rdoc'
- FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
+ FileUtils.mkdir_p ::File.join(@a.gem_dir, 'lib')
# rubygems/lib/rubygems/commands/rdoc_command.rb calls this
hook = RDoc::RubygemsHook.new @a, true, true
hook.force = true
hook.generate
- assert_path_exist File.join(@a.doc_dir('rdoc'), 'index.html')
+ assert_path_exist ::File.join(@a.doc_dir('rdoc'), 'index.html')
ensure
RDoc::RubygemsHook.singleton_class.remove_method(:default_gem?)
RDoc::RubygemsHook.define_singleton_method(:default_gem?, &original_default_gem_method)
@@ -233,24 +233,24 @@ def test_generate_rubygems_compatible
def test_generate_no_overwrite
FileUtils.mkdir_p @a.doc_dir 'ri'
FileUtils.mkdir_p @a.doc_dir 'rdoc'
- FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
+ FileUtils.mkdir_p ::File.join(@a.gem_dir, 'lib')
@hook.generate
- assert_path_not_exist File.join(@a.doc_dir('rdoc'), 'index.html')
- assert_path_not_exist File.join(@a.doc_dir('ri'), 'cache.ri')
+ assert_path_not_exist ::File.join(@a.doc_dir('rdoc'), 'index.html')
+ assert_path_not_exist ::File.join(@a.doc_dir('ri'), 'cache.ri')
end
def test_generate_with_ri_opt
@a.rdoc_options << '--ri'
FileUtils.mkdir_p @a.doc_dir
- FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
+ FileUtils.mkdir_p ::File.join(@a.gem_dir, 'lib')
@hook.generate_rdoc = true
@hook.generate_ri = true
@hook.generate
- assert_path_exist File.join(@a.doc_dir('rdoc'), 'index.html')
- assert_path_exist File.join(@a.doc_dir('ri'), 'cache.ri')
+ assert_path_exist ::File.join(@a.doc_dir('rdoc'), 'index.html')
+ assert_path_exist ::File.join(@a.doc_dir('ri'), 'cache.ri')
end
def test_new_rdoc
@@ -290,7 +290,7 @@ def test_remove_unwritable
assert_equal @a.base_dir, e.directory
ensure
- FileUtils.chmod(0755, @a.base_dir) if File.directory?(@a.base_dir)
+ FileUtils.chmod(0755, @a.base_dir) if ::File.directory?(@a.base_dir)
end
def test_ri_installed?
@@ -320,7 +320,7 @@ def test_setup_unwritable
assert_equal @a.doc_dir, e.directory
ensure
- if File.exist? @a.doc_dir
+ if ::File.exist? @a.doc_dir
FileUtils.chmod 0755, @a.doc_dir
FileUtils.rm_r @a.doc_dir
end
diff --git a/test/rdoc/rdoc_servlet_test.rb b/test/rdoc/rdoc_servlet_test.rb
index 0d9da1b727..54c0943254 100644
--- a/test/rdoc/rdoc_servlet_test.rb
+++ b/test/rdoc/rdoc_servlet_test.rb
@@ -12,7 +12,7 @@ def setup
@orig_gem_path = Gem.path
- @tempdir = File.join Dir.tmpdir, "test_rdoc_servlet_#{$$}"
+ @tempdir = ::File.join Dir.tmpdir, "test_rdoc_servlet_#{$$}"
Gem.use_paths @tempdir
Gem.ensure_gem_subdirectories @tempdir
@@ -28,7 +28,7 @@ def @server.mount(*) end
@stores = {}
@cache = Hash.new { |hash, store| hash[store] = {} }
- @extra_dirs = [File.join(@tempdir, 'extra1'), File.join(@tempdir, 'extra2')]
+ @extra_dirs = [::File.join(@tempdir, 'extra1'), ::File.join(@tempdir, 'extra2')]
@s = RDoc::Servlet.new @server, @stores, @cache, nil, @extra_dirs
@@ -41,10 +41,10 @@ def @req.path=(path)
@req.instance_variable_set :@header, Hash.new { |h, k| h[k] = [] }
- @base = File.join @tempdir, 'base'
- @system_dir = File.join @tempdir, 'base', 'system'
- @home_dir = File.join @tempdir, 'home'
- @gem_doc_dir = File.join @tempdir, 'doc'
+ @base = ::File.join @tempdir, 'base'
+ @system_dir = ::File.join @tempdir, 'base', 'system'
+ @home_dir = ::File.join @tempdir, 'home'
+ @gem_doc_dir = ::File.join @tempdir, 'doc'
@options = RDoc::Options.new
@orig_base = RDoc::RI::Paths::BASE
@@ -76,8 +76,8 @@ def test_asset
FileUtils.mkdir 'css'
now = Time.now
- File.open 'css/rdoc.css', 'w' do |io| io.write 'h1 { color: red }' end
- File.utime now, now, 'css/rdoc.css'
+ ::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] = '.'
@@ -298,11 +298,11 @@ def test_generator_for
end
def test_if_modified_since
- omit 'File.utime on directory not supported' if Gem.win_platform?
+ omit '::File.utime on directory not supported' if Gem.win_platform?
temp_dir do
now = Time.now
- File.utime now, now, '.'
+ ::File.utime now, now, '.'
@s.if_modified_since @req, @res, '.'
@@ -311,11 +311,11 @@ def test_if_modified_since
end
def test_if_modified_since_not_modified
- omit 'File.utime on directory not supported' if Gem.win_platform?
+ omit '::File.utime on directory not supported' if Gem.win_platform?
temp_dir do
now = Time.now
- File.utime now, now, '.'
+ ::File.utime now, now, '.'
@req.header['if-modified-since'] = [(now + 10).httpdate]
@@ -339,11 +339,11 @@ def test_installed_docs
['Ruby Documentation', 'ruby/', true, :system,
@system_dir],
['Site Documentation', 'site/', false, :site,
- File.join(@base, 'site')],
+ ::File.join(@base, 'site')],
['Home Documentation', 'home/', false, :home,
RDoc::RI::Paths::HOMEDIR],
['spec-1.0', 'spec-1.0/', false, :gem,
- File.join(@spec.doc_dir, 'ri')],
+ ::File.join(@spec.doc_dir, 'ri')],
]
assert_equal expected, @s.installed_docs
@@ -380,9 +380,9 @@ def test_ri_paths
[@extra_dirs[0], :extra],
[@extra_dirs[1], :extra],
[@system_dir, :system],
- [File.join(@base, 'site'), :site],
+ [::File.join(@base, 'site'), :site],
[RDoc::RI::Paths::HOMEDIR, :home],
- [File.join(@spec.doc_dir, 'ri'), :gem],
+ [::File.join(@spec.doc_dir, 'ri'), :gem],
]
assert_equal expected, paths.to_a
@@ -474,13 +474,13 @@ def test_show_documentation_search_index
end
def test_store_for_gem
- ri_dir = File.join @gem_doc_dir, 'spec-1.0', 'ri'
+ ri_dir = ::File.join @gem_doc_dir, 'spec-1.0', 'ri'
FileUtils.mkdir_p ri_dir
- FileUtils.touch File.join ri_dir, 'cache.ri'
+ FileUtils.touch ::File.join ri_dir, 'cache.ri'
store = @s.store_for 'spec-1.0'
- assert_equal File.join(@gem_doc_dir, 'spec-1.0', 'ri'), store.path
+ assert_equal ::File.join(@gem_doc_dir, 'spec-1.0', 'ri'), store.path
assert_equal :gem, store.type
end
@@ -492,7 +492,7 @@ def test_store_for_home
end
def test_store_for_missing_documentation
- FileUtils.mkdir_p(File.join @gem_doc_dir, 'spec-1.0', 'ri')
+ FileUtils.mkdir_p(::File.join @gem_doc_dir, 'spec-1.0', 'ri')
e = assert_raise WEBrick::HTTPStatus::NotFound do
@s.store_for 'spec-1.0'
@@ -521,7 +521,7 @@ def test_store_for_ruby
def test_store_for_site
store = @s.store_for 'site'
- assert_equal File.join(@base, 'site'), store.path
+ assert_equal ::File.join(@base, 'site'), store.path
assert_equal :site, store.type
end
@@ -536,7 +536,7 @@ def touch_system_cache_path
store = RDoc::Store.new(@options, path: @system_dir)
store.title = 'Standard Library Documentation'
- FileUtils.mkdir_p File.dirname store.cache_path
+ FileUtils.mkdir_p ::File.dirname store.cache_path
store.save
end
@@ -545,7 +545,7 @@ def touch_extra_cache_path
store = RDoc::Store.new(@options, path: @extra_dirs.first)
store.title = 'My Extra Documentation'
- FileUtils.mkdir_p File.dirname store.cache_path
+ FileUtils.mkdir_p ::File.dirname store.cache_path
store.save
end
diff --git a/test/rdoc/rdoc_store_test.rb b/test/rdoc/rdoc_store_test.rb
index d22516100e..4b10347450 100644
--- a/test/rdoc/rdoc_store_test.rb
+++ b/test/rdoc/rdoc_store_test.rb
@@ -8,41 +8,41 @@ class RDocStoreTest < XrefTestCase
def setup
super
- @tmpdir = File.join Dir.tmpdir, "test_rdoc_ri_store_#{$$}"
+ @tmpdir = ::File.join Dir.tmpdir, "test_rdoc_ri_store_#{$$}"
@s = RDoc::RI::Store.new(RDoc::Options.new, path: @tmpdir)
- @top_level = @s.add_file 'file.rb'
+ @file = @s.add_file 'file.rb'
@page = @s.add_file 'README.txt', parser: RDoc::Parser::Simple
@page.comment = RDoc::Comment.new 'This is a page', @page
- @klass = @top_level.add_class RDoc::NormalClass, 'Object'
- @klass.add_comment 'original', @top_level
- @klass.record_location @top_level
+ @klass = @file.add_class RDoc::NormalClass, 'Object'
+ @klass.add_comment 'original', @file
+ @klass.record_location @file
@cmeth = RDoc::AnyMethod.new nil, 'cmethod', singleton: true
- @cmeth.record_location @top_level
+ @cmeth.record_location @file
@meth_comment = RDoc::Comment.new 'method comment'
- @meth_comment.location = @top_level
+ @meth_comment.location = @file
@meth = RDoc::AnyMethod.new nil, 'method'
- @meth.record_location @top_level
+ @meth.record_location @file
@meth.comment = @meth_comment
@meth_bang = RDoc::AnyMethod.new nil, 'method!'
- @meth_bang.record_location @top_level
+ @meth_bang.record_location @file
@meth_bang_alias = RDoc::Alias.new nil, 'method!', 'method_bang', ''
- @meth_bang_alias.record_location @top_level
+ @meth_bang_alias.record_location @file
@meth_bang.add_alias @meth_bang_alias, @klass
@attr_comment = RDoc::Comment.new 'attribute comment'
- @attr_comment.location = @top_level
+ @attr_comment.location = @file
@attr = RDoc::Attr.new nil, 'attr', 'RW', ''
- @attr.record_location @top_level
+ @attr.record_location @file
@attr.comment = @attr_comment
@klass.add_method @cmeth
@@ -52,16 +52,16 @@ def setup
@nest_klass = @klass.add_class RDoc::NormalClass, 'SubClass'
@nest_meth = RDoc::AnyMethod.new nil, 'method'
- @nest_meth.record_location @top_level
+ @nest_meth.record_location @file
@nest_incl = RDoc::Include.new 'Incl', ''
- @nest_incl.record_location @top_level
+ @nest_incl.record_location @file
@nest_klass.add_method @nest_meth
@nest_klass.add_include @nest_incl
- @mod = @top_level.add_module RDoc::NormalModule, 'Mod'
- @mod.record_location @top_level
+ @mod = @file.add_module RDoc::NormalModule, 'Mod'
+ @mod.record_location @file
end
def using_prism_ruby_parser?
@@ -135,30 +135,30 @@ def test_add_c_variables
end
def test_add_file
- top_level = @store.add_file 'file.rb'
+ file = @store.add_file 'file.rb'
- assert_kind_of RDoc::TopLevel, top_level
- assert_equal @store, top_level.store
- assert_equal 'file.rb', top_level.name
- assert_includes @store.all_files, top_level
+ assert_kind_of RDoc::File, file
+ assert_equal @store, file.store
+ assert_equal 'file.rb', file.name
+ assert_includes @store.all_files, file
- assert_same top_level, @store.add_file('file.rb')
- refute_same top_level, @store.add_file('other.rb')
+ assert_same file, @store.add_file('file.rb')
+ refute_same file, @store.add_file('other.rb')
end
def test_add_file_relative
- top_level = @store.add_file 'path/file.rb', relative_name: 'file.rb'
+ file = @store.add_file 'path/file.rb', relative_name: 'file.rb'
- assert_kind_of RDoc::TopLevel, top_level
- assert_equal @store, top_level.store
+ assert_kind_of RDoc::File, file
+ assert_equal @store, file.store
- assert_equal 'path/file.rb', top_level.absolute_name
- assert_equal 'file.rb', top_level.relative_name
+ assert_equal 'path/file.rb', file.absolute_name
+ assert_equal 'file.rb', file.relative_name
- assert_includes @store.all_files, top_level
+ assert_includes @store.all_files, file
- assert_same top_level, @store.add_file('file.rb')
- refute_same top_level, @store.add_file('other.rb')
+ assert_same file, @store.add_file('file.rb')
+ refute_same file, @store.add_file('other.rb')
end
def test_all_classes_and_modules
@@ -197,9 +197,9 @@ def test_attributes
end
def test_class_file
- assert_equal File.join(@tmpdir, 'Object', 'cdesc-Object.ri'),
+ assert_equal ::File.join(@tmpdir, 'Object', 'cdesc-Object.ri'),
@s.class_file('Object')
- assert_equal File.join(@tmpdir, 'Object', 'SubClass', 'cdesc-SubClass.ri'),
+ assert_equal ::File.join(@tmpdir, 'Object', 'SubClass', 'cdesc-SubClass.ri'),
@s.class_file('Object::SubClass')
end
@@ -212,8 +212,8 @@ def test_class_methods
end
def test_class_path
- assert_equal File.join(@tmpdir, 'Object'), @s.class_path('Object')
- assert_equal File.join(@tmpdir, 'Object', 'SubClass'),
+ assert_equal ::File.join(@tmpdir, 'Object'), @s.class_path('Object')
+ assert_equal ::File.join(@tmpdir, 'Object', 'SubClass'),
@s.class_path('Object::SubClass')
end
@@ -234,7 +234,7 @@ def test_classes
def test_complete
a1 = RDoc::Constant.new 'A1', '', ''
- @c2.add_module_alias @c2_c3, @c2_c3.name, a1, @top_level
+ @c2.add_module_alias @c2_c3, @c2_c3.name, a1, @file
@store.complete :public
@@ -245,8 +245,8 @@ def test_complete
end
def test_complete_nodoc
- c_nodoc = @top_level.add_class RDoc::NormalClass, 'Nodoc'
- c_nodoc.record_location @top_level
+ c_nodoc = @file.add_class RDoc::NormalClass, 'Nodoc'
+ c_nodoc.record_location @file
c_nodoc.document_self = nil
@s.complete :nodoc
@@ -274,7 +274,7 @@ def test_find_c_enclosure_from_cache
assert_equal @klass, klass
assert_empty klass.comment_location
- assert_equal @top_level, klass.parent
+ assert_equal @file, klass.parent
assert_includes @s.c_enclosure_classes, 'cObject'
end
@@ -365,7 +365,7 @@ def test_friendly_path
assert_equal "ruby site", @s.friendly_path
@s.type = :home
- assert_equal File.expand_path("~/.local/share/rdoc"), @s.friendly_path
+ assert_equal ::File.expand_path("~/.local/share/rdoc"), @s.friendly_path
@s.type = :gem
@s.path = "#{@tmpdir}/gem_repository/doc/gem_name-1.0/ri"
@@ -401,7 +401,7 @@ def test_load_all
assert_equal [@klass, @nest_klass], s.all_classes.sort
assert_equal [@mod], s.all_modules.sort
- assert_equal [@page, @top_level], s.all_files.sort
+ assert_equal [@page, @file], s.all_files.sort
methods = s.all_classes_and_modules.flat_map do |mod|
mod.method_list
@@ -442,7 +442,7 @@ def test_load_cache
Dir.mkdir @tmpdir
- File.open File.join(@tmpdir, 'cache.ri'), 'wb' do |io|
+ ::File.open ::File.join(@tmpdir, 'cache.ri'), 'wb' do |io|
Marshal.dump cache, io
end
@@ -480,7 +480,7 @@ def test_load_cache_encoding_differs
Dir.mkdir @tmpdir
- File.open File.join(@tmpdir, 'cache.ri'), 'wb' do |io|
+ ::File.open ::File.join(@tmpdir, 'cache.ri'), 'wb' do |io|
Marshal.dump cache, io
end
@@ -529,7 +529,7 @@ def test_load_cache_legacy
Dir.mkdir @tmpdir
- File.open File.join(@tmpdir, 'cache.ri'), 'wb' do |io|
+ ::File.open ::File.join(@tmpdir, 'cache.ri'), 'wb' do |io|
Marshal.dump cache, io
end
@@ -597,7 +597,7 @@ def test_load_method_legacy
file = @s.method_file @klass.full_name, @meth.full_name
- File.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" +
@@ -630,16 +630,16 @@ def test_main
end
def test_method_file
- assert_equal File.join(@tmpdir, 'Object', 'method-i.ri'),
+ assert_equal ::File.join(@tmpdir, 'Object', 'method-i.ri'),
@s.method_file('Object', 'Object#method')
- assert_equal File.join(@tmpdir, 'Object', 'method%21-i.ri'),
+ assert_equal ::File.join(@tmpdir, 'Object', 'method%21-i.ri'),
@s.method_file('Object', 'Object#method!')
- assert_equal File.join(@tmpdir, 'Object', 'SubClass', 'method%21-i.ri'),
+ assert_equal ::File.join(@tmpdir, 'Object', 'SubClass', 'method%21-i.ri'),
@s.method_file('Object::SubClass', 'Object::SubClass#method!')
- assert_equal File.join(@tmpdir, 'Object', 'method-c.ri'),
+ assert_equal ::File.join(@tmpdir, 'Object', 'method-c.ri'),
@s.method_file('Object', 'Object::method')
end
@@ -670,13 +670,13 @@ def test_save
@s.save
- assert_directory File.join(@tmpdir, 'Object')
+ assert_directory ::File.join(@tmpdir, 'Object')
- assert_file File.join(@tmpdir, 'Object', 'cdesc-Object.ri')
- assert_file File.join(@tmpdir, 'Object', 'method-i.ri')
- assert_file File.join(@tmpdir, 'page-README_txt.ri')
+ assert_file ::File.join(@tmpdir, 'Object', 'cdesc-Object.ri')
+ assert_file ::File.join(@tmpdir, 'Object', 'method-i.ri')
+ assert_file ::File.join(@tmpdir, 'page-README_txt.ri')
- assert_file File.join(@tmpdir, 'cache.ri')
+ assert_file ::File.join(@tmpdir, 'cache.ri')
expected = {
:ancestors => {
@@ -699,7 +699,7 @@ def test_save
expected[:ancestors]['Object'] = %w[BasicObject]
- File.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
@@ -732,7 +732,7 @@ def test_save_cache
@s.save_cache
- assert_file File.join(@tmpdir, 'cache.ri')
+ assert_file ::File.join(@tmpdir, 'cache.ri')
c_class_variables = {
'ext.c' => {
@@ -767,7 +767,7 @@ def test_save_cache
expected[:ancestors]['Object'] = %w[BasicObject]
- File.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
@@ -784,7 +784,7 @@ def test_save_cache_dry_run
@s.save_cache
- refute_file File.join(@tmpdir, 'cache.ri')
+ refute_file ::File.join(@tmpdir, 'cache.ri')
end
def test_save_cache_duplicate_methods
@@ -808,8 +808,8 @@ def test_save_cache_duplicate_pages
def test_save_class
@s.save_class @klass
- assert_directory File.join(@tmpdir, 'Object')
- assert_file File.join(@tmpdir, 'Object', 'cdesc-Object.ri')
+ assert_directory ::File.join(@tmpdir, 'Object')
+ assert_file ::File.join(@tmpdir, 'Object', 'cdesc-Object.ri')
assert_cache nil, nil, nil, %w[Object], 'Object' => OBJECT_ANCESTORS
@@ -821,8 +821,8 @@ def test_save_class_basic_object
@s.save_class @klass
- assert_directory File.join(@tmpdir, 'Object')
- assert_file File.join(@tmpdir, 'Object', 'cdesc-Object.ri')
+ assert_directory ::File.join(@tmpdir, 'Object')
+ assert_file ::File.join(@tmpdir, 'Object', 'cdesc-Object.ri')
assert_cache(nil, nil, nil, %w[Object])
@@ -841,7 +841,7 @@ def test_save_class_delete
klass = RDoc::NormalClass.new 'Object'
meth = klass.add_method RDoc::AnyMethod.new(nil, 'replace')
- meth.record_location @top_level
+ meth.record_location @file
# load original, save newly updated class
@s = RDoc::RI::Store.new(RDoc::Options.new, path: @tmpdir)
@@ -873,15 +873,15 @@ def test_save_class_dry_run
@s.save_class @klass
- refute_file File.join(@tmpdir, 'Object')
- refute_file File.join(@tmpdir, 'Object', 'cdesc-Object.ri')
+ refute_file ::File.join(@tmpdir, 'Object')
+ refute_file ::File.join(@tmpdir, 'Object', 'cdesc-Object.ri')
end
def test_save_class_loaded
@s.save
- assert_directory File.join(@tmpdir, 'Object')
- assert_file File.join(@tmpdir, 'Object', 'cdesc-Object.ri')
+ assert_directory ::File.join(@tmpdir, 'Object')
+ assert_file ::File.join(@tmpdir, 'Object', 'cdesc-Object.ri')
assert_file @s.method_file(@klass.full_name, @attr.full_name)
assert_file @s.method_file(@klass.full_name, @cmeth.full_name)
@@ -915,7 +915,7 @@ def test_save_class_merge
@s.save_class @klass
klass = RDoc::NormalClass.new 'Object'
- klass.add_comment 'new comment', @top_level
+ klass.add_comment 'new comment', @file
s = RDoc::RI::Store.new(RDoc::Options.new, path: @tmpdir)
s.save_class klass
@@ -923,7 +923,7 @@ def test_save_class_merge
s = RDoc::RI::Store.new(RDoc::Options.new, path: @tmpdir)
inner = @RM::Document.new @RM::Paragraph.new 'new comment'
- inner.file = @top_level
+ inner.file = @file
document = @RM::Document.new inner
@@ -963,8 +963,8 @@ def test_save_class_merge_constant
def test_save_class_methods
@s.save_class @klass
- assert_directory File.join(@tmpdir, 'Object')
- assert_file File.join(@tmpdir, 'Object', 'cdesc-Object.ri')
+ assert_directory ::File.join(@tmpdir, 'Object')
+ assert_file ::File.join(@tmpdir, 'Object', 'cdesc-Object.ri')
assert_cache nil, nil, nil, %w[Object], 'Object' => OBJECT_ANCESTORS
@@ -974,8 +974,8 @@ def test_save_class_methods
def test_save_class_nested
@s.save_class @nest_klass
- assert_directory File.join(@tmpdir, 'Object', 'SubClass')
- assert_file File.join(@tmpdir, 'Object', 'SubClass', 'cdesc-SubClass.ri')
+ assert_directory ::File.join(@tmpdir, 'Object', 'SubClass')
+ assert_file ::File.join(@tmpdir, 'Object', 'SubClass', 'cdesc-SubClass.ri')
assert_cache({ 'Object::SubClass' => %w[method] }, {}, {},
%w[Object::SubClass], 'Object::SubClass' => %w[Incl Object])
@@ -984,8 +984,8 @@ def test_save_class_nested
def test_save_method
@s.save_method @klass, @meth
- assert_directory File.join(@tmpdir, 'Object')
- assert_file File.join(@tmpdir, 'Object', 'method-i.ri')
+ assert_directory ::File.join(@tmpdir, 'Object')
+ assert_file ::File.join(@tmpdir, 'Object', 'method-i.ri')
assert_cache({ 'Object' => %w[method] }, {}, {}, [])
@@ -997,15 +997,15 @@ def test_save_method_dry_run
@s.save_method @klass, @meth
- refute_file File.join(@tmpdir, 'Object')
- refute_file File.join(@tmpdir, 'Object', 'method-i.ri')
+ refute_file ::File.join(@tmpdir, 'Object')
+ refute_file ::File.join(@tmpdir, 'Object', 'method-i.ri')
end
def test_save_method_nested
@s.save_method @nest_klass, @nest_meth
- assert_directory File.join(@tmpdir, 'Object', 'SubClass')
- assert_file File.join(@tmpdir, 'Object', 'SubClass', 'method-i.ri')
+ assert_directory ::File.join(@tmpdir, 'Object', 'SubClass')
+ assert_file ::File.join(@tmpdir, 'Object', 'SubClass', 'method-i.ri')
assert_cache({ 'Object::SubClass' => %w[method] }, {}, {}, [])
end
@@ -1013,15 +1013,15 @@ def test_save_method_nested
def test_save_page
@s.save_page @page
- assert_file File.join(@tmpdir, 'page-README_txt.ri')
+ assert_file ::File.join(@tmpdir, 'page-README_txt.ri')
assert_cache({}, {}, {}, [], {}, %w[README.txt])
end
def test_save_page_file
- @s.save_page @top_level
+ @s.save_page @file
- refute_file File.join(@tmpdir, 'page-file_rb.ri')
+ refute_file ::File.join(@tmpdir, 'page-file_rb.ri')
end
def test_source
diff --git a/test/rdoc/rdoc_text_test.rb b/test/rdoc/rdoc_text_test.rb
index b691afa0ca..25e1f2d296 100644
--- a/test/rdoc/rdoc_text_test.rb
+++ b/test/rdoc/rdoc_text_test.rb
@@ -12,7 +12,7 @@ def setup
@options = RDoc::Options.new
- @top_level = @store.add_file 'file.rb'
+ @file = @store.add_file 'file.rb'
@language = nil
end
@@ -189,7 +189,7 @@ def test_parse
def test_parse_comment
expected = RDoc::Markup::Document.new
- expected.file = @top_level
+ expected.file = @file
c = comment ''
parsed = parse c
diff --git a/test/rdoc/rdoc_tom_doc_test.rb b/test/rdoc/rdoc_tom_doc_test.rb
index 941d027f24..480cd71933 100644
--- a/test/rdoc/rdoc_tom_doc_test.rb
+++ b/test/rdoc/rdoc_tom_doc_test.rb
@@ -6,7 +6,7 @@ class RDocTomDocTest < RDoc::TestCase
def setup
super
- @top_level = @store.add_file 'file.rb'
+ @file = @store.add_file 'file.rb'
@TD = RDoc::TomDoc
@td = @TD.new
@@ -66,7 +66,7 @@ def test_class_signature_no_space
list(:NOTE,
item(%w[here],
para('something'))))
- expected.file = @top_level
+ expected.file = @file
assert_equal expected, c.parse
end
@@ -114,7 +114,7 @@ def test_class_signature_two_space
list(:NOTE,
item(%w[here],
para('something'))))
- expected.file = @top_level
+ expected.file = @file
assert_equal expected, c.parse
end
diff --git a/test/rdoc/ri/driver_test.rb b/test/rdoc/ri/driver_test.rb
index 2d1a2ce741..118c22ffee 100644
--- a/test/rdoc/ri/driver_test.rb
+++ b/test/rdoc/ri/driver_test.rb
@@ -6,12 +6,12 @@ class RDocRIDriverTest < RDoc::TestCase
def setup
super
- @home_ri = File.join @test_home, 'dot_ri'
+ @home_ri = ::File.join @test_home, 'dot_ri'
FileUtils.mkdir_p @home_ri
@orig_ri = ENV.delete('RI')
- @rdoc_home = File.join @test_home, ".rdoc"
+ @rdoc_home = ::File.join @test_home, ".rdoc"
FileUtils.mkdir_p @rdoc_home
@options = RDoc::RI::Driver.default_options
@@ -965,10 +965,10 @@ def test_expand_class
def test_expand_class_2
@store1 = RDoc::RI::Store.new(@rdoc_options, path: @home_ri, type: :home)
- @top_level = @store1.add_file 'file.rb'
+ @file = @store1.add_file 'file.rb'
- @cFoo = @top_level.add_class RDoc::NormalClass, 'Foo'
- @mFox = @top_level.add_module RDoc::NormalModule, 'Fox'
+ @cFoo = @file.add_class RDoc::NormalClass, 'Foo'
+ @mFox = @file.add_module RDoc::NormalModule, 'Fox'
@cFoo_Bar = @cFoo.add_class RDoc::NormalClass, 'Bar'
@store1.save
@@ -983,10 +983,10 @@ def test_expand_class_2
def test_expand_class_3
@store1 = RDoc::RI::Store.new(@rdoc_options, path: @home_ri, type: :home)
- @top_level = @store1.add_file 'file.rb'
+ @file = @store1.add_file 'file.rb'
- @cFoo = @top_level.add_class RDoc::NormalClass, 'Foo'
- @mFox = @top_level.add_module RDoc::NormalModule, 'FooBar'
+ @cFoo = @file.add_class RDoc::NormalClass, 'Foo'
+ @mFox = @file.add_module RDoc::NormalModule, 'FooBar'
@store1.save
@driver.stores = [@store1]
@@ -1209,12 +1209,12 @@ def test_list_methods_matching_regexp
util_store
index = RDoc::AnyMethod.new nil, '[]'
- index.record_location @top_level
+ index.record_location @file
@cFoo.add_method index
@store1.save_method @cFoo, index
c_index = RDoc::AnyMethod.new nil, '[]', singleton: true
- c_index.record_location @top_level
+ c_index.record_location @file
@cFoo.add_method c_index
@store1.save_method @cFoo, c_index
@@ -1515,22 +1515,22 @@ def util_multi_store
@home_ri2 = "#{@home_ri}2"
@store2 = RDoc::RI::Store.new(@rdoc_options, path: @home_ri2)
- @top_level = @store2.add_file 'file.rb'
+ @file = @store2.add_file 'file.rb'
# as if seen in a namespace like class Ambiguous::Other
- @mAmbiguous = @top_level.add_module RDoc::NormalModule, 'Ambiguous'
+ @mAmbiguous = @file.add_module RDoc::NormalModule, 'Ambiguous'
- @cFoo = @top_level.add_class RDoc::NormalClass, 'Foo'
+ @cFoo = @file.add_class RDoc::NormalClass, 'Foo'
- @cBar = @top_level.add_class RDoc::NormalClass, 'Bar', 'Foo'
+ @cBar = @file.add_class RDoc::NormalClass, 'Bar', 'Foo'
@cFoo_Baz = @cFoo.add_class RDoc::NormalClass, 'Baz'
@baz = @cBar.add_method RDoc::AnyMethod.new(nil, 'baz')
- @baz.record_location @top_level
+ @baz.record_location @file
@override = @cBar.add_method RDoc::AnyMethod.new(nil, 'override')
@override.comment = 'must be displayed'
- @override.record_location @top_level
+ @override.record_location @file
@store2.save
@@ -1540,66 +1540,66 @@ def util_multi_store
def util_store
@store1 = RDoc::RI::Store.new(@rdoc_options, path: @home_ri, type: :home)
- @top_level = @store1.add_file 'file.rb'
+ @file = @store1.add_file 'file.rb'
@readme = @store1.add_file 'README.md'
@readme.parser = RDoc::Parser::Simple
@readme.comment = RDoc::Comment.from_document(doc(head(1, 'README'), para('This is a README')))
- @cFoo = @top_level.add_class RDoc::NormalClass, 'Foo'
- @mExt = @top_level.add_module RDoc::NormalModule, 'Ext'
- @mInc = @top_level.add_module RDoc::NormalModule, 'Inc'
- @cAmbiguous = @top_level.add_class RDoc::NormalClass, 'Ambiguous'
+ @cFoo = @file.add_class RDoc::NormalClass, 'Foo'
+ @mExt = @file.add_module RDoc::NormalModule, 'Ext'
+ @mInc = @file.add_module RDoc::NormalModule, 'Inc'
+ @cAmbiguous = @file.add_class RDoc::NormalClass, 'Ambiguous'
doc = @RM::Document.new @RM::Paragraph.new('Extend thingy')
@cFooExt = @cFoo.add_extend RDoc::Extend.new('Ext', RDoc::Comment.from_document(doc))
- @cFooExt.record_location @top_level
+ @cFooExt.record_location @file
doc = @RM::Document.new @RM::Paragraph.new('Include thingy')
@cFooInc = @cFoo.add_include RDoc::Include.new('Inc', RDoc::Comment.from_document(doc))
- @cFooInc.record_location @top_level
+ @cFooInc.record_location @file
@cFoo_Bar = @cFoo.add_class RDoc::NormalClass, 'Bar'
- @cFoo_Bar.add_comment "See also {Doc}[rdoc-ref:README.md]", @top_level
- @cFoo_Bar.record_location @top_level
+ @cFoo_Bar.add_comment "See also {Doc}[rdoc-ref:README.md]", @file
+ @cFoo_Bar.record_location @file
@blah = @cFoo_Bar.add_method RDoc::AnyMethod.new(nil, 'blah')
@blah.call_seq = "blah(5) => 5\nblah(6) => 6\n"
- @blah.record_location @top_level
+ @blah.record_location @file
@blah_with_rdoc_ref = @cFoo_Bar.add_method RDoc::AnyMethod.new(nil, 'blah_with_rdoc_ref')
@blah_with_rdoc_ref.call_seq = "blah(5) => 5\nSee also {Doc}[rdoc-ref:README.md]"
- @blah_with_rdoc_ref.record_location @top_level
+ @blah_with_rdoc_ref.record_location @file
@bother = @cFoo_Bar.add_method RDoc::AnyMethod.new(nil, 'bother')
@bother.block_params = "stuff"
@bother.params = "(things)"
- @bother.record_location @top_level
+ @bother.record_location @file
@new = @cFoo_Bar.add_method RDoc::AnyMethod.new nil, 'new', singleton: true
- @new.record_location @top_level
+ @new.record_location @file
@attr = @cFoo_Bar.add_attribute RDoc::Attr.new nil, 'attr', 'RW', ''
- @attr.record_location @top_level
+ @attr.record_location @file
@cFoo_Baz = @cFoo.add_class RDoc::NormalClass, 'Baz'
- @cFoo_Baz.record_location @top_level
+ @cFoo_Baz.record_location @file
@inherit = @cFoo.add_method RDoc::AnyMethod.new(nil, 'inherit')
- @inherit.record_location @top_level
+ @inherit.record_location @file
# overridden by Bar in multi_store
@overridden = @cFoo.add_method RDoc::AnyMethod.new(nil, 'override')
@overridden.comment = 'must not be displayed in Bar#override'
- @overridden.record_location @top_level
+ @overridden.record_location @file
- @cQux = @top_level.add_class RDoc::NormalClass, 'Qux'
+ @cQux = @file.add_class RDoc::NormalClass, 'Qux'
@original = @cQux.add_method RDoc::AnyMethod.new(nil, 'original')
@original.comment = 'original comment'
- @original.record_location @top_level
+ @original.record_location @file
@aliased = @original.add_alias RDoc::Alias.new(nil, 'original', 'aliased', 'alias comment'), @cQux
- @aliased.record_location @top_level
+ @aliased.record_location @file
@store1.save
diff --git a/test/rdoc/ri/paths_test.rb b/test/rdoc/ri/paths_test.rb
index 97af41fd9d..b090ecb16e 100644
--- a/test/rdoc/ri/paths_test.rb
+++ b/test/rdoc/ri/paths_test.rb
@@ -9,7 +9,7 @@ def setup
@orig_env = ENV.to_hash
@orig_gem_path = Gem.path
- @tempdir = File.join Dir.tmpdir, "test_rdoc_ri_paths_#{$$}"
+ @tempdir = ::File.join Dir.tmpdir, "test_rdoc_ri_paths_#{$$}"
Gem.use_paths @tempdir
Gem.ensure_gem_subdirectories @tempdir
@@ -23,11 +23,11 @@ def setup
specs.each do |spec|
spec.loaded_from = spec.spec_file
- File.open spec.spec_file, 'w' do |file|
+ ::File.open spec.spec_file, 'w' do |file|
file.write spec.to_ruby_for_cache
end
- FileUtils.mkdir_p File.join(spec.doc_dir, 'ri') unless
+ FileUtils.mkdir_p ::File.join(spec.doc_dir, 'ri') unless
spec.name == 'nodoc'
end
@@ -52,10 +52,10 @@ def test_class_each
assert_equal RDoc::RI::Paths.system_dir, path.shift
assert_equal RDoc::RI::Paths.site_dir, path.shift
assert_equal RDoc::RI::Paths.home_dir, path.shift if RDoc::RI::Paths.home_dir
- assert_equal File.join(@nodoc.doc_dir, 'ri'), path.shift
- assert_equal File.join(@rake_10.doc_dir, 'ri'), path.shift
- assert_equal File.join(@rdoc_4_0.doc_dir, 'ri'), path.shift
- assert_equal File.join(@rdoc_3_12.doc_dir, 'ri'), path.shift
+ assert_equal ::File.join(@nodoc.doc_dir, 'ri'), path.shift
+ assert_equal ::File.join(@rake_10.doc_dir, 'ri'), path.shift
+ assert_equal ::File.join(@rdoc_4_0.doc_dir, 'ri'), path.shift
+ assert_equal ::File.join(@rdoc_3_12.doc_dir, 'ri'), path.shift
assert_empty path
end
@@ -64,8 +64,8 @@ def test_class_gemdirs_latest
gemdirs = RDoc::RI::Paths.gemdirs :latest
expected = [
- File.join(@rake_10.doc_dir, 'ri'),
- File.join(@rdoc_4_0.doc_dir, 'ri'),
+ ::File.join(@rake_10.doc_dir, 'ri'),
+ ::File.join(@rdoc_4_0.doc_dir, 'ri'),
]
assert_equal expected, gemdirs
@@ -77,8 +77,8 @@ def test_class_gemdirs_legacy
gemdirs = RDoc::RI::Paths.gemdirs true
expected = [
- File.join(@rake_10.doc_dir, 'ri'),
- File.join(@rdoc_4_0.doc_dir, 'ri'),
+ ::File.join(@rake_10.doc_dir, 'ri'),
+ ::File.join(@rdoc_4_0.doc_dir, 'ri'),
]
assert_equal expected, gemdirs
@@ -90,10 +90,10 @@ def test_class_gemdirs_all
gemdirs = RDoc::RI::Paths.gemdirs :all
expected = [
- File.join(@nodoc.doc_dir, 'ri'),
- File.join(@rake_10.doc_dir, 'ri'),
- File.join(@rdoc_4_0.doc_dir, 'ri'),
- File.join(@rdoc_3_12.doc_dir, 'ri'),
+ ::File.join(@nodoc.doc_dir, 'ri'),
+ ::File.join(@rake_10.doc_dir, 'ri'),
+ ::File.join(@rdoc_4_0.doc_dir, 'ri'),
+ ::File.join(@rdoc_3_12.doc_dir, 'ri'),
]
assert_equal expected, gemdirs
@@ -103,7 +103,7 @@ def test_class_gemdirs_all
def test_class_gem_dir
dir = RDoc::RI::Paths.gem_dir 'rake', '10.0.1'
- expected = File.join @rake_10.doc_dir, 'ri'
+ expected = ::File.join @rake_10.doc_dir, 'ri'
assert_equal expected, dir
end
@@ -116,7 +116,7 @@ def test_class_home_dir
def test_class_path_nonexistent
temp_dir do |dir|
- nonexistent = File.join dir, 'nonexistent'
+ nonexistent = ::File.join dir, 'nonexistent'
dir = RDoc::RI::Paths.path true, true, true, true, nonexistent
refute_includes dir, nonexistent
@@ -129,7 +129,7 @@ def test_class_raw_path
assert_equal RDoc::RI::Paths.system_dir, path.shift
assert_equal RDoc::RI::Paths.site_dir, path.shift
assert_equal RDoc::RI::Paths.home_dir, path.shift if RDoc::RI::Paths.home_dir
- assert_equal File.join(@rake_10.doc_dir, 'ri'), path.shift
+ assert_equal ::File.join(@rake_10.doc_dir, 'ri'), path.shift
end
def test_class_raw_path_extra_dirs
@@ -139,19 +139,19 @@ def test_class_raw_path_extra_dirs
assert_equal RDoc::RI::Paths.system_dir, path.shift
assert_equal RDoc::RI::Paths.site_dir, path.shift
assert_equal RDoc::RI::Paths.home_dir, path.shift if RDoc::RI::Paths.home_dir
- assert_equal File.join(@rake_10.doc_dir, 'ri'), path.shift
+ assert_equal ::File.join(@rake_10.doc_dir, 'ri'), path.shift
end
def test_class_site_dir
dir = RDoc::RI::Paths.site_dir
- assert_equal File.join(RDoc::RI::Paths::BASE, 'site'), dir
+ assert_equal ::File.join(RDoc::RI::Paths::BASE, 'site'), dir
end
def test_class_system_dir
dir = RDoc::RI::Paths.system_dir
- assert_equal File.join(RDoc::RI::Paths::BASE, 'system'), dir
+ assert_equal ::File.join(RDoc::RI::Paths::BASE, 'system'), dir
end
end
diff --git a/test/rdoc/support/test_case.rb b/test/rdoc/support/test_case.rb
index cb1a3bddd9..3195878a24 100644
--- a/test/rdoc/support/test_case.rb
+++ b/test/rdoc/support/test_case.rb
@@ -44,7 +44,7 @@ def setup
FileUtils.mkdir_p(@test_home = Dir.mktmpdir("test_rdoc_"))
ENV["HOME"] = @test_home
- @top_level = nil
+ @file = nil
@RM = RDoc::Markup
@@ -76,21 +76,21 @@ def teardown
# Asserts +path+ is a file
def assert_file(path)
- assert File.file?(path), "#{path} is not a file"
+ assert ::File.file?(path), "#{path} is not a file"
end
##
# Asserts +path+ is a directory
def assert_directory(path)
- assert File.directory?(path), "#{path} is not a directory"
+ assert ::File.directory?(path), "#{path} is not a directory"
end
##
# Refutes +path+ exists
def refute_file(path)
- refute File.exist?(path), "#{path} exists"
+ refute ::File.exist?(path), "#{path} exists"
end
##
@@ -108,11 +108,11 @@ def block *contents
end
##
- # Creates an RDoc::Comment with +text+ which was defined on +top_level+.
+ # Creates an RDoc::Comment with +text+ which was defined on +file+.
# By default the comment has the 'rdoc' format.
- def comment(text, top_level = @top_level, language = nil)
- comment = RDoc::Comment.new text, top_level, language
+ def comment(text, file = @file, language = nil)
+ comment = RDoc::Comment.new text, file, language
comment
end
diff --git a/test/rdoc/xref_test_case.rb b/test/rdoc/xref_test_case.rb
index 4c3e3166b2..9a55ca50b9 100644
--- a/test/rdoc/xref_test_case.rb
+++ b/test/rdoc/xref_test_case.rb
@@ -2,7 +2,7 @@
ENV['RDOC_TEST'] = 'yes'
require_relative 'helper'
-require File.expand_path '../xref_data', __FILE__
+require ::File.expand_path '../xref_data', __FILE__
class XrefTestCase < RDoc::TestCase
@@ -13,7 +13,7 @@ def setup
@file_name = 'xref_data.rb'
@xref_data = @store.add_file @file_name
- @top_level = @xref_data
+ @file = @xref_data
stats = RDoc::Stats.new @store, 0
@@ -22,9 +22,9 @@ def setup
@example_md = @store.add_file 'EXAMPLE.md'
@example_md.parser = RDoc::Parser::Markdown
- @top_levels = []
- @top_levels.push parser.scan
- @top_levels.push @example_md
+ @files = []
+ @files.push parser.scan
+ @files.push @example_md
generator = Object.new
@rdoc.generator = generator