Class: JsDuck::Tag::DeprecatedTag
- Defined in:
- lib/jsduck/tag/deprecated_tag.rb
Overview
Base class for both @deprecated and @removed. Child classes only need to define the @tagname and @msg attributes and call #super - all the correct behavior will the fall out automatically.
Direct Known Subclasses
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
- #format(context, formatter) ⇒ Object
-
#initialize ⇒ DeprecatedTag
constructor
A new instance of DeprecatedTag.
- #parse_doc(p, pos) ⇒ Object
- #process_doc(h, tags, pos) ⇒ Object
- #to_html(context) ⇒ Object
Methods inherited from Tag
descendants, #parse_ext_define
Constructor Details
#initialize ⇒ DeprecatedTag
Returns a new instance of DeprecatedTag.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/jsduck/tag/deprecated_tag.rb', line 8 def initialize if @tagname @pattern = @tagname.to_s @signature = {:long => @tagname.to_s, :short => @tagname.to_s[0..2].upcase} @html_position = POS_DEPRECATED @since = "since" unless @since @css += <<-EOCSS .deprecated-tag-box { text-align: center; color: #600; background-color: #fee; } .deprecated-tag-box strong { text-transform: uppercase; border-radius: 2px; padding: 0 3px; } EOCSS end end |
Instance Method Details
#format(context, formatter) ⇒ Object
43 44 45 |
# File 'lib/jsduck/tag/deprecated_tag.rb', line 43 def format(context, formatter) context[@tagname][:text] = formatter.format(context[@tagname][:text]) end |
#parse_doc(p, pos) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/jsduck/tag/deprecated_tag.rb', line 29 def parse_doc(p, pos) { :tagname => @tagname, :version => p.match(/[0-9.]+/), :doc => :multiline, } end |
#process_doc(h, tags, pos) ⇒ Object
37 38 39 40 41 |
# File 'lib/jsduck/tag/deprecated_tag.rb', line 37 def process_doc(h, , pos) v = {:text => [0][:doc] || ""} v[:version] = [0][:version] if [0][:version] h[@tagname] = v end |
#to_html(context) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/jsduck/tag/deprecated_tag.rb', line 47 def to_html(context) depr = context[@tagname] msg = @msg.sub(/\{TAGNAME\}/, context[:tagname].to_s) v = depr[:version] ? "#{@since} " + depr[:version] : "" <<-EOHTML <div class='rounded-box #{@tagname}-box deprecated-tag-box'> <p>#{msg} #{v}</p> #{depr[:text]} </div> EOHTML end |