Sha256: 385ca54d91df5ba1ae8c663d85bd5485ccbb3cb3d259eba236f7a8179a268a8b

Contents?: true

Size: 1.61 KB

Versions: 21

Compression:

Stored size: 1.61 KB

Contents

require "jsduck/tag/tag"

module JsDuck::Tag
  # Base class for both @deprecated and @removed.  Child classes only
  # need to define the @tagname and @msg attributes and call #super -
  # all the correct behavior will the fall out automatically.
  class DeprecatedTag < Tag
    def initialize
      if @tagname
        @pattern = @tagname.to_s
        @signature = {:long => @tagname.to_s, :short => @tagname.to_s[0..2].upcase}
        @html_position = POS_DEPRECATED
        @since = "since" unless @since
        @css += <<-EOCSS
          .deprecated-tag-box {
            text-align: center;
            color: #600;
            background-color: #fee;
          }
          .deprecated-tag-box strong {
            text-transform: uppercase;
            border-radius: 2px;
            padding: 0 3px;
          }
        EOCSS
      end
    end

    def parse_doc(p, pos)
      {
        :tagname => @tagname,
        :version => p.match(/[0-9.]+/),
        :doc => :multiline,
      }
    end

    def process_doc(h, tags, pos)
      v = {:text => tags[0][:doc] || ""}
      v[:version] = tags[0][:version] if tags[0][:version]
      h[@tagname] = v
    end

    def format(context, formatter)
      context[@tagname][:text] = formatter.format(context[@tagname][:text])
    end

    def to_html(context)
      depr = context[@tagname]
      msg = @msg.sub(/\{TAGNAME\}/, context[:tagname].to_s)
      v = depr[:version] ? "#{@since} " + depr[:version] : ""
      <<-EOHTML
        <div class='rounded-box #{@tagname}-box deprecated-tag-box'>
        <p>#{msg} #{v}</p>
        #{depr[:text]}
        </div>
      EOHTML
    end

  end
end

Version data entries

21 entries across 21 versions & 3 rubygems

Version Path
solvas-jsduck-6.0.0.30539 lib/jsduck/tag/deprecated_tag.rb
solvas-jsduck-6.0.0.9571 lib/jsduck/tag/deprecated_tag.rb
solvas-jsduck-6.0.0.6154 lib/jsduck/tag/deprecated_tag.rb
solvas-jsduck-6.0.0.4021 lib/jsduck/tag/deprecated_tag.rb
solvas-jsduck-6.0.0.2554 lib/jsduck/tag/deprecated_tag.rb
solvas-jsduck-6.0.0.1891 lib/jsduck/tag/deprecated_tag.rb
solvas-jsduck-6.0.0.beta.1888 lib/jsduck/tag/deprecated_tag.rb
jsduck-troopjs-0.0.10 lib/jsduck/tag/deprecated_tag.rb
jsduck-troopjs-0.0.9 lib/jsduck/tag/deprecated_tag.rb
jsduck-troopjs-0.0.8 lib/jsduck/tag/deprecated_tag.rb
jsduck-troopjs-0.0.7 lib/jsduck/tag/deprecated_tag.rb
jsduck-troopjs-0.0.5 lib/jsduck/tag/deprecated_tag.rb
jsduck-troopjs-0.0.4 lib/jsduck/tag/deprecated_tag.rb
jsduck-troopjs-0.0.3 lib/jsduck/tag/deprecated_tag.rb
jsduck-troopjs-0.0.1 lib/jsduck/tag/deprecated_tag.rb
jsduck-6.0.0beta lib/jsduck/tag/deprecated_tag.rb
jsduck-5.3.4 lib/jsduck/tag/deprecated_tag.rb
jsduck-5.3.3 lib/jsduck/tag/deprecated_tag.rb
jsduck-5.3.2 lib/jsduck/tag/deprecated_tag.rb
jsduck-5.3.1 lib/jsduck/tag/deprecated_tag.rb