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

Auto-generated @new tags.

Along with @since tags generate @new tags.

@new tag is added to any class/member that is available since the
very latest version.

Graphically the @new tags will be rendered as stars on yellow
background.
parent 65be043d
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ module JsDuck
  module Importer
    module_function

    # Loads in exported docs and generates @since tags based on that data.
    # Loads in exported docs and generates @since and @new tags based on that data.
    def import(imports, relations)
      if imports.length > 0
        generate_since_tags(read_all(imports), relations)
@@ -56,10 +56,17 @@ module JsDuck
    # Using the imported versions data, adds @since tags to all
    # classes/members.
    def generate_since_tags(versions, relations)
      last_version = versions.last[:version]

      relations.each do |cls|
        cls[:meta][:since] = class_since(versions, cls)
        v = class_since(versions, cls)
        cls[:meta][:since] = v
        cls[:meta][:new] = true if v == last_version

        cls.all_local_members.each do |m|
          m[:meta][:since] = member_since(versions, cls, m)
          v = member_since(versions, cls, m)
          m[:meta][:since] = v
          m[:meta][:new] = true if v == last_version
        end
      end
    end

lib/jsduck/tag/new.rb

0 → 100644
+20 −0
Original line number Diff line number Diff line
require "jsduck/meta_tag"
require "jsduck/logger"

module JsDuck::Tag
  # Implementation of @new tag.
  class New < JsDuck::MetaTag
    def initialize
      @name = "new"
      @key = :new
      @signature = {:long => "&#9733;", :short => "&#9733;"} # unicode black star char
      @boolean = true
    end

    def to_value(contents)
      true
    end

  end
end
+31 −0
Original line number Diff line number Diff line
@@ -35,6 +35,8 @@ describe "JsDuck::Importer#generate_since_tags" do
    JsDuck::Importer.generate_since_tags(@versions, @relations)
  end

  # @since

  it "adds @since 1.0 to VeryOldClass" do
    @relations[0][:meta][:since].should == "1.0"
  end
@@ -63,4 +65,33 @@ describe "JsDuck::Importer#generate_since_tags" do
    @relations[0][:members][:event][0][:meta][:since].should == "3.0"
  end

  # @new

  it "doesn't add @new to VeryOldClass" do
    @relations[0][:meta][:new].should_not == true
  end

  it "doesn't add @new to OldClass" do
    @relations[1][:meta][:new].should_not == true
  end

  it "adds @new to NewClass" do
    @relations[2][:meta][:new].should == true
  end

  it "doesn't add @new to ClassWithNewName" do
    @relations[3][:meta][:new].should_not == true
  end

  it "doesn't add @new to VeryOldClass#cfg-foo" do
    @relations[0][:members][:cfg][0][:meta][:new].should_not == true
  end

  it "doesn't add @new to VeryOldClass#method-bar" do
    @relations[0][:members][:method][0][:meta][:new].should_not == true
  end

  it "adds @new to VeryOldClass#event-baz" do
    @relations[0][:members][:event][0][:meta][:new].should == true
  end
end
+3 −0
Original line number Diff line number Diff line
@@ -132,6 +132,9 @@
    background-color: $docs-text-color; }
  &.required {
    background-color: $docs-text-color; }
  &.new {
    color: $docs-text-color;
    background-color: #F5D833; }
  &.private {
    background-color: #FD6B1B; }
  &.protected {