-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRakefile
49 lines (44 loc) · 1.41 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
require 'rake'
SOURCE = "."
CONFIG = {
'posts' => File.join(SOURCE, "_posts"),
}
desc "Create new stylesheet skeleton"
task :guide do
abort("rake aborted: '#{CONFIG['posts']}' directory not found.") unless FileTest.directory?(CONFIG['posts'])
title = ENV["title"] || "styleguide"
slug = title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
filename = File.join(CONFIG['posts'], "#{Time.now.strftime('%Y-%m-%d')}-#{slug}.md")
puts "Creating new styleguide: #{filename}"
default_headings = %w{documentation syntax naming classes exceptions collections strings regular-expressions}
open(filename, 'w') do |post|
post.puts "---"
post.puts "layout: styleguide"
post.puts "title: \"#{title.gsub(/-/,' ')}\""
post.puts "---"
post.puts ""
post.puts "## <a id='TOC'>Table of Contents</a>"
default_headings.each do | heading |
post.puts "* [#{heading.capitalize}](##{heading})"
end
post.puts ""
default_headings.each do | heading |
post.puts "## <a id='#{heading}'>#{heading.capitalize}</a>"
post.puts "* Something they should do"
post.puts "* Something else they should do"
post.puts ""
post.puts "```"
post.puts "# Bad"
post.puts "x = code"
post.puts "code should do something"
post.puts ""
post.puts "# Good"
post.puts "x = code"
post.puts "code should show something"
post.puts "```"
post.puts ""
post.puts "**[[^]](#TOC)**"
post.puts ""
end
end
end