API ドキュメントを公開ドキュメントと開発者ドキュメントに分けようとしています。これにより、私以外の人に提供できる別のドキュメントを持つことができます。
このために、Rails とrspec_api_documentationとして知られる gem を使用していますが、動作させることができません。github ページ内で提供されている構成オプションが機能しないようです。
最初に自分のプロジェクトで試し、次にサンプル アプリケーションをチェックして、そこで変更を加えました。
受け入れ_ヘルパー.rb:
...
# Only document examples marked as 'public'
config.define_group :public do |config|
config.filter = :public
end
# Only document examples marked as 'developers'
config.define_group :developers do |config|
config.filter = :developers
end
...
orders_spec.rb:
...
example_request "Updating an order", :document => :public do
...
example_request "Deleting an order", :document => :developers do
...
出力:
Maunos-MacBook-Pro:example maunovaha$ rake docs:generate
/Users/maunovaha/.rvm/rubies/ruby-2.1.3/bin/ruby -I/Users/maunovaha/.rvm/gems/ruby-2.1.3/gems/rspec-core-3.0.1/lib:/Users/maunovaha/.rvm/gems/ruby-2.1.3/gems/rspec-support-3.0.0/lib -S /Users/maunovaha/.rvm/gems/ruby-2.1.3/gems/rspec-core-3.0.1/exe/rspec spec/acceptance/orders_spec.rb --format RspecApiDocumentation::ApiFormatter
Generating API Docs
Run options: include {:focus=>true}
All examples were filtered out; ignoring {:focus=>true}
Orders
PUT /orders/:id
* Updating an order
POST /orders
* Creating an order
DELETE /orders/:id
! Deleting an order (FAILED)
GET /orders
* Getting a list of orders
HEAD /orders
* Getting the headers
GET /orders/:id
* Getting a specific order
Failures:
1) Orders DELETE /orders/:id Deleting an order
Failure/Error: Unable to find matching line from backtrace
ActionDispatch::ParamsParser::ParseError:
795: unexpected token at 'document=developers'
# /Users/maunovaha/Documents/repos/rspec_api_documentation/lib/rspec_api_documentation/rack_test_client.rb:38:in `do_request'
# /Users/maunovaha/Documents/repos/rspec_api_documentation/lib/rspec_api_documentation/client_base.rb:42:in `process'
# /Users/maunovaha/Documents/repos/rspec_api_documentation/lib/rspec_api_documentation/client_base.rb:24:in `delete'
Finished in 0.06349 seconds (files took 0.8706 seconds to load)
6 examples, 1 failure
Failed examples:
rspec ./spec/acceptance/orders_spec.rb:90 # Orders DELETE /orders/:id Deleting an order
Top 6 slowest examples (0.05349 seconds, 84.2% of total time):
Orders PUT /orders/:id Updating an order
0.02879 seconds ./spec/acceptance/orders_spec.rb:82
Orders POST /orders Creating an order
0.00884 seconds ./spec/acceptance/orders_spec.rb:47
Orders GET /orders Getting a list of orders
0.0061 seconds ./spec/acceptance/orders_spec.rb:20
Orders GET /orders/:id Getting a specific order
0.00498 seconds ./spec/acceptance/orders_spec.rb:66
Orders HEAD /orders Getting the headers
0.00273 seconds ./spec/acceptance/orders_spec.rb:27
Orders DELETE /orders/:id Deleting an order
0.00205 seconds ./spec/acceptance/orders_spec.rb:90
Randomized with seed 47568
また、グループを削除しようとしdevelopers
ましたが、エラーは発生しませんが、生成されたファイルを/doc/api/public/index.html
開くと、「サンプルアプリ API」という空のファイルになります。
助けていただければ幸いです。