Loading lib/jsduck/js_parser.rb +8 −1 Original line number Diff line number Diff line Loading @@ -172,7 +172,7 @@ module JsDuck # <literal> := ...see JsLiteralParser... def my_literal lit = literal return unless lit return unless lit && literal_expression_end? cls_map = { :string => "String", Loading @@ -195,6 +195,13 @@ module JsDuck {:type => :literal, :class => cls, :value => value} end # True when we're at the end of literal expression. # ",", ";" and "}" are the normal closing symbols, but for # our docs purposes doc-comment and file end work too. def literal_expression_end? look(",") || look(";") || look("}") || look(:doc_comment) || @lex.empty? end # <ext-extend> := "Ext" "." "extend" "(" <ident-chain> "," ... def ext_extend match(:ident, ".", "extend", "(") Loading spec/aggregator_default_values_spec.rb +28 −0 Original line number Diff line number Diff line Loading @@ -331,6 +331,34 @@ describe JsDuck::Aggregator do end end describe "cfg with implicit number value given as expression" do before do @doc = parse(<<-EOS)[0] /** * @cfg {Number} foo */ foo: 5 + 5 EOS end it "doesn't get the default value from code" do @doc[:default].should == nil end end describe "cfg with implicit array value with chained method" do before do @doc = parse(<<-EOS)[0] /** * @cfg {Array} foo */ foo: [1, 2, 3].compact() EOS end it "doesn't get the default value from code" do @doc[:default].should == nil end end describe "cfg with implicit name followed by code field with another name" do before do @doc = parse(<<-EOS)[0] Loading Loading
lib/jsduck/js_parser.rb +8 −1 Original line number Diff line number Diff line Loading @@ -172,7 +172,7 @@ module JsDuck # <literal> := ...see JsLiteralParser... def my_literal lit = literal return unless lit return unless lit && literal_expression_end? cls_map = { :string => "String", Loading @@ -195,6 +195,13 @@ module JsDuck {:type => :literal, :class => cls, :value => value} end # True when we're at the end of literal expression. # ",", ";" and "}" are the normal closing symbols, but for # our docs purposes doc-comment and file end work too. def literal_expression_end? look(",") || look(";") || look("}") || look(:doc_comment) || @lex.empty? end # <ext-extend> := "Ext" "." "extend" "(" <ident-chain> "," ... def ext_extend match(:ident, ".", "extend", "(") Loading
spec/aggregator_default_values_spec.rb +28 −0 Original line number Diff line number Diff line Loading @@ -331,6 +331,34 @@ describe JsDuck::Aggregator do end end describe "cfg with implicit number value given as expression" do before do @doc = parse(<<-EOS)[0] /** * @cfg {Number} foo */ foo: 5 + 5 EOS end it "doesn't get the default value from code" do @doc[:default].should == nil end end describe "cfg with implicit array value with chained method" do before do @doc = parse(<<-EOS)[0] /** * @cfg {Array} foo */ foo: [1, 2, 3].compact() EOS end it "doesn't get the default value from code" do @doc[:default].should == nil end end describe "cfg with implicit name followed by code field with another name" do before do @doc = parse(<<-EOS)[0] Loading