Commit c373eadb authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Implement @experimental tag.

Placed it in the same group with @deprecated and @removed, so one
can also add a version number (since when the feature was added),
and a comment:

    @experimental 3.2 To try out new Google API.

Tweaked the styles of @deprecated and @removed too, so they all look
a bit better.  To allow for different message text in @experimental,
had to introduce @msg and @since instance variables to the DeprecatedTag
base class.

Fixes #239
parent b370a2a0
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -4,10 +4,14 @@ module JsDuck::Tag
  class Deprecated < DeprecatedTag
    def initialize
      @tagname = :deprecated
      @msg = "This {TAGNAME} has been <strong>deprected</strong>"
      @css = <<-EOCSS
        .signature .deprecated {
          background-color: #aa0000;
        }
        .deprecated-box {
          border: 2px solid #aa0000;
        }
        .deprecated-box strong {
          color: white;
          background-color: #aa0000;
+6 −4
Original line number Diff line number Diff line
@@ -2,14 +2,15 @@ require "jsduck/tag/tag"

module JsDuck::Tag
  # Base class for both @deprecated and @removed.  Child classes only
  # need to define the @tagname attribute and call #super - all the
  # correct behavior will the fall out automatically.
  # 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;
@@ -45,10 +46,11 @@ module JsDuck::Tag

    def to_html(context)
      depr = context[@tagname]
      v = depr[:version] ? "since " + depr[:version] : ""
      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>This #{context[:tagname]} has been <strong>#{@tagname}</strong> #{v}</p>
        <p>#{msg} #{v}</p>
        #{depr[:text]}
        </div>
      EOHTML
+28 −0
Original line number Diff line number Diff line
require "jsduck/tag/deprecated_tag"

module JsDuck::Tag
  class Experimental < DeprecatedTag
    def initialize
      @tagname = :experimental
      @msg = "This {TAGNAME} is <strong>experimental</strong>"
      @since = "Introduced in"
      # dashed border
      @css = <<-EOCSS
        .signature .experimental {
          color: #a00;
          border: 1px dashed #a00;
          background-color: #fee;
        }
        .experimental-box {
          border: 2px dashed #ccc;
        }
        .experimental-box strong {
          margin: 0 3px;
          border: 2px dashed #a00;
          color: #a00;
        }
      EOCSS
      super
    end
  end
end
+5 −1
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ module JsDuck::Tag
  class Removed < DeprecatedTag
    def initialize
      @tagname = :removed
      @msg = "This {TAGNAME} has been <strong>removed</strong>"
      # striked-through text with red border.
      @css = <<-EOCSS
        .signature .removed {
@@ -15,9 +16,12 @@ module JsDuck::Tag
          border: 1px solid #aa0000;
          text-decoration: line-through;
        }
        .removed-box {
          border: 2px solid #aa0000;
        }
        .removed-box strong {
          color: #aa0000;
          border: 1px solid #aa0000;
          border: 2px solid #aa0000;
          background-color: transparent;
          text-decoration: line-through;
        }