Class: JsDuck::Aggregator

Inherits:
Object
  • Object
show all
Defined in:
lib/jsduck/aggregator.rb

Overview

Groups parsed documentation data from source files into classes.

Produces Hash of classes as result. When a member is found that doesn’t belong to any class, it’s placed into special “global” class.

Instance Method Summary collapse

Constructor Details

#initializeAggregator

Returns a new instance of Aggregator.



11
12
13
14
15
16
# File 'lib/jsduck/aggregator.rb', line 11

def initialize
  @classes = {}
  @alt_names = {}
  @orphans = []
  @current_class = nil
end

Instance Method Details

#aggregate(file) ⇒ Object

Combines chunk of parsed JavaScript together with previously added chunks. The resulting documentation is accumulated inside this class and can be later accessed through #result method.

  • file SoureFile class instance



24
25
26
27
# File 'lib/jsduck/aggregator.rb', line 24

def aggregate(file)
  @current_class = nil
  file.each {|doc| register(doc) }
end

#resultObject

Returns the final result which is a Hash of all classes indexed by name. It’s a hash because some processors applied to this returned classes list need a random-access look up classes by name.



33
34
35
36
37
# File 'lib/jsduck/aggregator.rb', line 33

def result
  classify_orphans
  create_global_class
  @classes
end