aboutsummaryrefslogtreecommitdiffstats
path: root/guides/Rakefile
blob: d6dd950d012a14e01db7c283e6c6117dffcac4c4 (plain) (blame)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
namespace :guides do

  desc 'Generate guides (for authors), use ONLY=foo to process just "foo.md"'
  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

    desc "Generate .mobi file. The kindlegen executable must be in your PATH. You can get it for free from http://www.amazon.com/kindlepublishing"
    task :kindle do
      unless `kindlerb -v 2> /dev/null` =~ /kindlerb 0.1.1/  
        abort "Please `gem install kindlerb`"
      end
      unless `convert` =~ /convert/  
        abort "Please install ImageMagick`"
      end
      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

  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.

All this process is handled via rake tasks, here's a full list of them:

#{%x[rake -T]}
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.

    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
  $ rake guides:generate:kindle EDGE=1
  $ rake guides:generate GUIDES_LANGUAGE=es
    help
  end
end

task :default => 'guides:help'