Commit 3ebec076 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Remove #merge method from Default tag class.

Let the auto-merging algorithm take care of this.

Change the generic merging algorithm to merge all non-nil fields.
Previously it checked for #key_exists? but in the case of :default
the key existed but defaulted to nil.
parent 5407cc87
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ module JsDuck
    def general_merge(h, docs, code)
      # Add all items in docs not already in result.
      docs.each_pair do |key, value|
        h[key] = value unless h.has_key?(key) || Merger::explicit?(key)
        h[key] = value unless h[key] || Merger::explicit?(key)
      end

      # Add all items in code not already in result and mark them as
@@ -60,7 +60,7 @@ module JsDuck
      # names don't conflict.
      if DocsCodeComparer.matches?(docs, code)
        code.each_pair do |key, value|
          unless h.has_key?(key) || Merger::explicit?(key)
          unless h[key] || Merger::explicit?(key)
            h[key] = value
            DocsCodeComparer.mark_autodetected(h, key)
          end
+2 −7
Original line number Diff line number Diff line
@@ -9,19 +9,14 @@ module JsDuck::Tag
  #
  #     @cfg [blah=somedefault]
  #
  # This tag class exists to take care of the merging of :default
  # fields and to generate the "Defaults to:" text in final HTML.
  # This tag class exists to generate the "Defaults to:" text in final
  # HTML.
  class Default < Tag
    def initialize
      @tagname = :default
      @merge_context = :property_like
      @html_position = POS_DEFAULT
    end

    def merge(h, docs, code)
      JsDuck::DocsCodeComparer.merge_if_matches(h, :default, docs, code)
    end

    def to_html(m)
      return if m[:default] == "undefined"