2012-05-27 03:29:47 +08:00
|
|
|
namespace :guides do
|
|
|
|
|
2012-09-07 12:09:56 +08:00
|
|
|
desc 'Generate guides (for authors), use ONLY=foo to process just "foo.md"'
|
2012-05-27 03:29:47 +08:00
|
|
|
task :generate => 'generate:html'
|
|
|
|
|
|
|
|
namespace :generate do
|
|
|
|
|
|
|
|
desc "Generate HTML guides"
|
|
|
|
task :html do
|
|
|
|
ENV["WARN_BROKEN_LINKS"] = "1" # authors can't disable this
|
|
|
|
ruby "rails_guides.rb"
|
|
|
|
end
|
|
|
|
|
2012-05-29 05:20:10 +08:00
|
|
|
desc "Generate .mobi file. The kindlegen executable must be in your PATH. You can get it for free from http://www.amazon.com/kindlepublishing"
|
2012-05-27 03:29:47 +08:00
|
|
|
task :kindle do
|
2012-11-29 00:25:32 +08:00
|
|
|
unless `kindlerb -v 2> /dev/null` =~ /kindlerb 0.1.1/
|
|
|
|
abort "Please `gem install kindlerb`"
|
|
|
|
end
|
|
|
|
unless `convert` =~ /convert/
|
|
|
|
abort "Please install ImageMagick`"
|
|
|
|
end
|
2012-05-27 03:29:47 +08:00
|
|
|
ENV['KINDLE'] = '1'
|
|
|
|
Rake::Task['guides:generate:html'].invoke
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Validate guides -------------------------------------------------------------------------
|
|
|
|
desc 'Validate guides, use ONLY=foo to process just "foo.html"'
|
|
|
|
task :validate do
|
|
|
|
ruby "w3c_validator.rb"
|
|
|
|
end
|
2012-03-17 23:32:49 +08:00
|
|
|
|
2012-05-27 04:05:52 +08:00
|
|
|
desc "Show help"
|
|
|
|
task :help do
|
|
|
|
puts <<-help
|
|
|
|
|
|
|
|
Guides are taken from the source directory, and the resulting HTML goes into the
|
|
|
|
output directory. Assets are stored under files, and copied to output/files as
|
|
|
|
part of the generation process.
|
|
|
|
|
2012-05-29 05:17:00 +08:00
|
|
|
All this process is handled via rake tasks, here's a full list of them:
|
|
|
|
|
|
|
|
#{%x[rake -T]}
|
2012-05-27 04:05:52 +08:00
|
|
|
Some arguments may be passed via environment variables:
|
|
|
|
|
|
|
|
WARNINGS=1
|
|
|
|
Internal links (anchors) are checked, also detects duplicated IDs.
|
|
|
|
|
|
|
|
ALL=1
|
|
|
|
Force generation of all guides.
|
|
|
|
|
|
|
|
ONLY=name
|
|
|
|
Useful if you want to generate only one or a set of guides.
|
2012-09-01 00:01:06 +08:00
|
|
|
|
2012-05-27 04:05:52 +08:00
|
|
|
Generate only association_basics.html:
|
|
|
|
ONLY=assoc
|
|
|
|
|
|
|
|
Separate many using commas:
|
|
|
|
ONLY=assoc,migrations
|
|
|
|
|
|
|
|
GUIDES_LANGUAGE
|
|
|
|
Use it when you want to generate translated guides in
|
|
|
|
source/<GUIDES_LANGUAGE> folder (such as source/es)
|
|
|
|
|
|
|
|
EDGE=1
|
|
|
|
Indicate generated guides should be marked as edge.
|
|
|
|
|
|
|
|
Examples:
|
|
|
|
$ rake guides:generate ALL=1
|
|
|
|
$ rake guides:generate EDGE=1
|
2012-05-29 05:20:10 +08:00
|
|
|
$ rake guides:generate:kindle EDGE=1
|
2012-05-27 04:05:52 +08:00
|
|
|
$ rake guides:generate GUIDES_LANGUAGE=es
|
|
|
|
help
|
|
|
|
end
|
2012-03-17 23:32:49 +08:00
|
|
|
end
|
2012-05-27 04:05:52 +08:00
|
|
|
|
|
|
|
task :default => 'guides:help'
|