Class: JsDuck::SearchData
- Inherits:
-
Object
- Object
- JsDuck::SearchData
- Defined in:
- lib/jsduck/search_data.rb
Overview
Creates list of all members in all classes that is used by the searching feature in UI.
Instance Method Summary collapse
-
#alias_display_name(key) ⇒ Object
Some alias types are shown differently.
-
#alias_node(key, name, cls) ⇒ Object
Creates structure representing one alias.
-
#alt_node(name, cls) ⇒ Object
Creates structure representing one alternate classname.
-
#class_node(cls) ⇒ Object
Creates structure representing one class.
-
#create(docs) ⇒ Object
Given list of class documentation objects returns an array of hashes describing all the members.
-
#member_node(member, cls) ⇒ Object
Creates structure representing one member.
Instance Method Details
#alias_display_name(key) ⇒ Object
Some alias types are shown differently. e.g. instead of “widget:” we show “xtype:”
92 93 94 95 96 97 98 99 |
# File 'lib/jsduck/search_data.rb', line 92 def alias_display_name(key) titles = { "widget" => "xtype", "plugin" => "ptype", "feature" => "ftype", } titles[key] || key end |
#alias_node(key, name, cls) ⇒ Object
Creates structure representing one alias
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/jsduck/search_data.rb', line 39 def alias_node(key, name, cls) return { :cls => alias_display_name(key)+": "+name, :member => name, :type => :class, :icon => cls.icon, :id => cls.full_name, :meta => cls[:meta], :sort => 0, } end |
#alt_node(name, cls) ⇒ Object
Creates structure representing one alternate classname
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/jsduck/search_data.rb', line 65 def alt_node(name, cls) return { :cls => name, :member => Class.short_name(name), :type => :class, :icon => cls.icon, :id => cls.full_name, :meta => cls[:meta], :sort => 2, } end |
#class_node(cls) ⇒ Object
Creates structure representing one class
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/jsduck/search_data.rb', line 52 def class_node(cls) return { :cls => cls.full_name, :member => cls.short_name, :type => :class, :icon => cls.icon, :id => cls.full_name, :meta => cls[:meta], :sort => 1, } end |
#create(docs) ⇒ Object
Given list of class documentation objects returns an array of hashes describing all the members.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/jsduck/search_data.rb', line 9 def create(docs) list = [] docs.each do |cls| list << class_node(cls) cls[:alternateClassNames].each do |name| list << alt_node(name, cls) end cls[:aliases].each_pair do |key, items| items.each do |name| list << alias_node(key, name, cls) end end [:members, :statics].each do |group| cls[group].each_key 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 |
#member_node(member, cls) ⇒ Object
Creates structure representing one member
78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/jsduck/search_data.rb', line 78 def member_node(member, cls) return { :cls => cls.full_name, :member => member[:name], :type => :member, :icon => "icon-" + member[:tagname].to_s, :id => cls.full_name + "-" + member[:id], :meta => member[:meta], :sort => 3, } end |