Skip to content

Commit 3ec786e

Browse files
committed
added docset cheetsheet generator
1 parent 578defb commit 3ec786e

File tree

3 files changed

+87
-1
lines changed

3 files changed

+87
-1
lines changed

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
config
2+
docset
23
sass
34
source
45
styleguide

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"name": "openwebicons",
33
"version": "1.3.2",
44
"main": ["./css/openwebicons.css", "./css/openwebicons-bootstrap.css"],
5-
"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"],
5+
"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"],
66
"description": "OpenWeb Icons"
77
}

docset/openwebicons.rb

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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

Comments
 (0)