Commit 6e7662cf authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Unify naming of TagRegistry methods.

Have two types of accessors:

 - get* methods for accessing one tag by some kind of key.
 - <plural noun> methods for accessing arrays of tags.
parent b49ff77a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -185,7 +185,7 @@ module JsDuck
      cls[:code_type] = :ext_define

      ast["arguments"][1].each_property do |key, value, pair|
        if tag = TagRegistry.get_ext_define(key)
        if tag = TagRegistry.get_by_ext_define_pattern(key)
          tag.parse_ext_define(cls, value)
        else
          case key
+2 −2
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ module JsDuck

    def inject_formatter_to_tags
      # inject formatter to all html-producing tags
      TagRegistry.get_html_renderers.each do |tag|
      TagRegistry.html_renderers.each do |tag|
        tag.formatter = @formatter
      end
    end
@@ -93,7 +93,7 @@ module JsDuck

    def format_tags_data(context)
      result = {}
      TagRegistry.get_html_renderers.each do |tag|
      TagRegistry.html_renderers.each do |tag|
        if context[tag.key]
          result[tag.key] = tag.to_html(context)
        end
+1 −1
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@ module JsDuck

      if !name
        # ignore
      elsif tag = TagRegistry.get_tag(name)
      elsif tag = TagRegistry.get_by_pattern(name)
        match(/\w+/)
        tag.parse(self)
        skip_white
+26 −18
Original line number Diff line number Diff line
@@ -60,32 +60,24 @@ module JsDuck
      JsDuck::Tag::Tag.descendants.sort {|a, b| a.to_s <=> b.to_s }
    end

    # Accesses tag by @name pattern
    def get_tag(name)
      @patterns[name]
    end
    #
    # Accessors for lists of tags
    #

    # Returns all multiline tags.
    attr_reader :multiliners

    # Accesses tag by Ext.define pattern
    def get_ext_define(name)
      @ext_define_patterns[name]
    end

    # Default values for class config when Ext.define is encountered.
    attr_reader :ext_define_defaults

    # Accesses tag by key name - the symbol under which the tag data
    # is stored in final hash.
    def get_by_key(key)
      @keys[key]
    end
    # Array of attributes to be shown in member signatures
    # (and in order they should be shown in).
    attr_reader :signatures

    # Returns tags for rendering HTML.  One can ask for tags for
    # rendering either :top or :bottom section.  By default renderers
    # for both sections are returned.
    def get_html_renderers(position = :all)
    def html_renderers(position = :all)
      if position == :all
        @html_renderers[:top] + @html_renderers[:bottom]
      else
@@ -93,9 +85,25 @@ module JsDuck
      end
    end

    # Array of attributes to be shown in member signatures
    # (and in order they should be shown in).
    attr_reader :signatures
    #
    # Accessors for a single tag
    #

    # Accesses tag by @name pattern
    def get_by_pattern(name)
      @patterns[name]
    end

    # Accesses tag by Ext.define pattern
    def get_by_ext_define_pattern(name)
      @ext_define_patterns[name]
    end

    # Accesses tag by key name - the symbol under which the tag data
    # is stored in final hash.
    def get_by_key(key)
      @keys[key]
    end

    # Gives access to assets from @aside tag
    def assets=(assets)
+1 −1
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ module JsDuck
    def self.render(html_data, position)
      return if html_data.size == 0

      TagRegistry.get_html_renderers(position).map do |tag|
      TagRegistry.html_renderers(position).map do |tag|
        html_data[tag.key]
      end
    end