2009-02-04 09:44:58 +08:00
|
|
|
pwd = File.dirname(__FILE__)
|
2009-10-11 04:59:13 +08:00
|
|
|
$:.unshift pwd
|
|
|
|
|
2010-07-31 03:50:38 +08:00
|
|
|
# This is a predicate useful for the doc:guides task of applications.
|
|
|
|
def bundler?
|
|
|
|
# Note that rake sets the cwd to the one that contains the Rakefile
|
|
|
|
# being executed.
|
2013-11-02 04:15:53 +08:00
|
|
|
File.exist?('Gemfile')
|
2010-07-31 03:50:38 +08:00
|
|
|
end
|
|
|
|
|
2009-03-17 20:26:34 +08:00
|
|
|
begin
|
2010-03-16 05:06:27 +08:00
|
|
|
# Guides generation in the Rails repo.
|
2012-03-17 23:32:49 +08:00
|
|
|
as_lib = File.join(pwd, "../activesupport/lib")
|
|
|
|
ap_lib = File.join(pwd, "../actionpack/lib")
|
2009-03-17 20:26:34 +08:00
|
|
|
|
2010-03-16 05:06:27 +08:00
|
|
|
$:.unshift as_lib if File.directory?(as_lib)
|
|
|
|
$:.unshift ap_lib if File.directory?(ap_lib)
|
2009-03-17 20:26:34 +08:00
|
|
|
rescue LoadError
|
2010-03-16 05:06:27 +08:00
|
|
|
# Guides generation from gems.
|
|
|
|
gem "actionpack", '>= 3.0'
|
2009-03-17 20:26:34 +08:00
|
|
|
end
|
2009-02-04 09:44:58 +08:00
|
|
|
|
|
|
|
begin
|
2012-09-07 12:09:56 +08:00
|
|
|
require 'redcarpet'
|
2013-04-30 21:49:03 +08:00
|
|
|
rescue LoadError
|
2011-01-13 04:12:44 +08:00
|
|
|
# This can happen if doc:guides is executed in an application.
|
2014-05-14 05:30:33 +08:00
|
|
|
$stderr.puts('Generating guides requires Redcarpet 3.1.2+.')
|
2010-07-31 03:50:38 +08:00
|
|
|
$stderr.puts(<<ERROR) if bundler?
|
|
|
|
Please add
|
|
|
|
|
2014-05-14 05:30:33 +08:00
|
|
|
gem 'redcarpet', '~> 3.1.2'
|
2010-07-31 03:50:38 +08:00
|
|
|
|
|
|
|
to the Gemfile, run
|
|
|
|
|
|
|
|
bundle install
|
|
|
|
|
|
|
|
and try again.
|
|
|
|
ERROR
|
2009-02-04 09:44:58 +08:00
|
|
|
exit 1
|
|
|
|
end
|
|
|
|
|
2013-08-22 11:38:38 +08:00
|
|
|
begin
|
|
|
|
require 'nokogiri'
|
|
|
|
rescue LoadError
|
|
|
|
# This can happen if doc:guides is executed in an application.
|
|
|
|
$stderr.puts('Generating guides requires Nokogiri.')
|
|
|
|
$stderr.puts(<<ERROR) if bundler?
|
|
|
|
Please add
|
|
|
|
|
|
|
|
gem 'nokogiri'
|
|
|
|
|
|
|
|
to the Gemfile, run
|
|
|
|
|
|
|
|
bundle install
|
|
|
|
|
|
|
|
and try again.
|
|
|
|
ERROR
|
|
|
|
exit 1
|
|
|
|
end
|
|
|
|
|
2012-09-01 00:01:06 +08:00
|
|
|
require 'rails_guides/markdown'
|
2010-03-16 05:06:27 +08:00
|
|
|
require "rails_guides/generator"
|
|
|
|
RailsGuides::Generator.new.generate
|