Commit 7bc2dd6a authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Implement MetaTagRegistry - central store for meta-tags.

This way the hash of tagname->tag is built in one place just once.
Also no need to pass around the meta_tags array to every object
that happens to deal with meta-tags.

The list of signature attributes is also produced by this registry.
parent 89e6dcac
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@ require 'jsduck/json_duck'
require 'jsduck/icons'
require 'jsduck/search_data'
require 'jsduck/stats'
require 'jsduck/class'
require 'jsduck/meta_tag_registry'

module JsDuck

@@ -27,7 +27,7 @@ module JsDuck
          :examples => @examples.to_array,
          :search => SearchData.new.create(@relations.classes),
          :stats => @opts.stats ? Stats.new.create(@relations.classes) : [],
          :signatureAttributes => Class.signature_attributes,
          :signatures => MetaTagRegistry.instance.signatures,
          :localStorageDb => @opts.local_storage_db,
          :showPrintButton => @opts.seo,
          :touchExamplesUi => @opts.touch_examples_ui,
+2 −2
Original line number Diff line number Diff line
require 'jsduck/full_exporter'
require 'jsduck/renderer'
require 'jsduck/doc_formatter'
require 'jsduck/meta_tag_registry'

module JsDuck

@@ -12,8 +13,7 @@ module JsDuck
      @renderer = Renderer.new
      # Inject formatter to all meta-tags.
      doc_formatter = DocFormatter.new(relations, opts)
      opts.meta_tags.each {|tag| tag.formatter = doc_formatter }
      @renderer.meta_tags = opts.meta_tags
      MetaTagRegistry.instance.tags.each {|tag| tag.formatter = doc_formatter }
    end

    # Returns compacted class data hash which contains an additional
+0 −14
Original line number Diff line number Diff line
@@ -255,20 +255,6 @@ module JsDuck
        :css_mixin => [],
      }
    end

    # Returns array of attributes to be shown in member signatures
    # (and in order they should be shown in).
    def self.signature_attributes
      return [
        {:name => :static,     :short => "STA"},
        {:name => :protected,  :short => "PRO"},
        {:name => :deprecated, :short => "DEP"},
        {:name => :required,   :short => "REQ"},
        {:name => :template,   :short => "TMP"},
        {:name => :abstract,   :short => "ABS"},
        {:name => :readonly,   :short => "R O"},
      ]
    end
  end

end
+0 −1
Original line number Diff line number Diff line
@@ -14,7 +14,6 @@ module JsDuck
      @relations = relations
      @formatter = formatter
      @include_types = true
      @meta_tags = []
    end

    # Runs the formatter on doc object of a class.
+1 −1
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ module JsDuck
  class CssParser
    def initialize(input, options = {})
      @lex = Lexer.new(input)
      @doc_parser = DocParser.new(:css, options[:meta_tags])
      @doc_parser = DocParser.new(:css)
      @docs = []
    end

Loading