From c373eadb7dd62406321a9a331973fff1053b01ab Mon Sep 17 00:00:00 2001 From: Rene Saarsoo Date: Sat, 21 Sep 2013 08:44:58 -0500 Subject: [PATCH] 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 --- lib/jsduck/tag/deprecated.rb | 4 ++++ lib/jsduck/tag/deprecated_tag.rb | 10 ++++++---- lib/jsduck/tag/experimental.rb | 28 ++++++++++++++++++++++++++++ lib/jsduck/tag/removed.rb | 6 +++++- 4 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 lib/jsduck/tag/experimental.rb diff --git a/lib/jsduck/tag/deprecated.rb b/lib/jsduck/tag/deprecated.rb index d2f3971a..83b0c782 100644 --- a/lib/jsduck/tag/deprecated.rb +++ b/lib/jsduck/tag/deprecated.rb @@ -4,10 +4,14 @@ module JsDuck::Tag class Deprecated < DeprecatedTag def initialize @tagname = :deprecated + @msg = "This {TAGNAME} has been deprected" @css = <<-EOCSS .signature .deprecated { background-color: #aa0000; } + .deprecated-box { + border: 2px solid #aa0000; + } .deprecated-box strong { color: white; background-color: #aa0000; diff --git a/lib/jsduck/tag/deprecated_tag.rb b/lib/jsduck/tag/deprecated_tag.rb index b76cfc48..322b683c 100644 --- a/lib/jsduck/tag/deprecated_tag.rb +++ b/lib/jsduck/tag/deprecated_tag.rb @@ -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
-

This #{context[:tagname]} has been #{@tagname} #{v}

+

#{msg} #{v}

#{depr[:text]}
EOHTML diff --git a/lib/jsduck/tag/experimental.rb b/lib/jsduck/tag/experimental.rb new file mode 100644 index 00000000..66c98e25 --- /dev/null +++ b/lib/jsduck/tag/experimental.rb @@ -0,0 +1,28 @@ +require "jsduck/tag/deprecated_tag" + +module JsDuck::Tag + class Experimental < DeprecatedTag + def initialize + @tagname = :experimental + @msg = "This {TAGNAME} is experimental" + @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 diff --git a/lib/jsduck/tag/removed.rb b/lib/jsduck/tag/removed.rb index f5a01cb1..50ce994d 100644 --- a/lib/jsduck/tag/removed.rb +++ b/lib/jsduck/tag/removed.rb @@ -7,6 +7,7 @@ module JsDuck::Tag class Removed < DeprecatedTag def initialize @tagname = :removed + @msg = "This {TAGNAME} has been removed" # 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; } -- GitLab