A TopLevel context is a representation of the contents of a single file
- #
- A
- B
- C
- E
- F
- H
- L
- M
- N
- O
- P
- R
- U
[RW] | absolute_name | Absolute name of this file |
[R] | classes_or_modules | All the classes or modules that were declared in this file. These are
assigned to either |
[RW] | file_stat | This TopLevel's File::Stat struct |
[RW] | parser | The parser that processed this file |
[RW] | relative_name | Relative name of this file |
Returns all classes and modules discovered by RDoc
Prepares the RDoc code object tree for use by a generator.
It finds unique classes/modules defined, and replaces classes/modules that are aliases for another one by a copy with RDoc::ClassModule#is_alias_for set.
It updates the RDoc::ClassModule#constant_aliases attribute of “real” classes or modules.
It also completely removes the classes and modules that should be removed
from the documentation and the methods that have a visibility below
min_visibility
, which is the --visibility
option.
# File ../ruby/lib/rdoc/top_level.rb, line 102 def self.complete min_visibility fix_basic_object_inheritance # cache included modules before they are removed from the documentation all_classes_and_modules.each { |cm| cm.ancestors } remove_nodoc @all_classes_hash remove_nodoc @all_modules_hash @unique_classes = find_unique @all_classes_hash @unique_modules = find_unique @all_modules_hash unique_classes_and_modules.each do |cm| cm.complete min_visibility end @all_files_hash.each_key do |file_name| tl = @all_files_hash[file_name] unless RDoc::Parser::Simple === tl.parser then tl.modules_hash.clear tl.classes_hash.clear tl.classes_or_modules.each do |cm| name = cm.full_name if cm.type == 'class' then tl.classes_hash[name] = cm if @all_classes_hash[name] else tl.modules_hash[name] = cm if @all_modules_hash[name] end end end end end
Finds the class with name
in all discovered classes
Finds the class with name
starting in namespace
from
# File ../ruby/lib/rdoc/top_level.rb, line 147 def self.find_class_named_from name, from from = find_class_named from unless RDoc::Context === from until RDoc::TopLevel === from do return nil unless from klass = from.find_class_named name return klass if klass from = from.parent end find_class_named name end
Finds the class or module with name
Finds the file with name
in all discovered files
Finds the module with name
in all discovered modules
Finds unique classes/modules defined in all_hash
, and returns
them as an array. Performs the alias updates in all_hash
: see
::complete.
Fixes the erroneous BasicObject < Object
in 1.9.
Because we assumed all classes without a stated superclass inherit from Object, we have the above wrong inheritance.
We fix BasicObject right away if we are running in a Ruby version >= 1.9. If not, we may be documenting 1.9 source while running under 1.8: we search the files of BasicObject for “object.c”, and fix the inheritance if we find it.
# File ../ruby/lib/rdoc/top_level.rb, line 212 def self.fix_basic_object_inheritance basic = all_classes_hash['BasicObject'] return unless basic if RUBY_VERSION >= '1.9' basic.superclass = nil elsif basic.in_files.any? { |f| File.basename(f.full_name) == 'object.c' } basic.superclass = nil end end
Creates a new TopLevel for
file_name
# File ../ruby/lib/rdoc/top_level.rb, line 298 def initialize(file_name) super() @name = nil @relative_name = file_name @absolute_name = file_name @file_stat = File.stat(file_name) rescue nil # HACK for testing @diagram = nil @parser = nil @classes_or_modules = [] RDoc::TopLevel.files_hash[file_name] = self end
Creates a new RDoc::TopLevel with
file_name
only if one with the same name does not exist in
all_files.
Removes from all_hash
the contexts that are nodoc or have no
content.
Empties RDoc of stored class, module and file information
Returns the unique classes discovered by RDoc.
::complete must have been called prior to using this method.
Returns the unique classes and modules discovered by RDoc. ::complete must have been called prior to using this method.
Returns the unique modules discovered by RDoc. ::complete must have been called prior to using this method.
An RDoc::TopLevel is equal to another with the same #absolute_name
Adds an_alias
to Object
instead of
self
.
Adds constant
to Object
instead of
self
.
Adds include
to Object
instead of
self
.
Adds method
to Object
instead of
self
.
Adds class or module mod
. Used in the building phase by the
ruby parser.
Returns a URL for this source file on some web repository. Use the -W command line option to set.
Finds a class or module named symbol
Finds a module or class with name
Returns the relative name of this file
An RDoc::TopLevel has the same hash as another with the same #absolute_name
URL for this with a prefix
Returns the NormalClass “Object”, creating it if not found.
Records self
as a location in “Object”.