Loading lib/jsduck/js_parser.rb +11 −1 Original line number Diff line number Diff line Loading @@ -234,7 +234,7 @@ module JsDuck end # <ext-define-cfg> := "{" ( <extend> | <mixins> | <alternate-class-name> | <alias> | # <requires> | <uses> | <singleton> | <?> )* # <xtype> | <requires> | <uses> | <singleton> | <?> )* def ext_define_cfg match("{") cfg = {} Loading @@ -249,6 +249,8 @@ module JsDuck cfg[:alternateClassNames] = found elsif found = ext_define_alias cfg[:alias] = found elsif found = ext_define_xtype cfg[:xtype] = found elsif found = ext_define_requires cfg[:requires] = found elsif found = ext_define_uses Loading Loading @@ -301,6 +303,14 @@ module JsDuck end end # <xtype> := "xtype" ":" <string-or-list> def ext_define_xtype if look("xtype", ":") match("xtype", ":") string_or_list end end # <requires> := "requires" ":" <string-or-list> def ext_define_requires if look("requires", ":") Loading lib/jsduck/merger.rb +9 −2 Original line number Diff line number Diff line Loading @@ -320,9 +320,16 @@ module JsDuck def detect_xtypes(doc_map, code) if doc_map[:xtype] {"widget" => doc_map[:xtype].map {|tag| tag[:name] } } elsif code[:alias] elsif code[:xtype] || code[:alias] xtypes = {} code[:alias].each do |a| (code[:xtype] || []).each do |a| if xtypes["widget"] xtypes["widget"] << a else xtypes["widget"] = [a] end end (code[:alias] || []).each do |a| if a =~ /^(\w+)\.(\w+)$/ if xtypes[$1] xtypes[$1] << $2 Loading spec/aggregator_xtypes_spec.rb +37 −0 Original line number Diff line number Diff line Loading @@ -114,6 +114,43 @@ describe JsDuck::Aggregator do end end describe "Ext.define() with xtype property" do before do @doc = parse(<<-EOS)[0] /** */ Ext.define('MyClass', { xtype: 'foo' }); EOS end it_should_behave_like "single xtype" end describe "Ext.define() with array xtype property" do before do @doc = parse(<<-EOS)[0] /** */ Ext.define('MyClass', { xtype: ['foo', 'bar'] }); EOS end it_should_behave_like "multiple xtypes" end describe "Ext.define() with both xtype and alias" do before do @doc = parse(<<-EOS)[0] /** */ Ext.define('MyClass', { xtype: 'foo', alias: 'widget.bar' }); EOS end it_should_behave_like "multiple xtypes" end describe "one class many times" do before do @doc = parse(<<-EOS)[0] Loading Loading
lib/jsduck/js_parser.rb +11 −1 Original line number Diff line number Diff line Loading @@ -234,7 +234,7 @@ module JsDuck end # <ext-define-cfg> := "{" ( <extend> | <mixins> | <alternate-class-name> | <alias> | # <requires> | <uses> | <singleton> | <?> )* # <xtype> | <requires> | <uses> | <singleton> | <?> )* def ext_define_cfg match("{") cfg = {} Loading @@ -249,6 +249,8 @@ module JsDuck cfg[:alternateClassNames] = found elsif found = ext_define_alias cfg[:alias] = found elsif found = ext_define_xtype cfg[:xtype] = found elsif found = ext_define_requires cfg[:requires] = found elsif found = ext_define_uses Loading Loading @@ -301,6 +303,14 @@ module JsDuck end end # <xtype> := "xtype" ":" <string-or-list> def ext_define_xtype if look("xtype", ":") match("xtype", ":") string_or_list end end # <requires> := "requires" ":" <string-or-list> def ext_define_requires if look("requires", ":") Loading
lib/jsduck/merger.rb +9 −2 Original line number Diff line number Diff line Loading @@ -320,9 +320,16 @@ module JsDuck def detect_xtypes(doc_map, code) if doc_map[:xtype] {"widget" => doc_map[:xtype].map {|tag| tag[:name] } } elsif code[:alias] elsif code[:xtype] || code[:alias] xtypes = {} code[:alias].each do |a| (code[:xtype] || []).each do |a| if xtypes["widget"] xtypes["widget"] << a else xtypes["widget"] = [a] end end (code[:alias] || []).each do |a| if a =~ /^(\w+)\.(\w+)$/ if xtypes[$1] xtypes[$1] << $2 Loading
spec/aggregator_xtypes_spec.rb +37 −0 Original line number Diff line number Diff line Loading @@ -114,6 +114,43 @@ describe JsDuck::Aggregator do end end describe "Ext.define() with xtype property" do before do @doc = parse(<<-EOS)[0] /** */ Ext.define('MyClass', { xtype: 'foo' }); EOS end it_should_behave_like "single xtype" end describe "Ext.define() with array xtype property" do before do @doc = parse(<<-EOS)[0] /** */ Ext.define('MyClass', { xtype: ['foo', 'bar'] }); EOS end it_should_behave_like "multiple xtypes" end describe "Ext.define() with both xtype and alias" do before do @doc = parse(<<-EOS)[0] /** */ Ext.define('MyClass', { xtype: 'foo', alias: 'widget.bar' }); EOS end it_should_behave_like "multiple xtypes" end describe "one class many times" do before do @doc = parse(<<-EOS)[0] Loading