From c52bec77f53a1dc4e3f61fbd45460b99f8f46fb1 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sun, 4 Apr 2010 01:36:12 -0700 Subject: 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 --- railties/guides/rails_guides/generator.rb | 47 +++++++++++++++---------------- 1 file changed, 23 insertions(+), 24 deletions(-) (limited to 'railties/guides/rails_guides/generator.rb') 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(/ Date: Sun, 4 Apr 2010 02:30:31 -0700 Subject: guides assets are now centralized in the assets directory, with standard subdirs --- railties/guides/rails_guides/generator.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'railties/guides/rails_guides/generator.rb') diff --git a/railties/guides/rails_guides/generator.rb b/railties/guides/rails_guides/generator.rb index 1454aed6e4..b8c1913819 100644 --- a/railties/guides/rails_guides/generator.rb +++ b/railties/guides/rails_guides/generator.rb @@ -107,8 +107,7 @@ module RailsGuides end def copy_assets - FileUtils.cp_r(File.join(guides_dir, 'images'), output_dir) - FileUtils.cp_r(File.join(guides_dir, 'files'), output_dir) + FileUtils.cp_r(Dir.glob("#{guides_dir}/assets/*"), output_dir) end def output_file_for(guide) -- cgit v1.2.3 From 7d7e0627a0490b6b4ddb0ee5429264ccd46f1245 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sun, 4 Apr 2010 08:42:54 -0700 Subject: fixes duplicate element IDs in some guides --- railties/guides/rails_guides/generator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/guides/rails_guides/generator.rb') diff --git a/railties/guides/rails_guides/generator.rb b/railties/guides/rails_guides/generator.rb index b8c1913819..f577182f5f 100644 --- a/railties/guides/rails_guides/generator.rb +++ b/railties/guides/rails_guides/generator.rb @@ -227,7 +227,7 @@ module RailsGuides anchors = Set.new html.scan(/