Loading lib/jsduck/accessors.rb +2 −4 Original line number Diff line number Diff line Loading @@ -122,13 +122,11 @@ module JsDuck str[0,1].upcase + str[1..-1] end # Create copy of all meta attributes of config, except the # :required which only applies to configs and must not be # propagated to methods or events. # Create copy of all meta attributes of config. def clone_meta(cfg) h = {} cfg[:meta].each_pair do |key, value| h[key] = value unless key == :required h[key] = value end h end Loading lib/jsduck/tag/required.rb→lib/jsduck/builtins/required.rb +22 −0 Original line number Diff line number Diff line require "jsduck/meta_tag" require "jsduck/builtins/tag" module JsDuck::Tag module JsDuck::Builtins # There is no @required tag. # Instead the :required attribute is detected after @cfg: # # @cfg {Type} someName (required) # # This class is only used for displaying the required attribute, not # for detecting it. The detection is done with custom logic in # DocParser and Merger classes. class Required < JsDuck::MetaTag # This class is only used for rendering the required attribute in # HTML documentation, not for detecting it. The detection is done # with custom logic in @cfg and DocAst classes. class Required < Tag def initialize @name = "--non-matching-requried-tag--" @key = :required @signature = {:long => "required", :short => "REQ"} @boolean = true end def process_doc(docs) true end end end lib/jsduck/doc_ast.rb +2 −1 Original line number Diff line number Diff line Loading @@ -136,6 +136,8 @@ module JsDuck end end hash[:required] = true if detect_required(doc_map) hash[:meta] = detect_meta(doc_map) return hash Loading Loading @@ -204,7 +206,6 @@ module JsDuck meta[key] = tag.to_value(tag.boolean ? true : value) end meta[:required] = true if detect_required(doc_map) meta end Loading lib/jsduck/renderer.rb +1 −1 Original line number Diff line number Diff line Loading @@ -164,7 +164,7 @@ module JsDuck configs = @cls[:members][:cfg] + @cls[:statics][:cfg] if configs.length > 0 required, optional = configs.partition {|c| c[:meta][:required] } required, optional = configs.partition {|c| c[:required] } return [ "<div class='members-section'>", required.length == 0 ? "<div class='definedBy'>Defined By</div>" : "", Loading spec/aggregator_attributes_spec.rb +4 −4 Original line number Diff line number Diff line Loading @@ -90,7 +90,7 @@ describe JsDuck::Aggregator do EOS end it "is not required by default" do @doc[:meta][:required].should_not == true @doc[:required].should_not == true end end Loading @@ -103,7 +103,7 @@ describe JsDuck::Aggregator do EOS end it "has required flag set to true" do @doc[:meta][:required].should == true @doc[:required].should == true end end Loading @@ -117,10 +117,10 @@ describe JsDuck::Aggregator do EOS end it "doesn't become a required class" do @doc[:meta][:required].should_not == true @doc[:required].should_not == true end it "contains required config" do @doc[:members][0][:meta][:required].should == true @doc[:members][0][:required].should == true end end Loading Loading
lib/jsduck/accessors.rb +2 −4 Original line number Diff line number Diff line Loading @@ -122,13 +122,11 @@ module JsDuck str[0,1].upcase + str[1..-1] end # Create copy of all meta attributes of config, except the # :required which only applies to configs and must not be # propagated to methods or events. # Create copy of all meta attributes of config. def clone_meta(cfg) h = {} cfg[:meta].each_pair do |key, value| h[key] = value unless key == :required h[key] = value end h end Loading
lib/jsduck/tag/required.rb→lib/jsduck/builtins/required.rb +22 −0 Original line number Diff line number Diff line require "jsduck/meta_tag" require "jsduck/builtins/tag" module JsDuck::Tag module JsDuck::Builtins # There is no @required tag. # Instead the :required attribute is detected after @cfg: # # @cfg {Type} someName (required) # # This class is only used for displaying the required attribute, not # for detecting it. The detection is done with custom logic in # DocParser and Merger classes. class Required < JsDuck::MetaTag # This class is only used for rendering the required attribute in # HTML documentation, not for detecting it. The detection is done # with custom logic in @cfg and DocAst classes. class Required < Tag def initialize @name = "--non-matching-requried-tag--" @key = :required @signature = {:long => "required", :short => "REQ"} @boolean = true end def process_doc(docs) true end end end
lib/jsduck/doc_ast.rb +2 −1 Original line number Diff line number Diff line Loading @@ -136,6 +136,8 @@ module JsDuck end end hash[:required] = true if detect_required(doc_map) hash[:meta] = detect_meta(doc_map) return hash Loading Loading @@ -204,7 +206,6 @@ module JsDuck meta[key] = tag.to_value(tag.boolean ? true : value) end meta[:required] = true if detect_required(doc_map) meta end Loading
lib/jsduck/renderer.rb +1 −1 Original line number Diff line number Diff line Loading @@ -164,7 +164,7 @@ module JsDuck configs = @cls[:members][:cfg] + @cls[:statics][:cfg] if configs.length > 0 required, optional = configs.partition {|c| c[:meta][:required] } required, optional = configs.partition {|c| c[:required] } return [ "<div class='members-section'>", required.length == 0 ? "<div class='definedBy'>Defined By</div>" : "", Loading
spec/aggregator_attributes_spec.rb +4 −4 Original line number Diff line number Diff line Loading @@ -90,7 +90,7 @@ describe JsDuck::Aggregator do EOS end it "is not required by default" do @doc[:meta][:required].should_not == true @doc[:required].should_not == true end end Loading @@ -103,7 +103,7 @@ describe JsDuck::Aggregator do EOS end it "has required flag set to true" do @doc[:meta][:required].should == true @doc[:required].should == true end end Loading @@ -117,10 +117,10 @@ describe JsDuck::Aggregator do EOS end it "doesn't become a required class" do @doc[:meta][:required].should_not == true @doc[:required].should_not == true end it "contains required config" do @doc[:members][0][:meta][:required].should == true @doc[:members][0][:required].should == true end end Loading