Loading lib/jsduck/evaluator.rb +21 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,18 @@ module JsDuck h[key] = value end h when "BinaryExpression" if ast["operator"] == "+" to_value(ast["left"]) + to_value(ast["right"]) else throw "Unable to handle operator: " + ast["operator"] end when "MemberExpression" if base_css_prefix?(ast) "x-" else throw "Unable to handle this MemberExpression" end when "Literal" if ast["value"] == nil && ast["raw"] =~ /\A\// :regexp Loading @@ -42,6 +54,15 @@ module JsDuck key["type"] == "Identifier" ? key["name"] : key["value"] end # True when MemberExpression == Ext.baseCSSPrefix def base_css_prefix?(ast) ast["computed"] == false && ast["object"]["type"] == "Identifier" && ast["object"]["name"] == "Ext" && ast["property"]["type"] == "Identifier" && ast["property"]["name"] == "baseCSSPrefix" end end end Loading spec/aggregator_default_values_spec.rb +15 −15 Original line number Diff line number Diff line Loading @@ -374,19 +374,19 @@ describe JsDuck::Aggregator do end end # describe "cfg with implicit string value starting with Ext.baseCSSPrefix" do # before do # @doc = parse(<<-EOS)[0] # ({/** # * @cfg foo Something # */ # foo: Ext.baseCSSPrefix + "foo" }) # EOS # end # it "replaces Ext.baseCSSPrefix with 'x-'" do # @doc[:default].should == '"x-foo"' # end # end describe "cfg with implicit string value starting with Ext.baseCSSPrefix" do before do @doc = parse(<<-EOS)[0] ({/** * @cfg foo Something */ foo: Ext.baseCSSPrefix + "foo" }) EOS end it "replaces Ext.baseCSSPrefix with 'x-'" do @doc[:default].should == 'Ext.baseCSSPrefix + "foo"' end end describe "cfg with implicit number value given as expression" do before do Loading @@ -397,8 +397,8 @@ describe JsDuck::Aggregator do foo: 5 + 5 }) EOS end it "doesn't get the default value from code" do @doc[:default].should == nil it "detects the literal expression from code" do @doc[:default].should == "5 + 5" end end Loading Loading
lib/jsduck/evaluator.rb +21 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,18 @@ module JsDuck h[key] = value end h when "BinaryExpression" if ast["operator"] == "+" to_value(ast["left"]) + to_value(ast["right"]) else throw "Unable to handle operator: " + ast["operator"] end when "MemberExpression" if base_css_prefix?(ast) "x-" else throw "Unable to handle this MemberExpression" end when "Literal" if ast["value"] == nil && ast["raw"] =~ /\A\// :regexp Loading @@ -42,6 +54,15 @@ module JsDuck key["type"] == "Identifier" ? key["name"] : key["value"] end # True when MemberExpression == Ext.baseCSSPrefix def base_css_prefix?(ast) ast["computed"] == false && ast["object"]["type"] == "Identifier" && ast["object"]["name"] == "Ext" && ast["property"]["type"] == "Identifier" && ast["property"]["name"] == "baseCSSPrefix" end end end Loading
spec/aggregator_default_values_spec.rb +15 −15 Original line number Diff line number Diff line Loading @@ -374,19 +374,19 @@ describe JsDuck::Aggregator do end end # describe "cfg with implicit string value starting with Ext.baseCSSPrefix" do # before do # @doc = parse(<<-EOS)[0] # ({/** # * @cfg foo Something # */ # foo: Ext.baseCSSPrefix + "foo" }) # EOS # end # it "replaces Ext.baseCSSPrefix with 'x-'" do # @doc[:default].should == '"x-foo"' # end # end describe "cfg with implicit string value starting with Ext.baseCSSPrefix" do before do @doc = parse(<<-EOS)[0] ({/** * @cfg foo Something */ foo: Ext.baseCSSPrefix + "foo" }) EOS end it "replaces Ext.baseCSSPrefix with 'x-'" do @doc[:default].should == 'Ext.baseCSSPrefix + "foo"' end end describe "cfg with implicit number value given as expression" do before do Loading @@ -397,8 +397,8 @@ describe JsDuck::Aggregator do foo: 5 + 5 }) EOS end it "doesn't get the default value from code" do @doc[:default].should == nil it "detects the literal expression from code" do @doc[:default].should == "5 + 5" end end Loading