Loading lib/jsduck/ast.rb +6 −2 Original line number Diff line number Diff line Loading @@ -195,7 +195,11 @@ module JsDuck cls[:singleton] = make_singleton(cfg["singleton"]) cls[:aliases] = make_string_list(cfg["alias"]) cls[:aliases] += make_string_list(cfg["xtype"]).map {|xtype| "widget."+xtype } cls[:members] = make_configs(cfg["config"]) members = [] members += make_configs(cfg["config"]) members += make_configs(cfg["cachedConfig"]) cls[:members] = members.length > 0 ? members : nil end end Loading Loading @@ -232,7 +236,7 @@ module JsDuck end def make_configs(ast) return nil unless ast && ast["type"] == "ObjectExpression" return [] unless ast && ast["type"] == "ObjectExpression" configs = [] Loading spec/aggregator_cfg_spec.rb +43 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,49 @@ describe JsDuck::Aggregator do end end describe "detecting Ext.define() with cachedConfig in code" do let(:cfg) do parse(<<-EOS)[0][:members][:cfg] /** * Some documentation. */ Ext.define("MyClass", { cachedConfig: { foo: 42, bar: "hello" } }); EOS end it "finds also two configs exactly like with config:" do cfg.length.should == 2 end end describe "detecting Ext.define() with both config and cachedConfig" do let(:cfg) do parse(<<-EOS)[0][:members][:cfg] /** * Some documentation. */ Ext.define("MyClass", { cachedConfig: { foo: 42, bar: "hello" }, config: { baz: /fafa/ } }); EOS end it "merges all configs together" do cfg.length.should == 3 end end describe "detecting Ext.define() with commented config" do let(:docs) do parse(<<-EOS) Loading Loading
lib/jsduck/ast.rb +6 −2 Original line number Diff line number Diff line Loading @@ -195,7 +195,11 @@ module JsDuck cls[:singleton] = make_singleton(cfg["singleton"]) cls[:aliases] = make_string_list(cfg["alias"]) cls[:aliases] += make_string_list(cfg["xtype"]).map {|xtype| "widget."+xtype } cls[:members] = make_configs(cfg["config"]) members = [] members += make_configs(cfg["config"]) members += make_configs(cfg["cachedConfig"]) cls[:members] = members.length > 0 ? members : nil end end Loading Loading @@ -232,7 +236,7 @@ module JsDuck end def make_configs(ast) return nil unless ast && ast["type"] == "ObjectExpression" return [] unless ast && ast["type"] == "ObjectExpression" configs = [] Loading
spec/aggregator_cfg_spec.rb +43 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,49 @@ describe JsDuck::Aggregator do end end describe "detecting Ext.define() with cachedConfig in code" do let(:cfg) do parse(<<-EOS)[0][:members][:cfg] /** * Some documentation. */ Ext.define("MyClass", { cachedConfig: { foo: 42, bar: "hello" } }); EOS end it "finds also two configs exactly like with config:" do cfg.length.should == 2 end end describe "detecting Ext.define() with both config and cachedConfig" do let(:cfg) do parse(<<-EOS)[0][:members][:cfg] /** * Some documentation. */ Ext.define("MyClass", { cachedConfig: { foo: 42, bar: "hello" }, config: { baz: /fafa/ } }); EOS end it "merges all configs together" do cfg.length.should == 3 end end describe "detecting Ext.define() with commented config" do let(:docs) do parse(<<-EOS) Loading