Loading lib/jsduck/js/associator.rb +3 −1 Original line number Diff line number Diff line Loading @@ -161,7 +161,9 @@ module JsDuck exit(1) end properties.map {|p| node[p] }.compact.flatten # First flatten, then get rid of all nils, because the inner # arrays may also contain nils. properties.map {|p| node[p] }.flatten.compact end # All possible node types in Esprima-created abstract syntax tree Loading spec/js_parser_spec.rb +15 −0 Original line number Diff line number Diff line Loading @@ -291,4 +291,19 @@ describe JsDuck::Js::Parser do end end # Sparse arrays are perfectly valid in JavaScript. # Omitted array members are initialized to undefined. describe "parsing comment before a missing array member" do before do @docs = parse(<<-EOS) x = [5, /* Blah */, 6]; EOS end it "associates comment with the next array member after that" do @docs[0][:comment].should == " Blah " @docs[0][:code]["value"].should == 6 end end end Loading
lib/jsduck/js/associator.rb +3 −1 Original line number Diff line number Diff line Loading @@ -161,7 +161,9 @@ module JsDuck exit(1) end properties.map {|p| node[p] }.compact.flatten # First flatten, then get rid of all nils, because the inner # arrays may also contain nils. properties.map {|p| node[p] }.flatten.compact end # All possible node types in Esprima-created abstract syntax tree Loading
spec/js_parser_spec.rb +15 −0 Original line number Diff line number Diff line Loading @@ -291,4 +291,19 @@ describe JsDuck::Js::Parser do end end # Sparse arrays are perfectly valid in JavaScript. # Omitted array members are initialized to undefined. describe "parsing comment before a missing array member" do before do @docs = parse(<<-EOS) x = [5, /* Blah */, 6]; EOS end it "associates comment with the next array member after that" do @docs[0][:comment].should == " Blah " @docs[0][:code]["value"].should == 6 end end end