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-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
|
2012-09-07 00:09:56 -04:00
|
|
|
require 'redcarpet'
|
2013-04-30 09:49:03 -04:00
|
|
|
rescue LoadError
|
2011-01-12 15:12:44 -05:00
|
|
|
# This can happen if doc:guides is executed in an application.
|
2012-09-07 00:09:56 -04:00
|
|
|
$stderr.puts('Generating guides requires Redcarpet 2.1.1+.')
|
2010-07-30 15:50:38 -04:00
|
|
|
$stderr.puts(<<ERROR) if bundler?
|
|
|
|
Please add
|
|
|
|
|
2012-09-07 00:09:56 -04:00
|
|
|
gem 'redcarpet', '~> 2.1.1'
|
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
|
|
|
|
|
2013-08-21 23:38:38 -04: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-08-31 12:01:06 -04:00
|
|
|
require 'rails_guides/markdown'
|
2010-03-15 17:06:27 -04:00
|
|
|
require "rails_guides/generator"
|
|
|
|
RailsGuides::Generator.new.generate
|