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 655
def self.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 659
def self.find_class_named(name)
 @@all_classes.each_value do |c|
    res = c.find_class_named(name) 
    return res if res
  end
  nil
end
            
find_file_named(name) click to toggle source
 
               # File rdoc/code_objects.rb, line 667
def self.find_file_named(name)
  @@all_files[name]
end
            
new(file_name) click to toggle source
 
               # File rdoc/code_objects.rb, line 594
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
  @@all_files[file_name] = self
end
            
reset() click to toggle source
 
               # File rdoc/code_objects.rb, line 588
def self.reset
  @@all_classes = {}
  @@all_modules = {}
  @@all_files   = {}
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 618
def add_class_or_module(collection, class_type, name, superclass)
  cls = collection[name]

  if cls then
    cls.superclass = superclass unless cls.module?
    puts "Reusing class/module #{cls.full_name}" if $DEBUG_RDOC
  else
    if class_type == NormalModule then
      all = @@all_modules
    else
      all = @@all_classes
    end

    cls = all[name]

    if !cls then
      cls = class_type.new name, superclass
      all[name] = cls unless @done_documenting
    else
      # If the class has been encountered already, check that its
      # superclass has been set (it may not have been, depending on
      # the context in which it was encountered).
      if class_type == NormalClass
        if !cls.superclass then
          cls.superclass = superclass
        end
      end
    end

    collection[name] = cls unless @done_documenting

    cls.parent = self
  end

  cls
end
            
file_base_name() click to toggle source
 
               # File rdoc/code_objects.rb, line 604
def file_base_name
  File.basename @file_absolute_name
end
            
find_class_or_module_named(symbol) click to toggle source
 
               # File rdoc/code_objects.rb, line 675
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 671
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 684
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 608
def full_name
  nil
end
            
inspect() click to toggle source
 
               # File rdoc/code_objects.rb, line 688
def inspect
  "#<%s:0x%x %p modules: %p classes: %p>" % [
    self.class, object_id,
    file_base_name,
    @modules.map { |n,m| m },
    @classes.map { |n,c| c }
  ]
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