Sha256: ddcb137ac12cfaf7f46e8c9df5a26f0b03aeae4677c28f48e1c59aa8afd47160

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 KB

Contents

module JsDuck

  # Creates list of all members in all classes that is used by the
  # searching feature in UI.
  class SearchData
    # Given list of class documentation objects returns an array of
    # hashes describing all the members.
    def create(docs)
      list = []
      docs.each do |cls|
        list << class_node(cls)
        [:cfg, :property, :method, :event].each do |type|
          cls.members(type).each do |m|
            # skip inherited items and constructors
            if m[:owner] == cls.full_name && m[:name] != cls.short_name
              list << member_node(m, cls)
            end
          end
        end
      end
      list
    end

    # Creates structure representing one class
    def class_node(cls)
      return {
        :cls => cls.full_name,
        :member => cls.short_name,
        :type => :cls,
        :xtypes => cls[:xtypes]
      }
    end

    # Creates structure representing one member
    def member_node(member, cls)
      return {
        :cls => cls.full_name,
        :member => member[:name],
        :type => member[:tagname],
      }
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jsduck-3.0.pre lib/jsduck/search_data.rb
jsduck-2.0.pre4 lib/jsduck/search_data.rb
jsduck-2.0.pre2 lib/jsduck/search_data.rb
jsduck-2.0.pre lib/jsduck/search_data.rb