From 52e2a9cc63f54219ffbc4a615b7fdd1216280728 Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Sat, 23 Jan 2010 01:05:24 -0800 Subject: [PATCH] A rake task to turn normal files into nanoc items. --- doc-src/Rakefile | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/doc-src/Rakefile b/doc-src/Rakefile index f484d249..1d3e0559 100644 --- a/doc-src/Rakefile +++ b/doc-src/Rakefile @@ -1 +1,19 @@ -require 'nanoc3/tasks' \ No newline at end of file +require 'nanoc3/tasks' + +desc "Make files into items." +task :itemize do + Dir.glob("content/**/*").each do |filename| + yaml_file = File.join(File.dirname(filename), File.basename(filename)[0..-(File.extname(filename).size)]) + "yaml" + if File.extname(filename) == ".yaml" + # skip + elsif File.exists?(yaml_file) + # skip + elsif File.directory?(filename) + else + puts "Itemizing #{filename}" + File.open(yaml_file,"w") do |f| + f.write("---\nextension: #{File.extname(filename)[1..-1]}") + end + end + end +end