Commit 4149d73e authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Turn @preventable into builtin tag class.

parent 9c9155cf
Loading
Loading
Loading
Loading
+15 −8
Original line number Diff line number Diff line
require "jsduck/meta_tag"
require "jsduck/builtins/tag"

module JsDuck::Tag
  # Implementation of @preventable tag
  class Preventable < JsDuck::MetaTag
module JsDuck::Builtins
  # That's pretty much a boolean tag, but we don't inherit from
  # BooleanTag as unlike other boolean tags it can be followed by some
  # text.
  class Preventable < Tag
    def initialize
      @name = "preventable"
      @pattern = "preventable"
      @key = :preventable
      @signature = {:long => "preventable", :short => "PREV"}
      @html_position = :bottom
    end

    # @preventable is optionally followed by some method name, but we
    # don't document it.
    def to_value(contents)
    def parse(p)
      p.add_tag(@key)
      p.match(/.*$/)
    end

    def process_doc(docs)
      true
    end

    def to_html(v)
    def to_html(contents, formatter)
      <<-EOHTML
        <div class='signature-box preventable'>
        <p>This action following this event is <b>preventable</b>.
@@ -25,4 +33,3 @@ module JsDuck::Tag
    end
  end
end
+18 −0
Original line number Diff line number Diff line
@@ -63,6 +63,24 @@ describe JsDuck::Aggregator do
    end
  end

  describe "event with @preventable" do
    before do
      @doc = parse(<<-EOS)[0]
        /**
         * @event foo
         * @preventable bla blah
         * Some event
         */
      EOS
    end
    it "gets preventable attribute" do
      @doc[:preventable].should == true
    end
    it "ignores text right after @preventable" do
      @doc[:doc].should == "Some event"
    end
  end

  describe "a normal config option" do
    before do
      @doc = parse(<<-EOS)[0]