aboutsummaryrefslogtreecommitdiffstats
path: root/railties/Rakefile
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2008-10-21 18:33:40 +0100
committerPratik Naik <pratiknaik@gmail.com>2008-10-21 18:33:40 +0100
commita03e2b356c66ddc8809fa2b23a2a7d652f173b8b (patch)
treeab8552913475bf94a78e4cbfbae804b2ecd9eca2 /railties/Rakefile
parent18542c9e00209679bdaacf64075819fb887ec856 (diff)
downloadrails-a03e2b356c66ddc8809fa2b23a2a7d652f173b8b.tar.gz
rails-a03e2b356c66ddc8809fa2b23a2a7d652f173b8b.tar.bz2
rails-a03e2b356c66ddc8809fa2b23a2a7d652f173b8b.zip
Merge with docrails. Also add a rake task to generate guides in your rails application :
rake doc:guides The rake task will generate guides inside doc/guides directory of your application. Open index.html to browse.
Diffstat (limited to 'railties/Rakefile')
-rw-r--r--railties/Rakefile89
1 files changed, 41 insertions, 48 deletions
diff --git a/railties/Rakefile b/railties/Rakefile
index 8de7e24738..59cbcf2322 100644
--- a/railties/Rakefile
+++ b/railties/Rakefile
@@ -272,57 +272,50 @@ Rake::RDocTask.new { |rdoc|
rdoc.rdoc_files.include('lib/commands/**/*.rb')
}
-# In this array, one defines the guides for which HTML output should be
-# generated. Specify the folder names of the guides. If the .txt filename
-# doesn't equal its folder name, then specify a hash: { 'folder_name' => 'basename' }
-guides = [
- 'getting_started_with_rails',
- # 'testing_rails_applications',
- 'creating_plugins',
- 'actioncontroller',
- 'migrations',
- { 'securing_rails_applications' => 'security' },
- { 'routing' => 'routing_outside_in' },
- { 'forms' =>'form_helpers' },
- { 'activerecord' => 'association_basics' },
- { 'activerecord' => 'finders' },
- { 'debugging' => 'debugging_rails_applications' },
- { 'caching' => 'caching_with_rails' },
- { 'benchmarking_and_profiling' => 'preamble' },
- { 'actionview' => 'layouts_and_rendering' }
-]
-
-guides_html_files = [] # autogenerated from the 'guides' variable.
-guides.each do |entry|
- if entry.is_a?(Hash)
- guide_folder = entry.keys.first
- guide_name = entry.values.first
- else
- guide_folder = entry
- guide_name = entry
- end
- input = "doc/guides/#{guide_folder}/#{guide_name}.txt"
- output = "doc/guides/#{guide_folder}/#{guide_name}.html"
- guides_html_files << output
- task output => Dir["doc/guides/#{guide_folder}/*.txt"] do
- ENV['MANUALSONRAILS_INDEX_URL'] = '../index.html'
- ENV.delete('MANUALSONRAILS_TOC')
- sh "mizuho", input, "--template", "manualsonrails", "--icons-dir", "../icons"
- end
-end
+desc "Generate guides for the framework"
+task :guides do
+ require 'mizuho/generator'
+
+ source = "doc/guides/source/"
+ html = "doc/guides/html/"
+ FileUtils.rm_r(html) if File.directory?(html)
+ FileUtils.mkdir(html)
+
+ template = File.expand_path("doc/guides/source/templates/guides.html.erb")
+ icons = File.expand_path("doc/guides/source/icons")
+
+ ignore = ['icons', 'images', 'templates', 'stylesheets']
+ ignore << 'active_record_basics.txt'
+
+ indexless = ['index.txt', 'authors.txt']
-['index', 'authors'].each do |guide|
- task "doc/guides/#{guide}.html" => "doc/guides/#{guide}.txt" do
- ENV.delete('MANUALSONRAILS_INDEX_URL')
- ENV['MANUALSONRAILS_TOC'] = 'no'
- sh "mizuho", "doc/guides/#{guide}.txt", "--template", "manualsonrails", "--icons-dir", "icons"
+ Dir.entries(source)[2..-1].each do |entry|
+ next if ignore.include?(entry)
+
+ if File.directory?(File.join(source, entry))
+ input = File.join(source, entry, 'index.txt')
+ output = File.join(html, entry)
+ else
+ input = File.join(source, entry)
+ output = File.join(html, entry).sub(/\.txt$/, '')
+ end
+
+ begin
+ puts "GENERATING => #{output}"
+ ENV['MANUALSONRAILS_TOC'] = 'no' if indexless.include?(entry)
+ Mizuho::Generator.new(input, output, template, false, icons).start
+ rescue Mizuho::GenerationError
+ STDERR.puts "*** ERROR"
+ exit 2
+ ensure
+ ENV.delete('MANUALSONRAILS_TOC')
+ end
end
-end
-desc "Generate HTML output for the guides"
-task :generate_guides => guides_html_files
-task :generate_guides => 'doc/guides/index.html'
-task :generate_guides => 'doc/guides/authors.html'
+ # Copy images and css files to html directory. These dirs are in .gitigore and shouldn't be source controlled.
+ FileUtils.cp_r File.join(source, 'images'), File.join(html, 'images')
+ FileUtils.cp_r File.join(source, 'stylesheets'), File.join(html, 'stylesheets')
+end
# Generate GEM ----------------------------------------------------------------------------