Class: RDoc::TopLevel

Inherits:
Object
  • Object
show all
Defined in:
lib/gerbil/rdoc.rb

Class Method Summary collapse

Class Method Details

.all_classesObject

Returns an array of all classes recorded thus far.



11
12
13
# File 'lib/gerbil/rdoc.rb', line 11

def self.all_classes
  @@all_classes.values
end

.all_methodsObject

Returns an array of RDoc::AnyMethod objects representing all methods recorded thus far.



22
23
24
# File 'lib/gerbil/rdoc.rb', line 22

def self.all_methods
  all_classes_and_modules.map {|c| c.method_list }.flatten
end

.all_modulesObject

Returns an array of all modules recorded thus far.



16
17
18
# File 'lib/gerbil/rdoc.rb', line 16

def self.all_modules
  @@all_modules.values
end

.parse(aCodeString, aFileName = __FILE__) ⇒ Object

Returns a RDoc::TopLevel object containing information parsed from the given code string. This information is also added to the global TopLevel class state, so you can access it via the class methods of the TopLevel class.

If the file name (which signifies the origin of the given code) is given, it MUST have a “.c” or “.rb” file extension. Otherwise, RDoc will ignore the given code string! :-(



53
54
55
56
57
58
59
60
61
62
# File 'lib/gerbil/rdoc.rb', line 53

def self.parse aCodeString, aFileName = __FILE__
  top = ParserFactory.parser_for(
    TopLevel.new(aFileName), aFileName,
    aCodeString, DummyOptions.new, Stats.new
  ).scan

  refresh_all_classes_and_modules

  top
end

.parse_file(aFileName) ⇒ Object

Returns a RDoc::TopLevel object containing information parsed from the code in the given file. This information is also added to the global TopLevel class state, so you can access it via the class methods of the TopLevel class.

The given file name MUST have a “.c” or “.rb” file extension. Otherwise, RDoc will ignore the file! :-(



72
73
74
# File 'lib/gerbil/rdoc.rb', line 72

def self.parse_file aFileName
  parse File.read(aFileName), aFileName
end

.refresh_all_classes_and_modulesObject

Update the return value of the all_classes_and_modules() method to really include every class and every module seen thus far.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/gerbil/rdoc.rb', line 28

def self.refresh_all_classes_and_modules
  visit = lambda do |node|
    if node.is_a? NormalClass or node.is_a? SingleClass
      @@all_classes[node.full_name] = node

    elsif node.is_a? NormalModule
      @@all_modules[node.full_name] = node
    end

    (node.classes + node.modules).each {|n| visit[n] }
  end

  all_classes_and_modules.each {|n| visit[n] }
end