Commit 540cd41c authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Single-line doc-comments now parsed correctly.

Previously they were interpreted as empty doc-comments.
parent 967a4ff2
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -23,11 +23,14 @@ 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:
      # - those beginning with *
      # - and those without it
      input.each_line do |line|
        line.chomp!
        if line =~ /\A\/\*\*/ || line =~ /\*\/\Z/ then
          # ignore first and last line
        elsif line =~ /\A\s*\*\s?(.*)\Z/ then
        if line =~ /\A\s*\*\s?(.*)\Z/ then
          result << $1
        else
          result << line
+6 −0
Original line number Diff line number Diff line
@@ -36,5 +36,11 @@ class TestDocParser < Test::Unit::TestCase
    assert_equal("Boolean|String", doc[0][:type])
  end

  def test_single_line_doc_comment
    doc = parse_single("/** @event blah */")
    assert_equal(:event, doc[0][:tagname])
    assert_equal("blah", doc[0][:name])
  end

end