Loading lib/jsduck/tag/preventable.rb→lib/jsduck/builtins/preventable.rb +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>. Loading @@ -25,4 +33,3 @@ module JsDuck::Tag end end end spec/aggregator_attributes_spec.rb +18 −0 Original line number Diff line number Diff line Loading @@ -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] Loading Loading
lib/jsduck/tag/preventable.rb→lib/jsduck/builtins/preventable.rb +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>. Loading @@ -25,4 +33,3 @@ module JsDuck::Tag end end end
spec/aggregator_attributes_spec.rb +18 −0 Original line number Diff line number Diff line Loading @@ -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] Loading