class JsDuck::TagRegistry

Access to all @tag definitions.

Attributes

signatures[R]

Array of attributes to be shown in member signatures (and in order they should be shown in).

tags[R]

Array of all available tags

Public Class Methods

configure(opts) click to toggle source

Configures TagRegistry according to the command line options.

# File lib/jsduck/tag_registry.rb, line 14
def self.configure(opts)
  if opts.tags.length > 0
    # Reconfigures the registry with additional 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
instance() click to toggle source

Access to the singleton instance (only used internally)

# File lib/jsduck/tag_registry.rb, line 8
def self.instance
  @instance = TagRegistry.new unless @instance
  @instance
end
method_missing(meth, *args, &block) click to toggle source

Redirect calls from TagRegistry.method to TagRegistry.instance.method, making it behave like other Singleton classes.

# File lib/jsduck/tag_registry.rb, line 32
def self.method_missing(meth, *args, &block)
  self.instance.send(meth, *args, &block)
end
new(load_paths=[]) click to toggle source
# File lib/jsduck/tag_registry.rb, line 36
def initialize(load_paths=[])
  @patterns = {}
  @tagnames = {}
  @signatures = []
  @tags = []

  instantiate_tags(TagLoader.new(load_paths).load_all)
end

Public Instance Methods

get_by_name(name) click to toggle source

Accesses tag by name - the symbol under which the tag data is stored in final hash.

# File lib/jsduck/tag_registry.rb, line 89
def get_by_name(name)
  @tagnames[name]
end
get_by_pattern(name) click to toggle source

Accesses tag by @name pattern

# File lib/jsduck/tag_registry.rb, line 83
def get_by_pattern(name)
  @patterns[name]
end
instantiate_tags(tag_classes) click to toggle source

Instantiates all descendants of JsDuck::Tag::Tag

# File lib/jsduck/tag_registry.rb, line 46
def instantiate_tags(tag_classes)
  tag_classes.each do |cls|
    tag = cls.new()

    Array(tag.pattern).each do |pattern|
      @patterns[pattern] = tag
    end

    if tag.tagname
      @tagnames[tag.tagname] = tag
    end

    if tag.signature
      tag.signature[:tagname] = tag.tagname
      @signatures << tag.signature
    end

    @tags << tag
  end
end