Commit 89e6dcac authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Convert :attributes tags to :meta tags.

Each attribute is now defined in separate file as meta tag.
parent b4a9e544
Loading
Loading
Loading
Loading
+7 −10
Original line number Diff line number Diff line
@@ -57,8 +57,7 @@ module JsDuck
        :owner => cfg[:owner],
        :files => cfg[:files],
        :id => "method-" + name,
        :attributes => clone_attributes(cfg),
        :meta => cfg[:meta],
        :meta => clone_meta(cfg),
      }
    end

@@ -80,8 +79,7 @@ module JsDuck
        :owner => cfg[:owner],
        :files => cfg[:files],
        :id => "method-" + name,
        :attributes => clone_attributes(cfg),
        :meta => cfg[:meta]
        :meta => clone_meta(cfg),
      }
    end

@@ -117,8 +115,7 @@ module JsDuck
        :owner => cfg[:owner],
        :files => cfg[:files],
        :id => "event-" + name,
        :attributes => clone_attributes(cfg),
        :meta => cfg[:meta]
        :meta => clone_meta(cfg),
      }
    end

@@ -126,12 +123,12 @@ module JsDuck
      str[0,1].upcase + str[1..-1]
    end

    # Create copy of all attributes of config, except the :required
    # attribute which only applies to configs and must not be
    # Create copy of all meta attributes of config, except the
    # :required which only applies to configs and must not be
    # propagated to methods or events.
    def clone_attributes(cfg)
    def clone_meta(cfg)
      h = {}
      cfg[:attributes].each_pair do |key, value|
      cfg[:meta].each_pair do |key, value|
        h[:key] = value unless key == :required
      end
      h
+5 −6
Original line number Diff line number Diff line
@@ -92,12 +92,12 @@ module JsDuck
      [:mixins, :alternateClassNames, :files].each do |tag|
        old[tag] = old[tag] + new[tag]
      end
      # Merge attribute hashes
      new[:attributes].each_pair do |name, value|
        old[:attributes][name] = old[:attributes][name] || value
      # Merge meta hashes
      new[:meta].each_pair do |name, value|
        old[:meta][name] = old[:meta][name] || value
      end
      # Merge hashes of arrays
      [:aliases, :meta].each do |tag|
      [:aliases].each do |tag|
        new[tag].each_pair do |key, contents|
          old[tag][key] = (old[tag][key] || []) + contents
        end
@@ -133,7 +133,7 @@ module JsDuck
    end

    def add_to_class(cls, member)
      cls[member[:attributes][:static] ? :statics : :members][member[:tagname]] << member
      cls[member[:meta][:static] ? :statics : :members][member[:tagname]] << member
    end

    def add_orphan(node)
@@ -187,7 +187,6 @@ module JsDuck
        :members => Class.default_members_hash,
        :statics => Class.default_members_hash,
        :aliases => {},
        :attributes => {},
        :meta => {},
        :files => [{:filename => "", :linenr => 0, :href => ""}],
      })
+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ module JsDuck

    def compact_member(m)
      m_copy = {}
      [:name, :tagname, :owner, :attributes, :id].each do |key|
      [:name, :tagname, :owner, :meta, :id].each do |key|
        m_copy[key] = m[key]
      end
      m_copy
+1 −1
Original line number Diff line number Diff line
@@ -174,7 +174,7 @@ module JsDuck

      ms = @members_map[name] || []
      ms = ms.find_all {|m| m[:tagname] == type_name } if type_name
      ms = ms.find_all {|m| m[:attributes][:static] } if static
      ms = ms.find_all {|m| m[:meta][:static] } if static
      return ms
    end

+1 −3
Original line number Diff line number Diff line
@@ -36,8 +36,6 @@ module JsDuck
    def format_member(m)
      @formatter.doc_context = m[:files][0]
      m[:doc] = @formatter.format(m[:doc]) if m[:doc]
      depr = m[:attributes][:deprecated]
      depr[:text] = @formatter.format(depr[:text]) if depr
      if expandable?(m) || @formatter.too_long?(m[:doc])
        m[:shortDoc] = @formatter.shorten(m[:doc])
      end
@@ -53,7 +51,7 @@ module JsDuck
    end

    def expandable?(m)
      m[:params] || (m[:properties] && m[:properties].length > 0) || m[:default] || m[:attributes][:deprecated] || m[:attributes][:template]
      m[:params] || (m[:properties] && m[:properties].length > 0) || m[:default] || m[:meta][:deprecated] || m[:meta][:template]
    end

    def format_item(it, is_css_tag)
Loading