Class: JsDuck::Process::GlobalMembers

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

Overview

Prints warning for each global member. Removes “global” class when –ignore-global option used. Warnings for global members are printed regardless of that setting, but of course can be turned off using –warnings=-global

Instance Method Summary collapse

Constructor Details

#initialize(classes_hash, opts) ⇒ GlobalMembers

Returns a new instance of GlobalMembers.



11
12
13
14
# File 'lib/jsduck/process/global_members.rb', line 11

def initialize(classes_hash, opts)
  @classes_hash = classes_hash
  @opts = opts
end

Instance Method Details

#process_all!Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/jsduck/process/global_members.rb', line 16

def process_all!
  # Do nothing when there's no "global" class.
  return unless @classes_hash["global"]

  # Warnings for each global member
  @classes_hash["global"][:members].each do |m|
    type = m[:tagname].to_s
    name = m[:name]
    Logger.warn(:global, "Global #{type}: #{name}", m[:files][0])
  end

  # Throw away the "global" class when --ignore-global option used
  if @opts.ignore_global
    @classes_hash.delete("global")
  end
end