Sha256: c071a1d7765cfdb30a3ae71d069c462f8c5235a3b1150480ff6d5983a19258f4

Contents?: true

Size: 1.21 KB

Versions: 16

Compression:

Stored size: 1.21 KB

Contents

require 'jsduck/member_registry'
require 'fileutils'

module JsDuck
  module Web

    # Manages member icons.
    # Generating CSS for them and coping the image files over to output dir.
    class MemberIcons
      # Generates CSS for member icons
      def self.css
        css = []
        members_with_icons.each do |m|
          name = m[:name]
          rule = ".icon-#{name} { background-image: url(member-icons/#{name}.png); background-repeat: no-repeat; }"
          css << "#search-dropdown #{rule}"
          css << ".members .members-section #{rule}"
          css << ".members .comments-section #{rule}"
          css << ".class-overview .x-toolbar.member-links #{rule}"
        end
        css.join("\n")
      end

      # Copies all member icons to given destination dir.
      def self.write(dir)
        FileUtils.mkdir(dir)

        members_with_icons.each do |m|
          if File.exists?(m[:icon])
            FileUtils.cp(m[:icon], "#{dir}/#{m[:name]}.png")
          else
            Logger.warn(nil, "Member icon file not found", {:filename => m[:icon]})
          end
        end
      end

      def self.members_with_icons
        MemberRegistry.definitions.find_all {|m| m[:icon] }
      end
    end

  end
end

Version data entries

16 entries across 16 versions & 3 rubygems

Version Path
solvas-jsduck-6.0.0.30539 lib/jsduck/web/member_icons.rb
solvas-jsduck-6.0.0.9571 lib/jsduck/web/member_icons.rb
solvas-jsduck-6.0.0.6154 lib/jsduck/web/member_icons.rb
solvas-jsduck-6.0.0.4021 lib/jsduck/web/member_icons.rb
solvas-jsduck-6.0.0.2554 lib/jsduck/web/member_icons.rb
solvas-jsduck-6.0.0.1891 lib/jsduck/web/member_icons.rb
solvas-jsduck-6.0.0.beta.1888 lib/jsduck/web/member_icons.rb
jsduck-troopjs-0.0.10 lib/jsduck/web/member_icons.rb
jsduck-troopjs-0.0.9 lib/jsduck/web/member_icons.rb
jsduck-troopjs-0.0.8 lib/jsduck/web/member_icons.rb
jsduck-troopjs-0.0.7 lib/jsduck/web/member_icons.rb
jsduck-troopjs-0.0.5 lib/jsduck/web/member_icons.rb
jsduck-troopjs-0.0.4 lib/jsduck/web/member_icons.rb
jsduck-troopjs-0.0.3 lib/jsduck/web/member_icons.rb
jsduck-troopjs-0.0.1 lib/jsduck/web/member_icons.rb
jsduck-6.0.0beta lib/jsduck/web/member_icons.rb