Loading lib/jsduck/doc/subproperties.rb +8 −8 Original line number Diff line number Diff line require 'jsduck/util/singleton' require 'jsduck/logger' module JsDuck module Doc Loading @@ -22,13 +23,12 @@ module JsDuck # {:name => "baz"}]}, # {:name => "zap"}, # # NOTE: It returns two values: the resulting nested items array # and warnings array of :subproperty warnings that should get # printed out. def nest(raw_items) # Secondly it takes a position argument which is used for # logging warnings when bogus subproperty syntax is encountered. def nest(raw_items, pos) # First item can't be namespaced, if it is ignore the rest. if raw_items[0] && raw_items[0][:name] =~ /\./ return [raw_items[0]], [] return [raw_items[0]] end # build name-index of all items Loading @@ -39,7 +39,6 @@ module JsDuck # Otherwise look up the parent of item and add it as the # property of that parent. items = [] warnings = [] raw_items.each do |it| if it[:name] =~ /^(.+)\.([^.]+)$/ it[:name] = $2 Loading @@ -48,14 +47,15 @@ module JsDuck parent[:properties] = [] unless parent[:properties] parent[:properties] << it else warnings << "Ignoring subproperty #{$1}.#{$2}, no parent found with name '#{$1}'." msg = "Ignoring subproperty #{$1}.#{$2}, no parent found with name '#{$1}'." Logger.warn(:subproperty, msg, pos[:filename], pos[:linenr]) end else items << it end end return items, warnings return items end end Loading lib/jsduck/tag/cfg.rb +1 −7 Original line number Diff line number Diff line Loading @@ -26,14 +26,8 @@ module JsDuck::Tag h[:name] = p[:name] h[:type] = p[:type] h[:default] = p[:default] h[:properties] = nest_properties(tags, pos) h[:properties] = JsDuck::Doc::Subproperties.nest(tags, pos)[0][:properties] h[:required] = true if p[:optional] == false end def nest_properties(tags, pos) items, warnings = JsDuck::Doc::Subproperties.nest(tags) warnings.each {|msg| JsDuck::Logger.warn(:subproperty, msg, pos[:filename], pos[:linenr]) } items[0][:properties] end end end lib/jsduck/tag/param.rb +1 −3 Original line number Diff line number Diff line Loading @@ -21,9 +21,7 @@ module JsDuck::Tag end def process_doc(h, tags, pos) items, warnings = JsDuck::Doc::Subproperties.nest(tags) warnings.each {|msg| JsDuck::Logger.warn(:subproperty, msg, pos[:filename], pos[:linenr]) } h[:params] = items h[:params] = JsDuck::Doc::Subproperties.nest(tags, pos) end end end lib/jsduck/tag/property.rb +1 −7 Original line number Diff line number Diff line Loading @@ -22,13 +22,7 @@ module JsDuck::Tag # Type might also come from @type, don't overwrite it with nil. h[:type] = p[:type] if p[:type] h[:default] = p[:default] h[:properties] = nest_properties(tags, pos) end def nest_properties(tags, pos) items, warnings = JsDuck::Doc::Subproperties.nest(tags) warnings.each {|msg| JsDuck::Logger.warn(:subproperty, msg, pos[:filename], pos[:linenr]) } items[0][:properties] h[:properties] = JsDuck::Doc::Subproperties.nest(tags, pos)[0][:properties] end end end lib/jsduck/tag/return.rb +1 −7 Original line number Diff line number Diff line Loading @@ -30,14 +30,8 @@ module JsDuck::Tag :type => ret[:type] || "Object", :name => ret[:name] || "return", :doc => ret[:doc] || "", :properties => nest_properties(tags, pos)[0][:properties] :properties => JsDuck::Doc::Subproperties.nest(tags, pos)[0][:properties], } end def nest_properties(tags, pos) items, warnings = JsDuck::Doc::Subproperties.nest(tags) warnings.each {|msg| JsDuck::Logger.warn(:subproperty, msg, pos[:filename], pos[:linenr]) } items end end end Loading
lib/jsduck/doc/subproperties.rb +8 −8 Original line number Diff line number Diff line require 'jsduck/util/singleton' require 'jsduck/logger' module JsDuck module Doc Loading @@ -22,13 +23,12 @@ module JsDuck # {:name => "baz"}]}, # {:name => "zap"}, # # NOTE: It returns two values: the resulting nested items array # and warnings array of :subproperty warnings that should get # printed out. def nest(raw_items) # Secondly it takes a position argument which is used for # logging warnings when bogus subproperty syntax is encountered. def nest(raw_items, pos) # First item can't be namespaced, if it is ignore the rest. if raw_items[0] && raw_items[0][:name] =~ /\./ return [raw_items[0]], [] return [raw_items[0]] end # build name-index of all items Loading @@ -39,7 +39,6 @@ module JsDuck # Otherwise look up the parent of item and add it as the # property of that parent. items = [] warnings = [] raw_items.each do |it| if it[:name] =~ /^(.+)\.([^.]+)$/ it[:name] = $2 Loading @@ -48,14 +47,15 @@ module JsDuck parent[:properties] = [] unless parent[:properties] parent[:properties] << it else warnings << "Ignoring subproperty #{$1}.#{$2}, no parent found with name '#{$1}'." msg = "Ignoring subproperty #{$1}.#{$2}, no parent found with name '#{$1}'." Logger.warn(:subproperty, msg, pos[:filename], pos[:linenr]) end else items << it end end return items, warnings return items end end Loading
lib/jsduck/tag/cfg.rb +1 −7 Original line number Diff line number Diff line Loading @@ -26,14 +26,8 @@ module JsDuck::Tag h[:name] = p[:name] h[:type] = p[:type] h[:default] = p[:default] h[:properties] = nest_properties(tags, pos) h[:properties] = JsDuck::Doc::Subproperties.nest(tags, pos)[0][:properties] h[:required] = true if p[:optional] == false end def nest_properties(tags, pos) items, warnings = JsDuck::Doc::Subproperties.nest(tags) warnings.each {|msg| JsDuck::Logger.warn(:subproperty, msg, pos[:filename], pos[:linenr]) } items[0][:properties] end end end
lib/jsduck/tag/param.rb +1 −3 Original line number Diff line number Diff line Loading @@ -21,9 +21,7 @@ module JsDuck::Tag end def process_doc(h, tags, pos) items, warnings = JsDuck::Doc::Subproperties.nest(tags) warnings.each {|msg| JsDuck::Logger.warn(:subproperty, msg, pos[:filename], pos[:linenr]) } h[:params] = items h[:params] = JsDuck::Doc::Subproperties.nest(tags, pos) end end end
lib/jsduck/tag/property.rb +1 −7 Original line number Diff line number Diff line Loading @@ -22,13 +22,7 @@ module JsDuck::Tag # Type might also come from @type, don't overwrite it with nil. h[:type] = p[:type] if p[:type] h[:default] = p[:default] h[:properties] = nest_properties(tags, pos) end def nest_properties(tags, pos) items, warnings = JsDuck::Doc::Subproperties.nest(tags) warnings.each {|msg| JsDuck::Logger.warn(:subproperty, msg, pos[:filename], pos[:linenr]) } items[0][:properties] h[:properties] = JsDuck::Doc::Subproperties.nest(tags, pos)[0][:properties] end end end
lib/jsduck/tag/return.rb +1 −7 Original line number Diff line number Diff line Loading @@ -30,14 +30,8 @@ module JsDuck::Tag :type => ret[:type] || "Object", :name => ret[:name] || "return", :doc => ret[:doc] || "", :properties => nest_properties(tags, pos)[0][:properties] :properties => JsDuck::Doc::Subproperties.nest(tags, pos)[0][:properties], } end def nest_properties(tags, pos) items, warnings = JsDuck::Doc::Subproperties.nest(tags) warnings.each {|msg| JsDuck::Logger.warn(:subproperty, msg, pos[:filename], pos[:linenr]) } items end end end