Loading lib/jsduck/js_parser.rb +3 −2 Original line number Diff line number Diff line Loading @@ -62,10 +62,11 @@ module JsDuck end # Two comments can be merged if they are both line-comments and # they are separated only by whitespace (but no newlines) # they are separated only by whitespace (only one newline at the # end of the first comment is allowed) def mergeable?(c1, c2) if c1["type"] == "Line" && c2["type"] == "Line" /\A[ \t]*\Z/ =~ @input.slice((c1["range"][1])..(c2["range"][0]-1)) /\A(\r\n|\n|\r)?[ \t]*\Z/ =~ @input.slice((c1["range"][1])..(c2["range"][0]-1)) else false end Loading spec/js_parser_spec.rb +11 −15 Original line number Diff line number Diff line Loading @@ -129,20 +129,6 @@ describe JsDuck::JsParser do end end shared_examples_for "three comments merged" do it "finds one comment" do @docs.length.should == 1 end it "merges all the line-comments together" do @docs[0][:comment].should == " Very\n Long\n Comment" end it "detects the whole comment as belonging to the function" do @docs[0][:code]["type"].should == "FunctionDeclaration" end end describe "parsing three line comments before one function" do before do @docs = parse(<<-EOS) Loading @@ -154,7 +140,17 @@ describe JsDuck::JsParser do EOS end it_should_behave_like "three comments merged" it "finds one comment" do @docs.length.should == 1 end it "merges all the line-comments together" do @docs[0][:comment].should == " Very\n Long\n Comment" end it "detects the whole comment as belonging to the function" do @docs[0][:code]["type"].should == "FunctionDeclaration" end end describe "parsing three separated line comments before one function" do Loading Loading
lib/jsduck/js_parser.rb +3 −2 Original line number Diff line number Diff line Loading @@ -62,10 +62,11 @@ module JsDuck end # Two comments can be merged if they are both line-comments and # they are separated only by whitespace (but no newlines) # they are separated only by whitespace (only one newline at the # end of the first comment is allowed) def mergeable?(c1, c2) if c1["type"] == "Line" && c2["type"] == "Line" /\A[ \t]*\Z/ =~ @input.slice((c1["range"][1])..(c2["range"][0]-1)) /\A(\r\n|\n|\r)?[ \t]*\Z/ =~ @input.slice((c1["range"][1])..(c2["range"][0]-1)) else false end Loading
spec/js_parser_spec.rb +11 −15 Original line number Diff line number Diff line Loading @@ -129,20 +129,6 @@ describe JsDuck::JsParser do end end shared_examples_for "three comments merged" do it "finds one comment" do @docs.length.should == 1 end it "merges all the line-comments together" do @docs[0][:comment].should == " Very\n Long\n Comment" end it "detects the whole comment as belonging to the function" do @docs[0][:code]["type"].should == "FunctionDeclaration" end end describe "parsing three line comments before one function" do before do @docs = parse(<<-EOS) Loading @@ -154,7 +140,17 @@ describe JsDuck::JsParser do EOS end it_should_behave_like "three comments merged" it "finds one comment" do @docs.length.should == 1 end it "merges all the line-comments together" do @docs[0][:comment].should == " Very\n Long\n Comment" end it "detects the whole comment as belonging to the function" do @docs[0][:code]["type"].should == "FunctionDeclaration" end end describe "parsing three separated line comments before one function" do Loading