Loading lib/jsduck/doc_parser.rb +1 −3 Original line number Diff line number Diff line Loading @@ -50,9 +50,7 @@ module JsDuck # Extracts content inside /** ... */ def purify(input) result = [] # Remove the beginning /** and end */ input = input.sub(/\A\/\*\* ?/, "").sub(/ ?\*\/\Z/, "") # Now we are left with only two types of lines: # We can have two types of lines: # - those beginning with * # - and those without it indent = nil Loading lib/jsduck/lexer.rb +1 −1 Original line number Diff line number Diff line Loading @@ -145,7 +145,7 @@ module JsDuck :type => :doc_comment, # Calculate current line number, starting with 1 :linenr => @input.string[0...@input.pos].count("\n") + 1, :value => @input.scan_until(/\*\/|\Z/) :value => @input.scan_until(/\*\/|\Z/).sub(/\A\/\*\*/, "").sub(/\*\/\Z/, "") } elsif @input.check(/\/\*/) # skip multiline comment Loading spec/doc_parser_spec.rb +3 −9 Original line number Diff line number Diff line Loading @@ -9,12 +9,10 @@ describe JsDuck::DocParser do describe "simple method doc-comment" do before do @doc = parse_single(<<-EOS.strip) /** * @method foo * Some docs. * @param {Number} x doc for x * @return {String} resulting value */ EOS end Loading Loading @@ -74,9 +72,7 @@ describe JsDuck::DocParser do describe "@type without curlies" do before do @tag = parse_single(<<-EOS.strip)[0] /** * @type Boolean|String */ EOS end it "detects tagname" do Loading @@ -89,7 +85,7 @@ describe JsDuck::DocParser do describe "single-line doc-comment" do before do @tag = parse_single("/** @event blah */")[0] @tag = parse_single("@event blah")[0] end it "detects tagname" do @tag[:tagname].should == :event Loading @@ -101,13 +97,13 @@ describe JsDuck::DocParser do describe "doc-comment without *-s on left side" do before do @tag = parse_single("/** @tag = parse_single(" @event blah Some comment. More text. code sample */")[0] ")[0] end it "detects the @event tag" do @tag[:tagname].should == :event Loading @@ -120,9 +116,7 @@ describe JsDuck::DocParser do describe "type definition with nested {braces}" do before do @tag = parse_single(<<-EOS.strip)[0] /** * @param {{foo:{bar:Number}}} x */ EOS end it "is parsed ensuring balanced braces" do Loading spec/lexer_spec.rb +2 −2 Original line number Diff line number Diff line Loading @@ -132,7 +132,7 @@ describe JsDuck::Lexer do end it "identifies doc-comments together with line numbers" do lex("/** foo */").should == [[:doc_comment, "/** foo */", 1]] lex("/** foo */").should == [[:doc_comment, " foo ", 1]] end it "counts line numbers correctly" do Loading @@ -157,7 +157,7 @@ describe JsDuck::Lexer do end it "doc-comment" do lex("/** ").should == [[:doc_comment, "/** ", 1]] lex("/** ").should == [[:doc_comment, " ", 1]] end it "regex" do Loading Loading
lib/jsduck/doc_parser.rb +1 −3 Original line number Diff line number Diff line Loading @@ -50,9 +50,7 @@ module JsDuck # Extracts content inside /** ... */ def purify(input) result = [] # Remove the beginning /** and end */ input = input.sub(/\A\/\*\* ?/, "").sub(/ ?\*\/\Z/, "") # Now we are left with only two types of lines: # We can have two types of lines: # - those beginning with * # - and those without it indent = nil Loading
lib/jsduck/lexer.rb +1 −1 Original line number Diff line number Diff line Loading @@ -145,7 +145,7 @@ module JsDuck :type => :doc_comment, # Calculate current line number, starting with 1 :linenr => @input.string[0...@input.pos].count("\n") + 1, :value => @input.scan_until(/\*\/|\Z/) :value => @input.scan_until(/\*\/|\Z/).sub(/\A\/\*\*/, "").sub(/\*\/\Z/, "") } elsif @input.check(/\/\*/) # skip multiline comment Loading
spec/doc_parser_spec.rb +3 −9 Original line number Diff line number Diff line Loading @@ -9,12 +9,10 @@ describe JsDuck::DocParser do describe "simple method doc-comment" do before do @doc = parse_single(<<-EOS.strip) /** * @method foo * Some docs. * @param {Number} x doc for x * @return {String} resulting value */ EOS end Loading Loading @@ -74,9 +72,7 @@ describe JsDuck::DocParser do describe "@type without curlies" do before do @tag = parse_single(<<-EOS.strip)[0] /** * @type Boolean|String */ EOS end it "detects tagname" do Loading @@ -89,7 +85,7 @@ describe JsDuck::DocParser do describe "single-line doc-comment" do before do @tag = parse_single("/** @event blah */")[0] @tag = parse_single("@event blah")[0] end it "detects tagname" do @tag[:tagname].should == :event Loading @@ -101,13 +97,13 @@ describe JsDuck::DocParser do describe "doc-comment without *-s on left side" do before do @tag = parse_single("/** @tag = parse_single(" @event blah Some comment. More text. code sample */")[0] ")[0] end it "detects the @event tag" do @tag[:tagname].should == :event Loading @@ -120,9 +116,7 @@ describe JsDuck::DocParser do describe "type definition with nested {braces}" do before do @tag = parse_single(<<-EOS.strip)[0] /** * @param {{foo:{bar:Number}}} x */ EOS end it "is parsed ensuring balanced braces" do Loading
spec/lexer_spec.rb +2 −2 Original line number Diff line number Diff line Loading @@ -132,7 +132,7 @@ describe JsDuck::Lexer do end it "identifies doc-comments together with line numbers" do lex("/** foo */").should == [[:doc_comment, "/** foo */", 1]] lex("/** foo */").should == [[:doc_comment, " foo ", 1]] end it "counts line numbers correctly" do Loading @@ -157,7 +157,7 @@ describe JsDuck::Lexer do end it "doc-comment" do lex("/** ").should == [[:doc_comment, "/** ", 1]] lex("/** ").should == [[:doc_comment, " ", 1]] end it "regex" do Loading