Loading lib/jsduck/merger.rb +2 −4 Original line number Diff line number Diff line Loading @@ -52,10 +52,8 @@ module JsDuck def merge_like_property(docs, code) h = {} h[:type] = merge_if_code_matches(:type, docs, code) if h[:type] == nil h[:type] = code[:tagname] == :method ? "Function" : "Object" TagRegistry.mergers(:property_like).each do |tag| tag.merge(h, docs, code) end h[:default] = merge_if_code_matches(:default, docs, code) Loading lib/jsduck/tag/type.rb +26 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ module JsDuck::Tag def initialize @pattern = "type" @key = :type @merge_context = :property_like end # matches @type {type} or @type type Loading @@ -26,5 +27,30 @@ module JsDuck::Tag h[:type] = tags[0][:type] unless h[:type] end # Do the merging of :type field def merge(h, docs, code) h[:type] = merge_if_code_matches(:type, docs, code) if h[:type] == nil h[:type] = code[:tagname] == :method ? "Function" : "Object" end end private def merge_if_code_matches(key, docs, code, default=nil) if docs[key] docs[key] elsif code[key] && code_matches_doc?(docs, code) code[key] else default end 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 +2 −4 Original line number Diff line number Diff line Loading @@ -52,10 +52,8 @@ module JsDuck def merge_like_property(docs, code) h = {} h[:type] = merge_if_code_matches(:type, docs, code) if h[:type] == nil h[:type] = code[:tagname] == :method ? "Function" : "Object" TagRegistry.mergers(:property_like).each do |tag| tag.merge(h, docs, code) end h[:default] = merge_if_code_matches(:default, docs, code) Loading
lib/jsduck/tag/type.rb +26 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ module JsDuck::Tag def initialize @pattern = "type" @key = :type @merge_context = :property_like end # matches @type {type} or @type type Loading @@ -26,5 +27,30 @@ module JsDuck::Tag h[:type] = tags[0][:type] unless h[:type] end # Do the merging of :type field def merge(h, docs, code) h[:type] = merge_if_code_matches(:type, docs, code) if h[:type] == nil h[:type] = code[:tagname] == :method ? "Function" : "Object" end end private def merge_if_code_matches(key, docs, code, default=nil) if docs[key] docs[key] elsif code[key] && code_matches_doc?(docs, code) code[key] else default end 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