|
| 1 | +#!/usr/bin/env ruby |
| 2 | + |
| 3 | +require 'sass' |
| 4 | +require 'fileutils' |
| 5 | + |
| 6 | +# path to resources |
| 7 | +ROOT_DIR = File.expand_path("./../", File.dirname(__FILE__)) |
| 8 | + |
| 9 | +# path to store assets |
| 10 | +ASSETS_DIR = File.join(ROOT_DIR, "docset", "assets") |
| 11 | + |
| 12 | +# Copy Assets to assets/ |
| 13 | +FileUtils.cp File.join(ROOT_DIR, 'css', 'openwebicons.css'), File.join(ASSETS_DIR, 'css/') |
| 14 | +FileUtils.cp File.join(ROOT_DIR, 'font', 'openwebicons.eot'), File.join(ASSETS_DIR, 'font/') |
| 15 | +FileUtils.cp File.join(ROOT_DIR, 'font', 'openwebicons.svg'), File.join(ASSETS_DIR, 'font/') |
| 16 | +FileUtils.cp File.join(ROOT_DIR, 'font', 'openwebicons.ttf'), File.join(ASSETS_DIR, 'font/') |
| 17 | +FileUtils.cp File.join(ROOT_DIR, 'font', 'openwebicons.woff'), File.join(ASSETS_DIR, 'font/') |
| 18 | +FileUtils.cp File.join(ROOT_DIR, 'font', 'openwebicons.woff2'), File.join(ASSETS_DIR, 'font/') |
| 19 | + |
| 20 | + |
| 21 | +# the icon vars |
| 22 | +vars = File.read(File.join(ROOT_DIR, 'sass', '_vars.scss')) |
| 23 | + |
| 24 | +# initiate SaSS engine |
| 25 | +sass_engine = Sass::Engine.new(vars, :syntax => :scss, :load_paths => [File.join(ROOT_DIR, 'sass')]) |
| 26 | + |
| 27 | +# parse icons |
| 28 | +icons = sass_engine.to_tree.children.first.expr.children |
| 29 | + |
| 30 | +# Generate Dash Cheatsheet |
| 31 | +cheatsheet do |
| 32 | + title "OpenWeb Icons" |
| 33 | + docset_file_name 'openwebicons' |
| 34 | + keyword 'owi' |
| 35 | + resources ASSETS_DIR |
| 36 | + source_url 'http://pfefferle.github.io/openwebicons' |
| 37 | + |
| 38 | + style <<-EOS |
| 39 | + @import 'assets/css/openwebicons.css'; |
| 40 | +
|
| 41 | + [class^="icon-"]:before, [class*=" icon-"]:before { |
| 42 | + font-size: 40px; |
| 43 | + } |
| 44 | + EOS |
| 45 | + |
| 46 | + category do |
| 47 | + id "Monochrome Icons" |
| 48 | + |
| 49 | + icons.each do |icon| |
| 50 | + entry do |
| 51 | + name icon.children.first.value.to_s |
| 52 | + command "icon-#{icon.children.first.value.to_s}" |
| 53 | + td_notes "<i class='icon-#{icon.children.first.value.to_s}'></i>" |
| 54 | + td_notes <<-EOS |
| 55 | + ```html |
| 56 | + <i class='icon-#{icon.children.first.value.to_s}'></i> |
| 57 | + ``` |
| 58 | + EOS |
| 59 | + end |
| 60 | + end |
| 61 | + end |
| 62 | + |
| 63 | + category do |
| 64 | + id "Colored Icons" |
| 65 | + |
| 66 | + icons.each do |icon| |
| 67 | + if not icon.children[2].value.to_s == "\"monochrome\"" |
| 68 | + entry do |
| 69 | + name "#{icon.children.first.value.to_s}" |
| 70 | + command "icon-#{icon.children.first.value.to_s}-colored" |
| 71 | + td_notes "<i class='icon-#{icon.children.first.value.to_s}-colored'></i>" |
| 72 | + td_notes <<-EOS |
| 73 | + ```html |
| 74 | + <i class="icon-#{icon.children.first.value.to_s}-colored"></i> |
| 75 | + ``` |
| 76 | + EOS |
| 77 | + end |
| 78 | + end |
| 79 | + end |
| 80 | + end |
| 81 | + |
| 82 | + notes <<-EOS |
| 83 | + * OpenWeb Icons by Matthias Pfefferle - http://notizblog.org/ |
| 84 | + EOS |
| 85 | +end |
0 commit comments