Class: JsDuck::Doc::StandardTagParser
- Inherits:
-
Object
- Object
- JsDuck::Doc::StandardTagParser
- Defined in:
- lib/jsduck/doc/standard_tag_parser.rb
Overview
Helper in parsing the standard tag pattern with type definition followed by name and default value:
Instance Method Summary collapse
-
#initialize(doc_scanner) ⇒ StandardTagParser
constructor
Initialized with Doc::Scanner instance.
-
#parse(cfg) ⇒ Object
Parses the standard tag pattern.
Constructor Details
#initialize(doc_scanner) ⇒ StandardTagParser
Initialized with Doc::Scanner instance
13 14 15 16 |
# File 'lib/jsduck/doc/standard_tag_parser.rb', line 13 def initialize(doc_scanner) @ds = doc_scanner @delimited_parser = Doc::DelimitedParser.new(doc_scanner) end |
Instance Method Details
#parse(cfg) ⇒ Object
Parses the standard tag pattern.
Takes as parameter a configuration hash which can contain the following keys:
-
:tagname => The :tagname of the hash to return.
-
:type => True to parse ‘Type` section.
-
:name => True to parse ‘some.name` section.
-
:default => True to parse ‘=<default-value>` after name.
-
:optional => True to allow placing name and default value
inside [ and ] brackets to denote optionality. Also returns :optional=>true when {SomType=} syntax used.
Returns tag definition hash containing the fields specified by config.
38 39 40 41 42 43 44 45 |
# File 'lib/jsduck/doc/standard_tag_parser.rb', line 38 def parse(cfg) @tagname = cfg[:tagname] tag = {} tag[:tagname] = cfg[:tagname] if cfg[:tagname] add_type(tag, cfg) if cfg[:type] add_name_with_default(tag, cfg) if cfg[:name] tag end |