From 5790c7e674844806ee5a4f524d5cb38f7a32fa97 Mon Sep 17 00:00:00 2001 From: Will Read Date: Mon, 21 May 2012 18:46:36 -0700 Subject: [PATCH 1/2] Updating example app and docs to include information about wURL --- README.md | 18 ++++++++++-------- example/spec/spec_helper.rb | 5 ++++- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 0929a4ce..07738420 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ See the `example` folder for a sample Rails app that has been documented. ## Configuration options - app - Set the application that Rack::Test uses, defaults to `Rails.application` - docs_dir - Output folder -- format - Output format +- format - An array of output format(s). Possible values are :json, :html, or :wurl. The final option is similar to :html, but includes the wURL console. - template_path - Location of templates - filter - Filter by example document type - exclusion_filter - Filter by example document type @@ -40,14 +40,16 @@ See the `example` folder for a sample Rails app that has been documented. ### Example Configuration `spec/spec_helper.rb` - RspecApiDocumentation.configure do |config| - config.docs_dir = Rails.root.join("app", "views", "pages") +```ruby +RspecApiDocumentation.configure do |config| + config.docs_dir = Rails.root.join("app", "views", "pages") - config.define_group :public do |config| - config.docs_dir = Rails.root.join("public", "docs") - config.url_prefix = "/docs" - end - end + config.define_group :public do |config| + config.docs_dir = Rails.root.join("public", "docs") + config.url_prefix = "/docs" + end +end +``` ## Usage diff --git a/example/spec/spec_helper.rb b/example/spec/spec_helper.rb index 6d67800d..20875e8f 100644 --- a/example/spec/spec_helper.rb +++ b/example/spec/spec_helper.rb @@ -34,7 +34,10 @@ RspecApiDocumentation.configure do |config| config.docs_dir = Rails.root.join("public", "docs") - config.format = [:html, :json] + # html pages with the wURL console + config.format = [:json, :wurl] + # html pages without the wURL console + #config.format = [:json, :html] config.url_prefix = "/docs" config.curl_host = 'http://localhost:3000' end From 3df46e5e4b920e56f26f077dd00fc7f8dec483cb Mon Sep 17 00:00:00 2001 From: Will Read Date: Mon, 21 May 2012 18:50:32 -0700 Subject: [PATCH 2/2] removing rake task definition restriction to allow docs to be generated in any env --- lib/tasks/docs.rake | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/tasks/docs.rake b/lib/tasks/docs.rake index c4b572ce..d1f4e00b 100644 --- a/lib/tasks/docs.rake +++ b/lib/tasks/docs.rake @@ -1,9 +1,7 @@ require 'rspec/core/rake_task' -if Rails.env.test? || Rails.env.development? - desc 'Generate API request documentation from API specs' - RSpec::Core::RakeTask.new('docs:generate') do |t| - t.pattern = 'spec/acceptance/**/*_spec.rb' - t.rspec_opts = ["--format RspecApiDocumentation::ApiFormatter"] - end +desc 'Generate API request documentation from API specs' +RSpec::Core::RakeTask.new('docs:generate') do |t| + t.pattern = 'spec/acceptance/**/*_spec.rb' + t.rspec_opts = ["--format RspecApiDocumentation::ApiFormatter"] end