aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2017-03-09 09:22:33 +0100
committerXavier Noria <fxn@hashref.com>2017-03-09 09:43:38 +0100
commit37770bc8d13c5c7af024e66539c79f966718aec0 (patch)
treee6249ea7d1cb3e536cfb06bf9d2abf3420b0b644 /guides
parentc741b493409a5d8ae1f2514f73570a014ddc6b57 (diff)
downloadrails-37770bc8d13c5c7af024e66539c79f966718aec0.tar.gz
rails-37770bc8d13c5c7af024e66539c79f966718aec0.tar.bz2
rails-37770bc8d13c5c7af024e66539c79f966718aec0.zip
force UTF-8 as external encoding in guides generation [ci skip]
See the rationale in the comment found in the patch.
Diffstat (limited to 'guides')
-rw-r--r--guides/Rakefile19
1 files changed, 16 insertions, 3 deletions
diff --git a/guides/Rakefile b/guides/Rakefile
index ccb42f3273..0a591558e1 100644
--- a/guides/Rakefile
+++ b/guides/Rakefile
@@ -2,15 +2,28 @@ 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
require "kindlerb"
unless Kindlerb.kindlegen_available?
abort "Please run `setupkindlerb` to install kindlegen"
@@ -25,7 +38,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