diff options
Diffstat (limited to 'railties/Rakefile')
-rw-r--r-- | railties/Rakefile | 89 |
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 ---------------------------------------------------------------------------- |