Loading lib/jsduck/doc_parser.rb +8 −1 Original line number Diff line number Diff line Loading @@ -162,10 +162,13 @@ module JsDuck # # There must be space before the next @tag - this ensures that we # don't detect tags inside "foo@example.com" or "{@link}". # # Also check that the @tag is not part of an indented code block - # in which case we also ignore the tag. def skip_to_next_at_tag @current_tag[:doc] += match(/[^@]+/) while !prev_char_is_whitespace? && look(/@/) while look(/@/) && (!prev_char_is_whitespace? || indented_as_code?) @current_tag[:doc] += match(/@+[^@]+/) end end Loading @@ -174,6 +177,10 @@ module JsDuck @current_tag[:doc][-1,1] =~ /\s/ end def indented_as_code? @current_tag[:doc] =~ /^ {4,}[^\n]*\Z/ end # Processes anything else beginning with @-sign. # # - When @ is not followed by any word chards, do nothing. Loading spec/doc_parser_spec.rb +37 −0 Original line number Diff line number Diff line Loading @@ -157,4 +157,41 @@ describe JsDuck::DocParser do end end describe "@tag indented by 4+ spaces" do before do @tag = parse_single(<<-EOS.strip)[0] * Code example: * * @method EOS end it "is treated as plain text within code example" do @tag[:doc].should == "Code example:\n\n @method" end end describe "@tag indented by 4+ spaces and preceded by additional code" do before do @tag = parse_single(<<-EOS.strip)[0] * Code example: * * if @method then EOS end it "is treated as plain text within code example" do @tag[:doc].should == "Code example:\n\n if @method then" end end describe "@tag simply separated by 4+ spaces" do before do @tag = parse_single(<<-EOS.strip)[1] * Foo: @method EOS end it "is parsed as normal tag" do @tag[:tagname].should == :method end end end Loading
lib/jsduck/doc_parser.rb +8 −1 Original line number Diff line number Diff line Loading @@ -162,10 +162,13 @@ module JsDuck # # There must be space before the next @tag - this ensures that we # don't detect tags inside "foo@example.com" or "{@link}". # # Also check that the @tag is not part of an indented code block - # in which case we also ignore the tag. def skip_to_next_at_tag @current_tag[:doc] += match(/[^@]+/) while !prev_char_is_whitespace? && look(/@/) while look(/@/) && (!prev_char_is_whitespace? || indented_as_code?) @current_tag[:doc] += match(/@+[^@]+/) end end Loading @@ -174,6 +177,10 @@ module JsDuck @current_tag[:doc][-1,1] =~ /\s/ end def indented_as_code? @current_tag[:doc] =~ /^ {4,}[^\n]*\Z/ end # Processes anything else beginning with @-sign. # # - When @ is not followed by any word chards, do nothing. Loading
spec/doc_parser_spec.rb +37 −0 Original line number Diff line number Diff line Loading @@ -157,4 +157,41 @@ describe JsDuck::DocParser do end end describe "@tag indented by 4+ spaces" do before do @tag = parse_single(<<-EOS.strip)[0] * Code example: * * @method EOS end it "is treated as plain text within code example" do @tag[:doc].should == "Code example:\n\n @method" end end describe "@tag indented by 4+ spaces and preceded by additional code" do before do @tag = parse_single(<<-EOS.strip)[0] * Code example: * * if @method then EOS end it "is treated as plain text within code example" do @tag[:doc].should == "Code example:\n\n if @method then" end end describe "@tag simply separated by 4+ spaces" do before do @tag = parse_single(<<-EOS.strip)[1] * Foo: @method EOS end it "is parsed as normal tag" do @tag[:tagname].should == :method end end end