Skip to content

Commit

Permalink
added docset cheetsheet generator
Browse files Browse the repository at this point in the history
  • Loading branch information
pfefferle committed Jun 26, 2015
1 parent 578defb commit 3ec786e
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 1 deletion.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
config
docset
sass
source
styleguide
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"name": "openwebicons",
"version": "1.3.2",
"main": ["./css/openwebicons.css", "./css/openwebicons-bootstrap.css"],
"ignore": ["config", "sass", "source", "styleguide", ".DS_Store", ".editorconfig", ".gitignore", ".npmignore", ".jshintrc", "bower.json", "compile.sh", "component.json", "composer.json", "Gruntfile.js", "package.json", "README.md"],
"ignore": ["config", "docset", "sass", "source", "styleguide", ".DS_Store", ".editorconfig", ".gitignore", ".npmignore", ".jshintrc", "bower.json", "compile.sh", "component.json", "composer.json", "Gruntfile.js", "package.json", "README.md"],
"description": "OpenWeb Icons"
}
85 changes: 85 additions & 0 deletions docset/openwebicons.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/usr/bin/env ruby

require 'sass'
require 'fileutils'

# path to resources
ROOT_DIR = File.expand_path("./../", File.dirname(__FILE__))

# path to store assets
ASSETS_DIR = File.join(ROOT_DIR, "docset", "assets")

# Copy Assets to assets/
FileUtils.cp File.join(ROOT_DIR, 'css', 'openwebicons.css'), File.join(ASSETS_DIR, 'css/')
FileUtils.cp File.join(ROOT_DIR, 'font', 'openwebicons.eot'), File.join(ASSETS_DIR, 'font/')
FileUtils.cp File.join(ROOT_DIR, 'font', 'openwebicons.svg'), File.join(ASSETS_DIR, 'font/')
FileUtils.cp File.join(ROOT_DIR, 'font', 'openwebicons.ttf'), File.join(ASSETS_DIR, 'font/')
FileUtils.cp File.join(ROOT_DIR, 'font', 'openwebicons.woff'), File.join(ASSETS_DIR, 'font/')
FileUtils.cp File.join(ROOT_DIR, 'font', 'openwebicons.woff2'), File.join(ASSETS_DIR, 'font/')


# the icon vars
vars = File.read(File.join(ROOT_DIR, 'sass', '_vars.scss'))

# initiate SaSS engine
sass_engine = Sass::Engine.new(vars, :syntax => :scss, :load_paths => [File.join(ROOT_DIR, 'sass')])

# parse icons
icons = sass_engine.to_tree.children.first.expr.children

# Generate Dash Cheatsheet
cheatsheet do
title "OpenWeb Icons"
docset_file_name 'openwebicons'
keyword 'owi'
resources ASSETS_DIR
source_url 'http://pfefferle.github.io/openwebicons'

style <<-EOS
@import 'assets/css/openwebicons.css';
[class^="icon-"]:before, [class*=" icon-"]:before {
font-size: 40px;
}
EOS

category do
id "Monochrome Icons"

icons.each do |icon|
entry do
name icon.children.first.value.to_s
command "icon-#{icon.children.first.value.to_s}"
td_notes "<i class='icon-#{icon.children.first.value.to_s}'></i>"
td_notes <<-EOS
```html
<i class='icon-#{icon.children.first.value.to_s}'></i>
```
EOS
end
end
end

category do
id "Colored Icons"

icons.each do |icon|
if not icon.children[2].value.to_s == "\"monochrome\""
entry do
name "#{icon.children.first.value.to_s}"
command "icon-#{icon.children.first.value.to_s}-colored"
td_notes "<i class='icon-#{icon.children.first.value.to_s}-colored'></i>"
td_notes <<-EOS
```html
<i class="icon-#{icon.children.first.value.to_s}-colored"></i>
```
EOS
end
end
end
end

notes <<-EOS
* OpenWeb Icons by Matthias Pfefferle - http://notizblog.org/
EOS
end

0 comments on commit 3ec786e

Please sign in to comment.