Loading lib/jsduck/doc_parser.rb +10 −1 Original line number Diff line number Diff line Loading @@ -216,7 +216,7 @@ module JsDuck add_tag(:cfg) maybe_type maybe_name_with_default maybe_optional maybe_required skip_white end Loading Loading @@ -376,6 +376,15 @@ module JsDuck end end # matches: "(required)" def maybe_required skip_horiz_white if look(/\(required\)/i) match(/\(required\)/i) @current_tag[:optional] = false end end # matches identifier name if possible and sets it on @current_tag def maybe_name skip_horiz_white Loading lib/jsduck/merger.rb +6 −0 Original line number Diff line number Diff line Loading @@ -164,6 +164,7 @@ module JsDuck :owner => detect_owner(doc_map) || owner, :type => detect_type(:cfg, doc_map, code), :doc => detect_doc(docs), :optional => detect_optional(:cfg, doc_map), :default => detect_default(:cfg, doc_map, code), :properties => detect_subproperties(docs, :cfg), }, doc_map) Loading Loading @@ -281,6 +282,11 @@ module JsDuck end end def detect_optional(tagname, doc_map) main_tag = doc_map[tagname] ? doc_map[tagname].first : {} return main_tag[:optional] != false end # for detecting mixins and alternateClassNames def detect_list(type, doc_map, code) if doc_map[type] Loading spec/aggregator_default_values_spec.rb +26 −0 Original line number Diff line number Diff line Loading @@ -304,4 +304,30 @@ describe JsDuck::Aggregator do end end describe "a normal config option" do before do @doc = parse(<<-EOS)[0] /** * @cfg foo Something */ EOS end it "is optional by default" do @doc[:optional].should == true end end describe "a config option labeled as required" do before do @doc = parse(<<-EOS)[0] /** * @cfg foo (required) Something */ EOS end it "has optional flag set to false" do @doc[:optional].should == false end end end Loading
lib/jsduck/doc_parser.rb +10 −1 Original line number Diff line number Diff line Loading @@ -216,7 +216,7 @@ module JsDuck add_tag(:cfg) maybe_type maybe_name_with_default maybe_optional maybe_required skip_white end Loading Loading @@ -376,6 +376,15 @@ module JsDuck end end # matches: "(required)" def maybe_required skip_horiz_white if look(/\(required\)/i) match(/\(required\)/i) @current_tag[:optional] = false end end # matches identifier name if possible and sets it on @current_tag def maybe_name skip_horiz_white Loading
lib/jsduck/merger.rb +6 −0 Original line number Diff line number Diff line Loading @@ -164,6 +164,7 @@ module JsDuck :owner => detect_owner(doc_map) || owner, :type => detect_type(:cfg, doc_map, code), :doc => detect_doc(docs), :optional => detect_optional(:cfg, doc_map), :default => detect_default(:cfg, doc_map, code), :properties => detect_subproperties(docs, :cfg), }, doc_map) Loading Loading @@ -281,6 +282,11 @@ module JsDuck end end def detect_optional(tagname, doc_map) main_tag = doc_map[tagname] ? doc_map[tagname].first : {} return main_tag[:optional] != false end # for detecting mixins and alternateClassNames def detect_list(type, doc_map, code) if doc_map[type] Loading
spec/aggregator_default_values_spec.rb +26 −0 Original line number Diff line number Diff line Loading @@ -304,4 +304,30 @@ describe JsDuck::Aggregator do end end describe "a normal config option" do before do @doc = parse(<<-EOS)[0] /** * @cfg foo Something */ EOS end it "is optional by default" do @doc[:optional].should == true end end describe "a config option labeled as required" do before do @doc = parse(<<-EOS)[0] /** * @cfg foo (required) Something */ EOS end it "has optional flag set to false" do @doc[:optional].should == false end end end