In Files

  • rdoc/code_objects.rb
  • rdoc/rdoc.rb

Files

Class/Module Index [+]

Quicksearch

RDoc::TopLevel

A TopLevel context is a source file

Attributes

diagram[RW]
file_absolute_name[RW]
file_relative_name[RW]
file_stat[RW]

Public Class Methods

all_classes_and_modules() click to toggle source
 
               # File rdoc/code_objects.rb, line 518
def TopLevel.all_classes_and_modules
  @@all_classes.values + @@all_modules.values
end
            
find_class_named(name) click to toggle source
 
               # File rdoc/code_objects.rb, line 522
def TopLevel.find_class_named(name)
 @@all_classes.each_value do |c|
    res = c.find_class_named(name) 
    return res if res
  end
  nil
end
            
new(file_name) click to toggle source
 
               # File rdoc/code_objects.rb, line 477
def initialize(file_name)
  super()
  @name = "TopLevel"
  @file_relative_name = file_name
  @file_absolute_name = file_name
  @file_stat          = File.stat(file_name)
  @diagram            = nil
end
            
reset() click to toggle source
 
               # File rdoc/code_objects.rb, line 472
def TopLevel::reset
  @@all_classes = {}
  @@all_modules = {}
end
            

Public Instance Methods

add_class_or_module(collection, class_type, name, superclass) click to toggle source

Adding a class or module to a TopLevel is special, as we only want one copy of a particular top-level class. For example, if both file A and file B implement class C, we only want one ClassModule object for C. This code arranges to share classes and modules between files.

 
               # File rdoc/code_objects.rb, line 496
def add_class_or_module(collection, class_type, name, superclass)
  cls = collection[name]
  if cls
    puts "Reusing class/module #{name}" if $DEBUG
  else
    if class_type == NormalModule
      all = @@all_modules
    else
      all = @@all_classes
    end
    cls = all[name]
    if !cls
      cls = class_type.new(name, superclass)
      all[name] = cls  unless @done_documenting
    end
    puts "Adding class/module #{name} to #@name" if $DEBUG
    collection[name] = cls unless @done_documenting
    cls.parent = self
  end
  cls
end
            
find_class_or_module_named(symbol) click to toggle source
 
               # File rdoc/code_objects.rb, line 534
def find_class_or_module_named(symbol)
  @@all_classes.each_value {|c| return c if c.name == symbol}
  @@all_modules.each_value {|m| return m if m.name == symbol}
  nil
end
            
find_local_symbol(symbol) click to toggle source
 
               # File rdoc/code_objects.rb, line 530
def find_local_symbol(symbol)
  find_class_or_module_named(symbol) || super
end
            
find_module_named(name) click to toggle source

Find a named module

 
               # File rdoc/code_objects.rb, line 541
def find_module_named(name)
  find_class_or_module_named(name) || find_enclosing_module_named(name)
end
            
full_name() click to toggle source
 
               # File rdoc/code_objects.rb, line 486
def full_name
  nil
end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus