Commit 545f1088 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Add :class_icon field to Tags.

Use it in @component and @singleton to define a CSS class name for
the tag that's used for the class instead of the default.

Eliminate the hard-wired icon rendering of class header.

Though the CSS and icons themselves are still hard-wired.
parent 3f4b3620
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ module JsDuck
      def export(cls)
        data = @full_exporter.export(cls)

        data[:component] = cls.inherits_from?("Ext.Component")
        data[:classIcon] = Web::Icons.class_icon(cls)
        data[:superclasses] = cls.superclasses.collect {|c| c[:name] }
        data[:subclasses] = @relations.subclasses(cls).collect {|c| c[:name] }.sort
        data[:mixedInto] = @relations.mixed_into(cls).collect {|c| c[:name] }.sort
+1 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ module JsDuck::Tag
  class Component < BooleanTag
    def initialize
      @pattern = "component"
      @class_icon = "icon-component"
      super
    end
  end
+1 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ module JsDuck::Tag
    def initialize
      @pattern = "singleton"
      @ext_define_pattern = "singleton"
      @class_icon = "icon-singleton"
      super
    end

+5 −0
Original line number Diff line number Diff line
@@ -133,6 +133,11 @@ module JsDuck::Tag
    #
    attr_reader :css

    # Changes the icon CSS class name when the tag is used with in
    # @class doc-comment.  Used by @singleton and @component tags to
    # display a different icon that the default.
    attr_reader :class_icon

    # Returns all descendants of JsDuck::Tag::Tag class.
    def self.descendants
      result = []
+8 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ module JsDuck
      @html_renderers_sorted = false
      @member_types = []
      @css = []
      @class_icon_providers = []

      instantiate_tags(TagLoader.new(load_paths).load_all)
    end
@@ -74,6 +75,10 @@ module JsDuck
        if tag.css
          @css << tag.css
        end

        if tag.class_icon
          @class_icon_providers << tag.tagname
        end
      end
    end

@@ -88,6 +93,9 @@ module JsDuck
    # (and in order they should be shown in).
    attr_reader :signatures

    # Array of tagnames which provide an icon tag.
    attr_reader :class_icon_providers

    # Same as #member_types, but returns just the names of member types.
    def member_type_names
      member_types.map {|mt| mt[:name] }
Loading