diff options
author | Yoshiyuki Hirano <yhirano@me.com> | 2018-04-02 18:30:23 +0900 |
---|---|---|
committer | Yoshiyuki Hirano <yhirano@me.com> | 2018-04-02 18:30:23 +0900 |
commit | f8d346f9fd0608bd4103def8879d8e23d2fc94f3 (patch) | |
tree | aeb34878e0820e2a9cfc37ba7b82fed82cebed73 /guides | |
parent | 87d9228d9d2225296f68795ef685f617a844f4df (diff) | |
download | rails-f8d346f9fd0608bd4103def8879d8e23d2fc94f3.tar.gz rails-f8d346f9fd0608bd4103def8879d8e23d2fc94f3.tar.bz2 rails-f8d346f9fd0608bd4103def8879d8e23d2fc94f3.zip |
Not generate needless files in guides
Not generate needless files:
* _license.html.erb, _welcome.html.erb are partial files.
* layout.html.erb is the layout file.
Diffstat (limited to 'guides')
-rw-r--r-- | guides/rails_guides/generator.rb | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/guides/rails_guides/generator.rb b/guides/rails_guides/generator.rb index 7205f37be7..c83538ad48 100644 --- a/guides/rails_guides/generator.rb +++ b/guides/rails_guides/generator.rb @@ -141,32 +141,34 @@ module RailsGuides puts "Generating #{guide} as #{output_file}" layout = @kindle ? "kindle/layout" : "layout" - File.open(output_path, "w") do |f| - view = ActionView::Base.new( - @source_dir, - edge: @edge, - version: @version, - mobi: "kindle/#{mobi}", - language: @language - ) - view.extend(Helpers) - - if guide =~ /\.(\w+)\.erb$/ - # Generate the special pages like the home. - # Passing a template handler in the template name is deprecated. So pass the file name without the extension. - result = view.render(layout: layout, formats: [$1], file: $`) - else - body = File.read("#{@source_dir}/#{guide}") - result = RailsGuides::Markdown.new( - view: view, - layout: layout, - edge: @edge, - version: @version - ).render(body) - - warn_about_broken_links(result) - end + view = ActionView::Base.new( + @source_dir, + edge: @edge, + version: @version, + mobi: "kindle/#{mobi}", + language: @language + ) + view.extend(Helpers) + + if guide =~ /\.(\w+)\.erb$/ + return if %w[_license _welcome layout].include?($`) + + # Generate the special pages like the home. + # Passing a template handler in the template name is deprecated. So pass the file name without the extension. + result = view.render(layout: layout, formats: [$1], file: $`) + else + body = File.read("#{@source_dir}/#{guide}") + result = RailsGuides::Markdown.new( + view: view, + layout: layout, + edge: @edge, + version: @version + ).render(body) + + warn_about_broken_links(result) + end + File.open(output_path, "w") do |f| f.write(result) end end |