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

Turn @chainable into builtin Tag class.

parent 4e00b19f
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
require "jsduck/meta_tag"
require "jsduck/builtins/boolean_tag"

module JsDuck::Tag
  # Implementation of @chainable tag
  class Chainable < JsDuck::MetaTag
module JsDuck::Builtins
  class Chainable < BooleanTag
    def initialize
      @name = "chainable"
      @key = :chainable
      @signature = {:long => "chainable", :short => "&gt;"} # show small right-arrow
      @boolean = true
      super
    end
    # When the tag is found, its value will always be true.
    def process_doc(docs)
      true
    end
  end
end
+1 −1
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ module JsDuck
    def merge_like_method(docs, code)
      h = do_merge(docs, code)
      h[:params] = merge_params(docs, code)
      h[:meta][:chainable] = code[:chainable] if code[:chainable]
      h[:chainable] = code[:chainable] if code[:chainable]
      h
    end

+2 −2
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ module JsDuck
    end

    def chainable?(m)
      m[:meta][:chainable]
      m[:chainable]
    end

    def returns_this?(m)
@@ -50,7 +50,7 @@ module JsDuck
    end

    def add_chainable(m)
      m[:meta][:chainable] = true
      m[:chainable] = true
    end

    def add_return_this(m)
+11 −11
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ describe JsDuck::Aggregator do
    end

    it "detects method as chainable" do
      cls[:members][0][:meta][:chainable].should == true
      cls[:members][0][:chainable].should == true
    end

    it "keeps the original @return docs" do
@@ -50,7 +50,7 @@ describe JsDuck::Aggregator do
    end

    it "detects method as chainable" do
      cls[:members][0][:meta][:chainable].should == true
      cls[:members][0][:chainable].should == true
    end

    it "adds @return {MyClass} this" do
@@ -78,7 +78,7 @@ describe JsDuck::Aggregator do
    end

    it "adds @chainable tag" do
      cls[:members][0][:meta][:chainable].should == true
      cls[:members][0][:chainable].should == true
    end
  end

@@ -101,7 +101,7 @@ describe JsDuck::Aggregator do
    end

    it "adds @chainable tag" do
      cls[:members][0][:meta][:chainable].should == true
      cls[:members][0][:chainable].should == true
    end
  end

@@ -119,7 +119,7 @@ describe JsDuck::Aggregator do
    end

    it "doesn't add @chainable tag" do
      cls[:members][0][:meta][:chainable].should_not == true
      cls[:members][0][:chainable].should_not == true
    end
  end

@@ -137,7 +137,7 @@ describe JsDuck::Aggregator do
    end

    it "doesn't add @chainable tag" do
      cls[:members][0][:meta][:chainable].should_not == true
      cls[:members][0][:chainable].should_not == true
    end
  end

@@ -155,7 +155,7 @@ describe JsDuck::Aggregator do
    end

    it "doesn't add @chainable tag" do
      cls[:members][0][:meta][:chainable].should_not == true
      cls[:members][0][:chainable].should_not == true
    end
  end

@@ -170,7 +170,7 @@ describe JsDuck::Aggregator do
    end

    it "doesn't add @chainable tag" do
      cls[:members][0][:meta][:chainable].should_not == true
      cls[:members][0][:chainable].should_not == true
    end
  end

@@ -186,7 +186,7 @@ describe JsDuck::Aggregator do
    end

    it "doesn't add @chainable tag" do
      cls[:members][0][:meta][:chainable].should_not == true
      cls[:members][0][:chainable].should_not == true
    end
  end

@@ -202,7 +202,7 @@ describe JsDuck::Aggregator do
    end

    it "adds @chainable tag" do
      cls[:members][0][:meta][:chainable].should == true
      cls[:members][0][:chainable].should == true
    end

    it "adds @return {MyClass} this" do
@@ -275,7 +275,7 @@ describe JsDuck::Aggregator do
    end

    it "doesn't get @chainable tag" do
      cls[:members][0][:meta][:chainable].should_not == true
      cls[:members][0][:chainable].should_not == true
    end
  end