Class: JsDuck::Tag::Enum
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, Tag::PRIORITY_CLASS, Tag::PRIORITY_COMPONENT, Tag::PRIORITY_SINGLETON
Instance Attribute Summary
Attributes inherited from Tag
#class_icon, #css, #ext_define_default, #ext_define_pattern, #html_position, #pattern, #repeatable, #signature, #tagname
Instance Method Summary collapse
-
#initialize ⇒ Enum
constructor
A new instance of Enum.
- #parse_doc(p, pos) ⇒ Object
- #process_doc(h, tags, pos) ⇒ Object
- #to_html(cls) ⇒ Object
Methods inherited from Tag
descendants, #format, #parse_ext_define
Constructor Details
#initialize ⇒ Enum
Returns a new instance of Enum.
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/jsduck/tag/enum.rb', line 5 def initialize @pattern = "enum" @tagname = :enum @html_position = POS_ENUM # Green box @css = ".enum-box {\ncolor: #060;\nbackground-color: #efe;\ntext-align: center;\n}\n" end |
Instance Method Details
#parse_doc(p, pos) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/jsduck/tag/enum.rb', line 20 def parse_doc(p, pos) enum = p.standard_tag({ :tagname => :enum, :type => true, :name => true, :default => true, :optional => true }) # @enum is a special case of class, so we also generate a class # tag with the same name as given for @enum. cls = {:tagname => :class, :name => enum[:name]} return [cls, enum] end |
#process_doc(h, tags, pos) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/jsduck/tag/enum.rb', line 36 def process_doc(h, , pos) h[:enum] = { :type => [0][:type], :default => [0][:default], :doc_only => !![0][:default], } end |
#to_html(cls) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/jsduck/tag/enum.rb', line 44 def to_html(cls) if cls[:enum][:doc_only] first = cls[:members][0] || {:name => 'foo', :default => '"foo"'} [ "<div class='rounded-box enum-box'>", "<p><strong>ENUM:</strong> ", "This enumeration defines a set of String values. ", "It exists primarily for documentation purposes - ", "in code use the actual string values like #{first[:default]}, ", "don't reference them through this class like #{cls[:name]}.#{first[:name]}.</p>", "</div>", ] else [ "<div class='rounded-box enum-box'>", "<p><strong>ENUM:</strong> ", "This enumeration defines a set of #{cls[:enum][:type]} values.</p>", "</div>", ] end end |