Browse files

be lazy loading SDoc

  • Loading branch information...
1 parent 5190871 commit f01b7570c5b2ec16083aaaa8b7e53441c74bfbb8 @fxn fxn committed Mar 30, 2013
View
2 guides/code/getting_started/Gemfile
@@ -23,7 +23,7 @@ gem 'turbolinks'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
- gem 'sdoc'
+ gem 'sdoc', require: false
end
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
View
15 railties/lib/rails/api/task.rb
@@ -69,12 +69,11 @@ def initialize(name)
options << '-m' << api_main
options << '-e' << 'UTF-8'
- options << '-f' << 'sdoc'
- options << '-T' << 'rails'
configure_rdoc_files
before_running_rdoc do
+ load_and_configure_sdoc
setup_horo_variables
end
end
@@ -84,6 +83,15 @@ def desc(description)
# no-op
end
+ def load_and_configure_sdoc
+ require 'sdoc'
+ options << '-f' << 'sdoc'
+ options << '-T' << 'rails'
+ rescue LoadError
+ $stderr.puts %(Unable to load SDoc, please add\n\n gem 'sdoc', require: false\n\nto the Gemfile.)
+ exit 1
+ end
+
def configure_rdoc_files
rdoc_files.include(api_main)
@@ -111,9 +119,8 @@ def api_main
end
class RepoTask < Task
- def initialize(name)
+ def load_and_configure_sdoc
super
-
options << '-g' # link to GitHub, SDoc flag
end
View
2 railties/lib/rails/generators/rails/app/templates/Gemfile
@@ -11,7 +11,7 @@ source 'https://rubygems.org'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
- gem 'sdoc'
+ gem 'sdoc', require: false
end
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
View
5 railties/test/generators/app_generator_test.rb
@@ -303,6 +303,11 @@ def test_inclusion_of_debugger
assert_file "Gemfile", /# gem 'debugger'/
end
+ def test_inclusion_of_lazy_loaded_sdoc
+ run_generator
+ assert_file 'Gemfile', /gem 'sdoc', require: false/
+ end
+
def test_template_from_dir_pwd
FileUtils.cd(Rails.root)
assert_match(/It works from file!/, run_generator([destination_root, "-m", "lib/template.rb"]))

0 comments on commit f01b757

Please sign in to comment.