Sha256: 10b0eac95b9eab916d20f571e24982fec2de40b9635571076629bb256d0004a1

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 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)
        [:members, :statics].each do |group|
          [:cfg, :property, :method, :event].each do |type|
            cls.members(type, group).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
      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],
        :id => member[:id],
      }
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jsduck-3.0.pre2 lib/jsduck/search_data.rb