Class: JsDuck::Tag::Cfg
- Defined in:
- lib/jsduck/tag/cfg.rb
Constant Summary
Constants inherited from MemberTag
MemberTag::MEMBER_POS_CFG, MemberTag::MEMBER_POS_CSS_MIXIN, MemberTag::MEMBER_POS_CSS_VAR, MemberTag::MEMBER_POS_EVENT, MemberTag::MEMBER_POS_LISTENER, MemberTag::MEMBER_POS_METHOD, MemberTag::MEMBER_POS_PROPERTY
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 MemberTag
Attributes inherited from Tag
#class_icon, #css, #ext_define_default, #ext_define_pattern, #html_position, #pattern, #repeatable, #signature, #tagname
Instance Method Summary collapse
-
#initialize ⇒ Cfg
constructor
A new instance of Cfg.
-
#merge(h, docs, code) ⇒ Object
Do the merging of :type field.
- #parse_doc(p, pos) ⇒ Object
- #parse_required(p) ⇒ Object
- #process_code(code) ⇒ Object
- #process_doc(h, tags, pos) ⇒ Object
- #to_html(cfg, cls) ⇒ Object
Methods inherited from MemberTag
Methods inherited from Tag
descendants, #format, #parse_ext_define
Constructor Details
#initialize ⇒ Cfg
Returns a new instance of Cfg.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/jsduck/tag/cfg.rb', line 6 def initialize @pattern = "cfg" @tagname = :cfg @repeatable = true @member_type = { :title => "Config options", :toolbar_title => "Configs", :position => MEMBER_POS_CFG, :icon => File.dirname(__FILE__) + "/icons/cfg.png", :subsections => [ {:title => "Required config options", :filter => {:required => true}}, {:title => "Optional config options", :filter => {:required => false}, :default => true}, ] } end |
Instance Method Details
#merge(h, docs, code) ⇒ Object
Do the merging of :type field
69 70 71 72 73 |
# File 'lib/jsduck/tag/cfg.rb', line 69 def merge(h, docs, code) if h[:type] == nil h[:type] = code[:tagname] == :method ? "Function" : "Object" end end |
#parse_doc(p, pos) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/jsduck/tag/cfg.rb', line 23 def parse_doc(p, pos) tag = p.standard_tag({ :tagname => :cfg, :type => true, :name => true, :default => true, :optional => true }) # don't parse (required) after subproperties unless tag[:name] =~ /\./ tag[:optional] = false if parse_required(p) end tag[:doc] = :multiline tag end |
#parse_required(p) ⇒ Object
41 42 43 |
# File 'lib/jsduck/tag/cfg.rb', line 41 def parse_required(p) p.hw.match(/\(required\)/i) end |
#process_code(code) ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/jsduck/tag/cfg.rb', line 59 def process_code(code) h = super(code) h[:type] = code[:type] h[:default] = code[:default] h[:accessor] = code[:accessor] h[:evented] = code[:evented] h end |
#process_doc(h, tags, pos) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/jsduck/tag/cfg.rb', line 45 def process_doc(h, , pos) p = [0] h[:type] = p[:type] h[:default] = p[:default] h[:required] = true if p[:optional] == false # Documentation after the first @cfg is part of the top-level docs. h[:doc] += p[:doc] nested = JsDuck::Doc::Subproperties.nest(, pos)[0] h[:properties] = nested[:properties] h[:name] = nested[:name] end |
#to_html(cfg, cls) ⇒ Object
75 76 77 |
# File 'lib/jsduck/tag/cfg.rb', line 75 def to_html(cfg, cls) member_link(cfg) + " : " + cfg[:html_type] end |