Commit 0136c17a authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Make meta-tags context-aware.

Using the available context, changing @deprecated implementation to
say the correct type of item that is deprecated.
parent 883c9a18
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ module JsDuck
          cls[group][type] = members.map {|m| format_member(m) }
        end
      end
      cls[:html_meta] = format_meta_data(cls[:meta])
      cls[:html_meta] = format_meta_data(cls)
      cls
    end

@@ -49,7 +49,7 @@ module JsDuck
      m[:params] = m[:params].map {|p| format_item(p, is_css_tag) } if m[:params]
      m[:return] = format_item(m[:return], is_css_tag) if m[:return]
      m[:properties] = m[:properties].map {|b| format_item(b, is_css_tag) } if m[:properties]
      m[:html_meta] = format_meta_data(m[:meta])
      m[:html_meta] = format_meta_data(m)
      m
    end

@@ -79,10 +79,14 @@ module JsDuck
      end
    end

    def format_meta_data(meta_data)
    def format_meta_data(context)
      result = {}
      meta_data.each_pair do |key, value|
        result[key] = MetaTagRegistry.instance[key].to_html(value) if value
      context[:meta].each_pair do |key, value|
        if value
          tag = MetaTagRegistry.instance[key]
          tag.context = context
          result[key] = tag.to_html(value)
        end
      end
      result
    end
+6 −0
Original line number Diff line number Diff line
@@ -26,6 +26,12 @@ module JsDuck
    # existance of the tag.
    attr_reader :boolean

    # Here the appropriate class or member will be injected,
    # so the to_value and to_html methods can for produce
    # different output based on whether the tag is inside class,
    # method, event, etc.
    attr_accessor :context

    # It gets passed an array of contents gathered from all meta-tags
    # of given type. It should return the value to be stored for this
    # meta-tag at :key. The returned value is also passed to #to_html
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ module JsDuck::Tag
      v = depr[:version] ? "since " + depr[:version] : ""
      <<-EOHTML
        <div class='signature-box deprecated'>
        <p>This member has been <strong>deprecated</strong> #{v}</p>
        <p>This #{@context[:tagname]} has been <strong>deprecated</strong> #{v}</p>
        #{format(depr[:text])}
        </div>
      EOHTML