class JsDuck::Exporter::Full

Exporter for all the class docs.

Public Class Methods

new(relations, opts=OpenStruct.new) click to toggle source
# File lib/jsduck/exporter/full.rb, line 10
def initialize(relations, opts=OpenStruct.new)
  # parameters are just for compatibility with other exporters
end

Public Instance Methods

export(cls) click to toggle source

Returns a hash of class data, with :members field expanded into list of all members (including those inherited from parents and mixins).

# File lib/jsduck/exporter/full.rb, line 17
def export(cls)
  # Make copy of the internal data structure of a class
  # so our modifications on it will be safe.
  h = cls.internal_doc.clone

  h[:members] = export_members(cls)

  h
end

Private Instance Methods

constructor_first(ms) click to toggle source

If methods list contains constructor, move it into the beginning.

# File lib/jsduck/exporter/full.rb, line 48
def constructor_first(ms)
  constr = ms.find {|m| JsDuck::Class.constructor?(m) }
  if constr
    ms.delete(constr)
    ms.unshift(constr)
  end
  ms
end
export_members(cls) click to toggle source

Generates flat list of all members

# File lib/jsduck/exporter/full.rb, line 30
def export_members(cls)
  groups = []
  MemberRegistry.names.each do |tagname|
    groups << export_members_group(cls, {:tagname => tagname, :static => false})
    groups << export_members_group(cls, {:tagname => tagname, :static => true})
  end
  groups.flatten
end
export_members_group(cls, cfg) click to toggle source

Looks up members of given type, and sorts them so that constructor method is first

# File lib/jsduck/exporter/full.rb, line 41
def export_members_group(cls, cfg)
  ms = cls.find_members(cfg)
  ms.sort! {|a,b| a[:name] <=> b[:name] }
  cfg[:tagname] == :method ? constructor_first(ms) : ms
end