Commit 8231a0dd authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Move @new tooltip creation out of Process::Versions.

The tooltip creation is really not the task for the Versions processor.
Moving it back to Tag::New were it was initially.
parent d4801167
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -182,6 +182,9 @@ module JsDuck
        # definitions multiple times.
        TagRegistry.instance
      end

      # The tooltip of @new can now be configured.
      TagRegistry.get_by_name(:new).init_tooltip!(self)
    end

    private
+0 −15
Original line number Diff line number Diff line
require 'jsduck/process/importer'
require 'jsduck/tag_registry'

module JsDuck
  module Process
@@ -7,8 +6,6 @@ module JsDuck
    # Generates @since and @new tags by importing JSDuck exports of
    # older versions of the same project and looking in which version
    # a class or method first appeared.
    #
    # Additionally here the tooltip text for @new tag gets injected.
    class Versions
      def initialize(relations, opts={}, importer=nil)
        @relations = relations
@@ -19,8 +16,6 @@ module JsDuck

      # Loads in exported docs and generates @since and @new tags.
      def process_all!
        init_new_tag_tooltip!

        if @opts[:imports].length > 0
          generate_since_tags(@importer.import(@opts[:imports]))
        end
@@ -28,16 +23,6 @@ module JsDuck

      private

      # Initializes the tooltip text for the signature of @new tag.
      def init_new_tag_tooltip!
        signature = TagRegistry.get_by_name(:new).signature
        if @opts[:new_since]
          signature[:tooltip] = "New since #{@opts[:new_since]}"
        elsif @opts[:imports].length > 0
          signature[:tooltip] = "New since #{@opts[:imports].last[:version]}"
        end
      end

      # Using the imported versions data, adds @since tags to all
      # classes/members/params.
      def generate_since_tags(versions)
+13 −0
Original line number Diff line number Diff line
@@ -15,5 +15,18 @@ module JsDuck::Tag
      EOCSS
      super
    end

    # Initializes the tooltip text based on the --new-since and
    # --import options passed from command line.
    #
    # NOTE: This method is explicitly called from JsDuck::Options class.
    def init_tooltip!(opts)
      if opts[:new_since]
        @signature[:tooltip] = "New since #{opts[:new_since]}"
      elsif opts[:imports].length > 0
        @signature[:tooltip] = "New since #{opts[:imports].last[:version]}"
      end
    end

  end
end