Loading lib/jsduck/merger.rb +2 −0 Original line number Diff line number Diff line Loading @@ -217,6 +217,8 @@ module JsDuck doc_map[:extends].first[:extends] elsif code[:type] == :assignment && code[:right] && code[:right][:type] == :ext_extend code[:right][:extend].join(".") elsif code[:type] == :ext_define code[:extend] end end Loading lib/jsduck/parser.rb +21 −4 Original line number Diff line number Diff line Loading @@ -74,7 +74,7 @@ module JsDuck function elsif look("var") var_declaration elsif look("Ext", ".", "define", "(") elsif look("Ext", ".", "define", "(", :string) ext_define elsif look(:ident, ":") || look(:string, ":") property_literal Loading Loading @@ -178,15 +178,32 @@ module JsDuck } end # <ext-define> := "Ext" "." "define" "(" <string> "," ... # <ext-define> := "Ext" "." "define" "(" <string> "," <ext-define-cfg> def ext_define match("Ext", ".", "define", "(") name = match("Ext", ".", "define", "(", :string) cfg = {} if look(",") match(",") cfg = ext_define_cfg end return { :type => :ext_define, :name => look(:string) ? match(:string) : nil, :name => name, :extend => cfg[:extend], } end # <ext-define-cfg> := "{" "extend" ":" <string> "," ... def ext_define_cfg cfg = {} if look("{", "extend", ":", :string) cfg[:extend] = match("{", "extend", ":", :string) end cfg end # <property-literal> := ( <ident> | <string> ) ":" <expression> def property_literal left = look(:ident) ? match(:ident) : match(:string) Loading spec/aggregator_classes_spec.rb +5 −2 Original line number Diff line number Diff line Loading @@ -93,15 +93,18 @@ describe JsDuck::Aggregator do end it_should_behave_like "class" it "detects implied extends" do @doc[:extends] == "Your.Class" @doc[:extends].should == "Your.Class" end end describe "Ext.define() in code" do before do @doc = parse("/** */ Ext.define('MyClass', { });")[0] @doc = parse("/** */ Ext.define('MyClass', { extend: 'Your.Class' });")[0] end it_should_behave_like "class" it "detects implied extends" do @doc[:extends].should == "Your.Class" end end describe "class with cfgs" do Loading Loading
lib/jsduck/merger.rb +2 −0 Original line number Diff line number Diff line Loading @@ -217,6 +217,8 @@ module JsDuck doc_map[:extends].first[:extends] elsif code[:type] == :assignment && code[:right] && code[:right][:type] == :ext_extend code[:right][:extend].join(".") elsif code[:type] == :ext_define code[:extend] end end Loading
lib/jsduck/parser.rb +21 −4 Original line number Diff line number Diff line Loading @@ -74,7 +74,7 @@ module JsDuck function elsif look("var") var_declaration elsif look("Ext", ".", "define", "(") elsif look("Ext", ".", "define", "(", :string) ext_define elsif look(:ident, ":") || look(:string, ":") property_literal Loading Loading @@ -178,15 +178,32 @@ module JsDuck } end # <ext-define> := "Ext" "." "define" "(" <string> "," ... # <ext-define> := "Ext" "." "define" "(" <string> "," <ext-define-cfg> def ext_define match("Ext", ".", "define", "(") name = match("Ext", ".", "define", "(", :string) cfg = {} if look(",") match(",") cfg = ext_define_cfg end return { :type => :ext_define, :name => look(:string) ? match(:string) : nil, :name => name, :extend => cfg[:extend], } end # <ext-define-cfg> := "{" "extend" ":" <string> "," ... def ext_define_cfg cfg = {} if look("{", "extend", ":", :string) cfg[:extend] = match("{", "extend", ":", :string) end cfg end # <property-literal> := ( <ident> | <string> ) ":" <expression> def property_literal left = look(:ident) ? match(:ident) : match(:string) Loading
spec/aggregator_classes_spec.rb +5 −2 Original line number Diff line number Diff line Loading @@ -93,15 +93,18 @@ describe JsDuck::Aggregator do end it_should_behave_like "class" it "detects implied extends" do @doc[:extends] == "Your.Class" @doc[:extends].should == "Your.Class" end end describe "Ext.define() in code" do before do @doc = parse("/** */ Ext.define('MyClass', { });")[0] @doc = parse("/** */ Ext.define('MyClass', { extend: 'Your.Class' });")[0] end it_should_behave_like "class" it "detects implied extends" do @doc[:extends].should == "Your.Class" end end describe "class with cfgs" do Loading