aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2010-04-04 01:36:12 -0700
committerXavier Noria <fxn@hashref.com>2010-04-04 02:08:06 -0700
commitc52bec77f53a1dc4e3f61fbd45460b99f8f46fb1 (patch)
tree18539bf7221f515e5b05508b76975350b34f1562 /railties
parent8f9becb42632d68ae84639b19022ff7d64666a30 (diff)
downloadrails-c52bec77f53a1dc4e3f61fbd45460b99f8f46fb1.tar.gz
rails-c52bec77f53a1dc4e3f61fbd45460b99f8f46fb1.tar.bz2
rails-c52bec77f53a1dc4e3f61fbd45460b99f8f46fb1.zip
sanity check arguments in guides generation collapsed into a single WARNINGS flag, EDGE_GUIDES renamed to EDGE to be coherent with the rest, preamble revised
Diffstat (limited to 'railties')
-rw-r--r--railties/guides/rails_guides/generator.rb47
1 files changed, 23 insertions, 24 deletions
diff --git a/railties/guides/rails_guides/generator.rb b/railties/guides/rails_guides/generator.rb
index 3d48d6b708..1454aed6e4 100644
--- a/railties/guides/rails_guides/generator.rb
+++ b/railties/guides/rails_guides/generator.rb
@@ -9,27 +9,23 @@
#
# Some arguments may be passed via environment variables:
#
-# WARN_BROKEN_LINKS
-# Internal references (anchors) are checked. If a reference is broken
-# levenshtein distance is used to suggest an existing one. This is useful
-# since IDs are generated by Textile from titles and thus rewordings alter
-# them.
+# WARNINGS
+# If you are writing a guide, please work always with WARNINGS=1. Users can
+# generate the guides, and thus this flag is off by default.
#
-# WARN_DUPLICATE_HEADERS
-# Warns about duplicate IDs in headers. Please do resolve them, if any,
-# so guides are valid XHTML.
+# Internal links (anchors) are checked. If a reference is broken levenshtein
+# distance is used to suggest an existing one. This is useful since IDs are
+# generated by Textile from headers and thus edits alter them.
#
-# This check only happens if WARN_BROKEN_LINKS is also active.
-#
-# EDGE_GUIDES
-# Set to "1" to indicate edge guides are generated.
+# Also detects duplicated IDs. They happen if there are headers with the same
+# text. Please do resolve them, if any, so guides are valid XHTML.
#
# ALL
-# Generate all guides.
-
+# Set to "1" to force the generation of all guides.
+#
# ONLY
-# If you want to generate only one or a set of guides.
-# Prefixes are enough:
+# Use ONLY if you want to generate only one or a set of guides. Prefixes are
+# enough:
#
# # generates only association_basics.html
# ONLY=assoc ruby rails_guides.rb
@@ -39,9 +35,12 @@
# # generates only
# ONLY=assoc,migrations ruby rails_guides.rb
#
-# Note that if you are working on a guide, generation will
-# by default process only that one, so ONLY is rarely used
-# nowadays.
+# Note that if you are working on a guide generation will by default process
+# only that one, so ONLY is rarely used nowadays.
+#
+# EDGE
+# Set to "1" to indicate generated guides should be marked as edge. This
+# inserts a badge and changes the preamble of the home page.
#
# ---------------------------------------------------------------------------
@@ -85,7 +84,7 @@ module RailsGuides
end
def set_edge
- @edge = ENV['EDGE_GUIDES'] == '1'
+ @edge = ENV['EDGE'] == '1'
end
def generate_guides
@@ -97,11 +96,11 @@ module RailsGuides
def guides_to_generate
guides = Dir.entries(source_dir).grep(GUIDES_RE)
- ENV.key?("ONLY") ? select_only(guides) : guides
+ ENV.key?('ONLY') ? select_only(guides) : guides
end
def select_only(guides)
- prefixes = ENV["ONLY"].split(",").map(&:strip)
+ prefixes = ENV['ONLY'].split(",").map(&:strip)
guides.select do |guide|
prefixes.any? {|p| guide.start_with?(p)}
end
@@ -138,7 +137,7 @@ module RailsGuides
result = view.render(:layout => 'layout', :text => textile(body))
- warn_about_broken_links(result) if ENV.key?("WARN_BROKEN_LINKS")
+ warn_about_broken_links(result) if ENV['WARNINGS'] == '1'
end
f.write result
@@ -229,7 +228,7 @@ module RailsGuides
anchors = Set.new
html.scan(/<h\d\s+id="([^"]+)/).flatten.each do |anchor|
if anchors.member?(anchor)
- puts "*** DUPLICATE HEADER ID: #{anchor}, please consider rewording" if ENV.key?("WARN_DUPLICATE_HEADERS")
+ puts "*** DUPLICATE HEADER ID: #{anchor}, please consider rewording"
else
anchors << anchor
end