Commit 4113fb40 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Use auto-merging for everything.

Run the custom #merge methods only to do post-processing after
the automerging has completed.

Generally this means the #merge method is now mainly responsible
for setting the default value.

This eliminates the clunky calls to DocsCodeComparer class.
parent 3ebec076
Loading
Loading
Loading
Loading
+3 −21
Original line number Diff line number Diff line
@@ -23,8 +23,8 @@ module JsDuck
        :files => [{:filename => filename, :linenr => linenr}],
      }

      invoke_merge_in_tags(h, docs, code)
      general_merge(h, docs, code)
      invoke_merge_in_tags(h, docs, code)

      # Needs to be calculated last, as it relies on the existance of
      # :name, :static and :tagname fields.
@@ -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[key] || Merger::explicit?(key)
        h[key] = value unless h[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[key] || Merger::explicit?(key)
          unless h[key]
            h[key] = value
            DocsCodeComparer.mark_autodetected(h, key)
          end
@@ -68,24 +68,6 @@ module JsDuck
      end
    end

    # True when given key gets merged explicitly and should therefore
    # be skipped when auto-merging.
    def self.explicit?(key)
      @explicit = explictly_merged_fields unless @explicit
      @explicit[key]
    end

    # Generates a lookup-hash of tagnames which are explicitly merged.
    def self.explictly_merged_fields
      mergers = {}
      member_types = TagRegistry.member_type_names + [:class]
      tags = member_types.map {|type| TagRegistry.mergers(type) }.flatten.uniq
      tags.each do |tag|
        mergers[tag.tagname] = true
      end
      mergers
    end

  end

end
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ module JsDuck::Tag
    end

    def merge(h, docs, code)
      h[:aliases] = build_aliases_hash(docs[:aliases] || code[:aliases] || [])
      h[:aliases] = build_aliases_hash(h[:aliases] || [])
    end

    # Given array of full alias names like "foo.bar", "foo.baz"
+1 −1
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ module JsDuck::Tag
    end

    def merge(h, docs, code)
      h[@tagname] = docs[@tagname] || code[@tagname] || []
      h[@tagname] = [] unless h[@tagname]
    end
  end
end
+0 −1
Original line number Diff line number Diff line
@@ -38,7 +38,6 @@ module JsDuck::Tag

    # Ignore extending of the Object class
    def merge(h, docs, code)
      h[:extends] = docs[:extends] || code[:extends]
      h[:extends] = nil if h[:extends] == "Object"
    end
  end
+0 −2
Original line number Diff line number Diff line
require "jsduck/tag/tag"
require "jsduck/docs_code_comparer"

module JsDuck::Tag
  class Type < Tag
@@ -34,7 +33,6 @@ module JsDuck::Tag

    # Do the merging of :type field
    def merge(h, docs, code)
      JsDuck::DocsCodeComparer.merge_if_matches(h, :type, docs, code)
      if h[:type] == nil
        h[:type] = code[:tagname] == :method ? "Function" : "Object"
      end