Commit f46ec7d0 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Allow method description before @method tag.

It's silly that @class must always be before class description,
but @method can either be before or after the description.
parent 423f5322
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -132,7 +132,11 @@ module JsDuck
    # matches @method name ...
    def at_method
      match(/@method/)
      set_root_tag(:method, {:doc => ""})
      # In case @method comes after the description,
      # turn the :default tag description into method description,
      # and afterwards delete it.
      set_root_tag(:method, @tags[:default] || {:doc => ""})
      @root_tags.shift() if @root_tags[0][:default]
      skip_horiz_white
      if look(/\w/) then
        @current_tag[:name] = ident
+11 −0
Original line number Diff line number Diff line
@@ -32,6 +32,17 @@ class TestDocCommentParser < Test::Unit::TestCase
    assert_equal("resulting value", doc[:return][:doc])
  end

  def test_description_can_precede_method_tag
    doc = parse_single("/**
 * Method description
 * @param foo
 * @method blah
 */")
    assert_equal("blah", doc[:method][:name])
    assert_equal("Method description", doc[:method][:doc])
    assert_equal("foo", doc[:param][0][:name])
  end

  def test_constructor
    doc = parse_single("/**
 * @constructor