Commit 8cba3888 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Eliminate Tag::Autodetected class.

Handle the :autodetected field entirely inside Merger class.

From code we get the :autodetected hash with :tagname value - we
use this as the initial value for :autodetected field in merge result.
By adding this, we eliminate the need for the special merge logic
in Autodetected class (which turned out to be buggy anyway).
parent 55dc211e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ module JsDuck
      h = {
        :tagname => docset[:tagname],
        :name => docs[:name] || code[:name] || "",
        :autodetected => code[:autodetected] || {},
        :files => [{:filename => filename, :linenr => linenr}],
      }

@@ -75,7 +76,6 @@ module JsDuck

    # Stores the key as flag into h[:autodetcted]
    def mark_autodetected(h, key)
      h[:autodetected] = {} unless h[:autodetected]
      h[:autodetected][key] = true
    end

lib/jsduck/tag/autodetected.rb

deleted100644 → 0
+0 −20
Original line number Diff line number Diff line
require "jsduck/tag/tag"

module JsDuck::Tag
  # There is no @autodetected tag.
  #
  # This tag class exists to take care of the merging of :autodetected
  # field.
  class Autodetected < Tag
    def initialize
      @tagname = :autodetected
      @merge_context = [:class, :member]
    end

    def merge(h, docs, code)
      if docs[:autodetected] || code[:autodetected]
        h[:autodetected] = (code[:autodetected] || {}).merge(docs[:autodetected] || {})
      end
    end
  end
end