2009-02-03 20:44:58 -05:00
|
|
|
pwd = File.dirname(__FILE__)
|
2009-10-10 16:59:13 -04:00
|
|
|
$:.unshift pwd
|
|
|
|
|
2010-07-30 15:50:38 -04: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.
|
|
|
|
File.exists?('Gemfile')
|
|
|
|
end
|
|
|
|
|
2009-10-10 16:59:13 -04:00
|
|
|
# Loading Action Pack requires rack and erubis.
|
|
|
|
require 'rubygems'
|
2009-02-03 20:44:58 -05:00
|
|
|
|
2009-03-17 08:26:34 -04:00
|
|
|
begin
|
2010-03-15 17:06:27 -04:00
|
|
|
# Guides generation in the Rails repo.
|
2012-03-17 11:32:49 -04:00
|
|
|
as_lib = File.join(pwd, "../activesupport/lib")
|
|
|
|
ap_lib = File.join(pwd, "../actionpack/lib")
|
2009-03-17 08:26:34 -04:00
|
|
|
|
2010-03-15 17:06:27 -04:00
|
|
|
$:.unshift as_lib if File.directory?(as_lib)
|
|
|
|
$:.unshift ap_lib if File.directory?(ap_lib)
|
2009-03-17 08:26:34 -04:00
|
|
|
rescue LoadError
|
2010-03-15 17:06:27 -04:00
|
|
|
# Guides generation from gems.
|
|
|
|
gem "actionpack", '>= 3.0'
|
2009-03-17 08:26:34 -04:00
|
|
|
end
|
2009-02-03 20:44:58 -05:00
|
|
|
|
|
|
|
begin
|
2010-03-15 17:06:27 -04:00
|
|
|
require 'redcloth'
|
2009-02-03 20:44:58 -05:00
|
|
|
rescue Gem::LoadError
|
2011-01-12 15:12:44 -05:00
|
|
|
# This can happen if doc:guides is executed in an application.
|
2010-07-30 15:50:38 -04:00
|
|
|
$stderr.puts('Generating guides requires RedCloth 4.1.1+.')
|
|
|
|
$stderr.puts(<<ERROR) if bundler?
|
|
|
|
Please add
|
|
|
|
|
2011-01-12 15:12:44 -05:00
|
|
|
gem 'RedCloth', '~> 4.2'
|
2010-07-30 15:50:38 -04:00
|
|
|
|
|
|
|
to the Gemfile, run
|
|
|
|
|
|
|
|
bundle install
|
|
|
|
|
|
|
|
and try again.
|
|
|
|
ERROR
|
|
|
|
|
2009-02-03 20:44:58 -05:00
|
|
|
exit 1
|
|
|
|
end
|
|
|
|
|
2010-03-15 17:06:27 -04:00
|
|
|
require "rails_guides/textile_extensions"
|
2009-02-03 20:44:58 -05:00
|
|
|
RedCloth.send(:include, RailsGuides::TextileExtensions)
|
|
|
|
|
2010-03-15 17:06:27 -04:00
|
|
|
require "rails_guides/generator"
|
|
|
|
RailsGuides::Generator.new.generate
|