Class: JsDuck::Tag::Preventable

Inherits:
Tag
  • Object
show all
Defined in:
lib/jsduck/tag/preventable.rb

Overview

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.

Constant Summary

Constants inherited from Tag

Tag::POS_ASIDE, Tag::POS_DEFAULT, Tag::POS_DEPRECATED, Tag::POS_DOC, Tag::POS_ENUM, Tag::POS_FIRES, Tag::POS_LOCALDOC, Tag::POS_OVERRIDES, Tag::POS_PARAM, Tag::POS_PREVENTABLE, Tag::POS_PRIVATE, Tag::POS_RETURN, Tag::POS_SINCE, Tag::POS_SUBPROPERTIES, Tag::POS_TEMPLATE, Tag::POS_THROWS

Instance Attribute Summary

Attributes inherited from Tag

#css, #ext_define_default, #ext_define_pattern, #html_position, #pattern, #repeatable, #signature, #tagname

Instance Method Summary collapse

Methods inherited from Tag

descendants, #format, #parse_ext_define

Constructor Details

#initializePreventable

Returns a new instance of Preventable.



8
9
10
11
12
13
14
15
# File 'lib/jsduck/tag/preventable.rb', line 8

def initialize
  @pattern = "preventable"
  @tagname = :preventable
  @signature = {:long => "preventable", :short => "PREV"}
  @html_position = POS_PREVENTABLE
  # Use the default white box with dark gray border.
  @css = ".preventable-box { text-align: center }"
end

Instance Method Details

#parse_doc(p, pos) ⇒ Object

don’t document it.



19
20
21
22
# File 'lib/jsduck/tag/preventable.rb', line 19

def parse_doc(p, pos)
  p.match(/.*$/)
  {:tagname => :preventable}
end

#process_doc(h, docs, pos) ⇒ Object



24
25
26
# File 'lib/jsduck/tag/preventable.rb', line 24

def process_doc(h, docs, pos)
  h[:preventable] = true
end

#to_html(context) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/jsduck/tag/preventable.rb', line 28

def to_html(context)
  <<-EOHTML
    <div class='rounded-box preventable-box'>
    <p>This action following this event is <b>preventable</b>.
    When any of the listeners returns false, the action is cancelled.</p>
    </div>
  EOHTML
end