Skip to content

Commit

Permalink
force UTF-8 as external encoding in guides generation [ci skip]
Browse files Browse the repository at this point in the history
See the rationale in the comment found in the patch.
  • Loading branch information
fxn committed Mar 9, 2017
1 parent df8bee6 commit 28d0790
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions guides/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,29 @@ namespace :guides do
desc 'Generate guides (for authors), use ONLY=foo to process just "foo.md"'
task :generate => 'generate:html'

# Guides are written in UTF-8, but the environment may be configured for some
# other locale, these tasks are responsible for ensuring the default external
# encoding is UTF-8.
#
# Real use cases: Generation was reported to fail on a machine configured with
# GBK (Chinese). The docs server once got misconfigured somehow and had "C",
# which broke generation too.
task :encoding do
%w(LANG LANGUAGE LC_ALL).each do |env_var|
ENV[env_var] = "en_US.UTF-8"
end
end

namespace :generate do

desc "Generate HTML guides"
task :html do
task :html => :encoding do
ENV["WARNINGS"] = "1" # authors can't disable this
ruby "rails_guides.rb"
end

desc "Generate .mobi file. The kindlegen executable must be in your PATH. You can get it for free from http://www.amazon.com/gp/feature.html?docId=1000765211"
task :kindle do
task :kindle => :encoding do
unless `kindlerb -v 2> /dev/null` =~ /kindlerb 0.1.1/
abort "Please `gem install kindlerb` and make sure you have `kindlegen` in your PATH"
end
Expand All @@ -26,7 +39,7 @@ namespace :guides do

# Validate guides -------------------------------------------------------------------------
desc 'Validate guides, use ONLY=foo to process just "foo.html"'
task :validate do
task :validate => :encoding do
ruby "w3c_validator.rb"
end

Expand Down

0 comments on commit 28d0790

Please sign in to comment.