Loading lib/jsduck/merger.rb +3 −22 Original line number Diff line number Diff line Loading @@ -43,7 +43,9 @@ module JsDuck def merge_like_method(docs, code) h = {} h[:params] = merge_params(docs, code) TagRegistry.mergers(:method_like).each do |tag| tag.merge(h, docs, code) end do_merge(h, docs, code) end Loading Loading @@ -79,27 +81,6 @@ module JsDuck h end def merge_params(docs, code) explicit = docs[:params] || [] implicit = code_matches_doc?(docs, code) ? (code[:params] || []) : [] # Override implicit parameters with explicit ones # But if explicit ones exist, don't append the implicit ones. params = [] (explicit.length > 0 ? explicit.length : implicit.length).times do |i| im = implicit[i] || {} ex = explicit[i] || {} params << { :type => ex[:type] || im[:type] || "Object", :name => ex[:name] || im[:name] || "", :doc => ex[:doc] || im[:doc] || "", :optional => ex[:optional] || false, :default => ex[:default], :properties => ex[:properties] || [], } end params end def merge_name(docs, code) if docs[:name] docs[:name] Loading lib/jsduck/tag/param.rb +34 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ module JsDuck::Tag def initialize @pattern = "param" @key = :param @merge_context = :method_like end # @param {Type} [name=default] (optional) ... Loading @@ -23,5 +24,38 @@ module JsDuck::Tag def process_doc(h, tags, pos) h[:params] = JsDuck::Doc::Subproperties.nest(tags, pos) end def merge(h, docs, code) h[:params] = merge_params(docs, code) end private def merge_params(docs, code) explicit = docs[:params] || [] implicit = code_matches_doc?(docs, code) ? (code[:params] || []) : [] # Override implicit parameters with explicit ones # But if explicit ones exist, don't append the implicit ones. params = [] (explicit.length > 0 ? explicit.length : implicit.length).times do |i| im = implicit[i] || {} ex = explicit[i] || {} params << { :type => ex[:type] || im[:type] || "Object", :name => ex[:name] || im[:name] || "", :doc => ex[:doc] || im[:doc] || "", :optional => ex[:optional] || false, :default => ex[:default], :properties => ex[:properties] || [], } end params end # True if the name detected from code matches with explicitly # documented name. Also true when no explicit name documented. def code_matches_doc?(docs, code) return docs[:name] == nil || docs[:name] == code[:name] end end end Loading
lib/jsduck/merger.rb +3 −22 Original line number Diff line number Diff line Loading @@ -43,7 +43,9 @@ module JsDuck def merge_like_method(docs, code) h = {} h[:params] = merge_params(docs, code) TagRegistry.mergers(:method_like).each do |tag| tag.merge(h, docs, code) end do_merge(h, docs, code) end Loading Loading @@ -79,27 +81,6 @@ module JsDuck h end def merge_params(docs, code) explicit = docs[:params] || [] implicit = code_matches_doc?(docs, code) ? (code[:params] || []) : [] # Override implicit parameters with explicit ones # But if explicit ones exist, don't append the implicit ones. params = [] (explicit.length > 0 ? explicit.length : implicit.length).times do |i| im = implicit[i] || {} ex = explicit[i] || {} params << { :type => ex[:type] || im[:type] || "Object", :name => ex[:name] || im[:name] || "", :doc => ex[:doc] || im[:doc] || "", :optional => ex[:optional] || false, :default => ex[:default], :properties => ex[:properties] || [], } end params end def merge_name(docs, code) if docs[:name] docs[:name] Loading
lib/jsduck/tag/param.rb +34 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ module JsDuck::Tag def initialize @pattern = "param" @key = :param @merge_context = :method_like end # @param {Type} [name=default] (optional) ... Loading @@ -23,5 +24,38 @@ module JsDuck::Tag def process_doc(h, tags, pos) h[:params] = JsDuck::Doc::Subproperties.nest(tags, pos) end def merge(h, docs, code) h[:params] = merge_params(docs, code) end private def merge_params(docs, code) explicit = docs[:params] || [] implicit = code_matches_doc?(docs, code) ? (code[:params] || []) : [] # Override implicit parameters with explicit ones # But if explicit ones exist, don't append the implicit ones. params = [] (explicit.length > 0 ? explicit.length : implicit.length).times do |i| im = implicit[i] || {} ex = explicit[i] || {} params << { :type => ex[:type] || im[:type] || "Object", :name => ex[:name] || im[:name] || "", :doc => ex[:doc] || im[:doc] || "", :optional => ex[:optional] || false, :default => ex[:default], :properties => ex[:properties] || [], } end params end # True if the name detected from code matches with explicitly # documented name. Also true when no explicit name documented. def code_matches_doc?(docs, code) return docs[:name] == nil || docs[:name] == code[:name] end end end