Commit 77b950a8 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Pull in css mixin params from source code.

parent 09e11e40
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -14,6 +14,16 @@ module JsDuck::Tag
      }
    end

    def process_code(code)
      h = super(code)
      h[:params] = code[:params]
      h
    end

    def merge(h, docs, code)
      JsDuck::ParamsMerger.merge(h, docs, code)
    end

    def to_html(mixin, cls)
      member_link(mixin) + member_params(mixin[:params])
    end
+28 −0
Original line number Diff line number Diff line
@@ -123,4 +123,32 @@ describe JsDuck::Aggregator do
    end
  end

  describe "CSS doc-comment followed by @mixin with parameters" do
    before do
      @doc = parse_member(<<-EOCSS)
        /**
         * Creates an awesome button.
         */
        @mixin my-button($foo, $bar: 2px) {
        }
      EOCSS
    end

    it "detects parameters" do
      @doc[:params].length.should == 2
    end
    it "detects first param name" do
      @doc[:params][0][:name].should == "$foo"
    end
    it "detects second param name" do
      @doc[:params][1][:name].should == "$bar"
    end
    it "detects second param type" do
      @doc[:params][1][:type].should == "number"
    end
    it "detects second param default value" do
      @doc[:params][1][:default].should == "2px"
    end
  end

end