Skip to content

Commit d6c5cf5

Browse files
committed
Rename TopLevel to File
1 parent e14946f commit d6c5cf5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+1769
-1756
lines changed

TODO.rdoc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ Forward Looking Statements applies.
4343
the middle of a method section.
4444
* RDoc::CodeObject
4545
* Move into own namespace
46-
* Rename TopLevel to File
4746
* Rename Context to Container
4847
* Rename NormalClass to Class
4948

lib/rdoc.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,21 +131,21 @@ def self.load_yaml
131131

132132
def self.home
133133
rdoc_dir = begin
134-
File.expand_path('~/.rdoc')
134+
::File.expand_path('~/.rdoc')
135135
rescue ArgumentError
136136
end
137137

138-
if File.directory?(rdoc_dir)
138+
if ::File.directory?(rdoc_dir)
139139
rdoc_dir
140140
else
141141
require 'fileutils'
142142
begin
143143
# XDG
144-
xdg_data_home = ENV["XDG_DATA_HOME"] || File.join(File.expand_path("~"), '.local', 'share')
145-
unless File.exist?(xdg_data_home)
144+
xdg_data_home = ENV["XDG_DATA_HOME"] || ::File.join(::File.expand_path("~"), '.local', 'share')
145+
unless ::File.exist?(xdg_data_home)
146146
FileUtils.mkdir_p xdg_data_home
147147
end
148-
File.join xdg_data_home, "rdoc"
148+
::File.join xdg_data_home, "rdoc"
149149
rescue Errno::EACCES
150150
end
151151
end
@@ -187,7 +187,8 @@ def self.home
187187
autoload :CodeObject, "#{__dir__}/rdoc/code_object"
188188

189189
autoload :Context, "#{__dir__}/rdoc/code_object/context"
190-
autoload :TopLevel, "#{__dir__}/rdoc/code_object/top_level"
190+
autoload :File, "#{__dir__}/rdoc/code_object/file"
191+
autoload :TopLevel, "#{__dir__}/rdoc/code_object/top_level" # @deprecated Use RDoc::File instead
191192

192193
autoload :AnonClass, "#{__dir__}/rdoc/code_object/anon_class"
193194
autoload :ClassModule, "#{__dir__}/rdoc/code_object/class_module"

lib/rdoc/code_object.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# Here's the tree of the CodeObject subclasses:
99
#
1010
# * RDoc::Context
11-
# * RDoc::TopLevel
11+
# * RDoc::File
1212
# * RDoc::ClassModule
1313
# * RDoc::AnonClass (never used so far)
1414
# * RDoc::NormalClass
@@ -291,7 +291,7 @@ def parent
291291
return @parent if @parent
292292
return nil unless @parent_name
293293

294-
if @parent_class == RDoc::TopLevel then
294+
if @parent_class == RDoc::File then
295295
@parent = @store.add_file @parent_name
296296
else
297297
@parent = @store.find_class_or_module @parent_name
@@ -314,12 +314,12 @@ def parent_name
314314
end
315315

316316
##
317-
# Records the RDoc::TopLevel (file) where this code object was defined
317+
# Records the RDoc::File (file) where this code object was defined
318318

319-
def record_location(top_level)
319+
def record_location(file)
320320
@ignored = false
321321
@suppressed = false
322-
@file = top_level
322+
@file = file
323323
end
324324

325325
##

lib/rdoc/code_object/any_method.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def marshal_load(array)
217217
name.join '::'
218218
end
219219

220-
@file = RDoc::TopLevel.new array[10] if version > 0
220+
@file = RDoc::File.new array[10] if version > 0
221221
end
222222

223223
##

lib/rdoc/code_object/attr.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def marshal_load(array)
140140
@parent_class = array[9]
141141
@section_title = array[10]
142142

143-
@file = RDoc::TopLevel.new array[7] if version > 1
143+
@file = RDoc::File.new array[7] if version > 1
144144

145145
@parent_name ||= @full_name.split('#', 2).first
146146
end

lib/rdoc/code_object/class_module.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ def marshal_load(array) # :nodoc:
393393

394394
add_attribute attr
395395
attr.visibility = visibility
396-
attr.record_location RDoc::TopLevel.new file
396+
attr.record_location RDoc::File.new file
397397
end
398398

399399
array[6].each do |constant, document, file|
@@ -402,13 +402,13 @@ def marshal_load(array) # :nodoc:
402402
add_constant constant
403403
else
404404
constant = add_constant RDoc::Constant.new(constant, nil, RDoc::Comment.from_document(document))
405-
constant.record_location RDoc::TopLevel.new file
405+
constant.record_location RDoc::File.new file
406406
end
407407
end
408408

409409
array[7].each do |name, document, file|
410410
incl = add_include RDoc::Include.new(name, RDoc::Comment.from_document(document))
411-
incl.record_location RDoc::TopLevel.new file
411+
incl.record_location RDoc::File.new file
412412
end
413413

414414
array[8].each do |type, visibilities|
@@ -417,15 +417,15 @@ def marshal_load(array) # :nodoc:
417417

418418
methods.each do |name, file|
419419
method = RDoc::AnyMethod.new nil, name, singleton: type == 'class'
420-
method.record_location RDoc::TopLevel.new file
420+
method.record_location RDoc::File.new file
421421
add_method method
422422
end
423423
end
424424
end
425425

426426
array[9].each do |name, document, file|
427427
ext = add_extend RDoc::Extend.new(name, RDoc::Comment.from_document(document))
428-
ext.record_location RDoc::TopLevel.new file
428+
ext.record_location RDoc::File.new file
429429
end if array[9] # Support Marshal version 1
430430

431431
sections = (array[10] || []).map do |section|
@@ -438,7 +438,7 @@ def marshal_load(array) # :nodoc:
438438
@in_files = []
439439

440440
(array[11] || []).each do |filename|
441-
record_location RDoc::TopLevel.new filename
441+
record_location RDoc::File.new filename
442442
end
443443

444444
@parent_name = array[12]
@@ -632,7 +632,7 @@ def parse(comment_location)
632632
def path
633633
prefix = options.class_module_path_prefix
634634
return http_url unless prefix
635-
File.join(prefix, http_url)
635+
::File.join(prefix, http_url)
636636
end
637637

638638
##
@@ -795,7 +795,7 @@ def update_aliases
795795
cm_alias.name = const.name
796796

797797
# Don't move top-level aliases under Object, they look ugly there
798-
unless RDoc::TopLevel === cm_alias.parent then
798+
unless RDoc::File === cm_alias.parent then
799799
cm_alias.parent = self
800800
cm_alias.full_name = nil # force update for new parent
801801
end

lib/rdoc/code_object/constant.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def marshal_load(array)
144144
@parent_class = array[8]
145145
@section_title = array[9]
146146

147-
@file = RDoc::TopLevel.new array[6]
147+
@file = RDoc::File.new array[6]
148148
end
149149

150150
##

lib/rdoc/code_object/context.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ def add_class(class_type, given_name, superclass = '::Object')
361361
klass = @store.classes_hash[full_name]
362362

363363
if klass then
364-
# if TopLevel, it may not be registered in the classes:
364+
# if File, it may not be registered in the classes:
365365
enclosing.classes_hash[name] = klass
366366

367367
# update the superclass if needed
@@ -397,7 +397,7 @@ def add_class(class_type, given_name, superclass = '::Object')
397397
##
398398
# Adds the class or module +mod+ to the modules or
399399
# classes Hash +self_hash+, and to +all_hash+ (either
400-
# <tt>TopLevel::modules_hash</tt> or <tt>TopLevel::classes_hash</tt>),
400+
# <tt>File::modules_hash</tt> or <tt>File::classes_hash</tt>),
401401
# unless #done_documenting is +true+. Sets the #parent of +mod+
402402
# to +self+, and its #section to #current_section. Returns +mod+.
403403

@@ -568,7 +568,7 @@ def add_module_alias(from, from_name, to, file)
568568
def add_require(require)
569569
return require unless @document_self
570570

571-
if RDoc::TopLevel === self then
571+
if RDoc::File === self then
572572
add_to @requires, require
573573
else
574574
parent.add_require require
@@ -632,7 +632,7 @@ def any_content(includes = true)
632632
def child_name(name)
633633
if name =~ /^:+/
634634
$' #'
635-
elsif RDoc::TopLevel === self then
635+
elsif RDoc::File === self then
636636
name
637637
else
638638
"#{self.full_name}::#{name}"
@@ -894,14 +894,14 @@ def find_symbol_module(symbol)
894894
mod = searched.find_module_named(top)
895895
break unless mod
896896
result = @store.find_class_or_module "#{mod.full_name}::#{suffix}"
897-
break if result || searched.is_a?(RDoc::TopLevel)
897+
break if result || searched.is_a?(RDoc::File)
898898
searched = searched.parent
899899
end
900900
else
901901
searched = self
902902
while searched do
903903
result = searched.find_module_named(symbol)
904-
break if result || searched.is_a?(RDoc::TopLevel)
904+
break if result || searched.is_a?(RDoc::File)
905905
searched = searched.parent
906906
end
907907
end
@@ -936,7 +936,7 @@ def http_url
936936
path = path.gsub(/<<\s*(\w*)/, 'from-\1') if path =~ /<</
937937
path = path.split('::')
938938

939-
File.join(*path.compact) + '.html'
939+
::File.join(*path.compact) + '.html'
940940
end
941941

942942
##
@@ -1033,10 +1033,10 @@ def ongoing_visibility=(visibility)
10331033
end
10341034

10351035
##
1036-
# Record +top_level+ as a file +self+ is in.
1036+
# Record +file+ as a file +self+ is in.
10371037

1038-
def record_location(top_level)
1039-
@in_files << top_level unless @in_files.include?(top_level)
1038+
def record_location(file)
1039+
@in_files << file unless @in_files.include?(file)
10401040
end
10411041

10421042
##
@@ -1197,7 +1197,7 @@ def to_s # :nodoc:
11971197
def top_level
11981198
return @top_level if defined? @top_level
11991199
@top_level = self
1200-
@top_level = @top_level.parent until RDoc::TopLevel === @top_level
1200+
@top_level = @top_level.parent until RDoc::File === @top_level
12011201
@top_level
12021202
end
12031203

0 commit comments

Comments
 (0)