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

Let TagRegistry configure itself.

parent e8b75b3b
Loading
Loading
Loading
Loading
+1 −13
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@ require 'jsduck/util/io'
require 'jsduck/util/parallel'
require 'jsduck/tag_registry'
require 'jsduck/js/ext_patterns'
require 'jsduck/warning/parser'

module JsDuck
  module Options
@@ -84,18 +83,7 @@ module JsDuck
      end

      def configure_tags
        if @opts.tags.length > 0
          TagRegistry.reconfigure(@opts.tags)
        else
          # Ensure the TagRegistry get instantiated just once.
          # Otherwise the parallel processing causes multiple requests
          # to initialize the TagRegistry, resulting in loading the Tag
          # definitions multiple times.
          TagRegistry.instance
        end

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

      def configure_json
+15 −4
Original line number Diff line number Diff line
@@ -10,10 +10,21 @@ module JsDuck
      @instance
    end

    # Configures TagRegistry according to the command line options.
    def self.configure(opts)
      if opts.tags.length > 0
        # Reconfigures the registry with additional load paths.
    # Used in Options class.
    def self.reconfigure(load_paths)
      @instance = TagRegistry.new(load_paths)
        @instance = TagRegistry.new(opts.tags)
      else
        # Ensure the TagRegistry get instantiated just once.
        # Otherwise the parallel processing causes multiple requests
        # to initialize the TagRegistry, resulting in loading the Tag
        # definitions multiple times.
        instance
      end

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

    # Redirect calls from TagRegistry.method to TagRegistry.instance.method,