Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion TODO.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 7 additions & 6 deletions lib/rdoc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
10 changes: 5 additions & 5 deletions lib/rdoc/code_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

##
Expand Down
2 changes: 1 addition & 1 deletion lib/rdoc/code_object/any_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

##
Expand Down
2 changes: 1 addition & 1 deletion lib/rdoc/code_object/attr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions lib/rdoc/code_object/class_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand All @@ -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|
Expand All @@ -417,15 +417,15 @@ 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
end

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|
Expand All @@ -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]
Expand Down Expand Up @@ -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

##
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/rdoc/code_object/constant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

##
Expand Down
38 changes: 20 additions & 18 deletions lib/rdoc/code_object/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
# <tt>TopLevel::modules_hash</tt> or <tt>TopLevel::classes_hash</tt>),
# <tt>File::modules_hash</tt> or <tt>File::classes_hash</tt>),
# unless #done_documenting is +true+. Sets the #parent of +mod+
# to +self+, and its #section to #current_section. Returns +mod+.

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

##
Expand Down Expand Up @@ -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

##
Expand Down Expand Up @@ -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+

Expand Down
Loading