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

Support default values of @property.

Default values make sense for properties too.  Previously I thought
that they don't but people are already using them, so here we go...
parent f7c2e752
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -276,7 +276,7 @@ module JsDuck
      match(/@property/)
      add_tag(:property)
      maybe_type
      maybe_ident_chain(:name)
      maybe_name_with_default
      skip_white
    end

+1 −0
Original line number Diff line number Diff line
@@ -192,6 +192,7 @@ module JsDuck
        :owner => detect_owner(doc_map),
        :type => detect_type(:property, doc_map, code),
        :doc => detect_doc(docs),
        :default => detect_default(:property, doc_map, code),
        :properties => detect_subproperties(docs, :property),
      }, doc_map)
    end
+13 −0
Original line number Diff line number Diff line
@@ -117,6 +117,19 @@ describe JsDuck::Aggregator do
    end
  end

  describe "property with default value" do
    before do
      @doc = parse(<<-EOS)[0]
        /**
         * @property {Number} [foo=3] Something
         */
      EOS
    end
    it "has default value" do
      @doc[:default].should == "3"
    end
  end

  describe "cfg with explicit regex default value" do
    before do
      @doc = parse(<<-EOS)[0]