From 48e7f7af7aee1f6f75509037176e779308cec919 Mon Sep 17 00:00:00 2001 From: Leonard Chin Date: Thu, 19 Apr 2018 14:58:25 +0900 Subject: [PATCH 1/3] Include resource explanations in Slate output --- features/slate_documentation.feature | 2 ++ lib/rspec_api_documentation/writers/slate_writer.rb | 1 + 2 files changed, 3 insertions(+) diff --git a/features/slate_documentation.feature b/features/slate_documentation.feature index d1d77b6c..73e3b06b 100644 --- a/features/slate_documentation.feature +++ b/features/slate_documentation.feature @@ -57,6 +57,7 @@ Feature: Generate Slate documentation from test examples end resource 'Orders' do + explanation "An Order represents an amount of money to be paid" get '/orders' do response_field :page, "Current page" @@ -216,6 +217,7 @@ Feature: Generate Slate documentation from test examples ## Creating an order + An Order represents an amount of money to be paid ### Request diff --git a/lib/rspec_api_documentation/writers/slate_writer.rb b/lib/rspec_api_documentation/writers/slate_writer.rb index d2373dcb..0dfd9b96 100644 --- a/lib/rspec_api_documentation/writers/slate_writer.rb +++ b/lib/rspec_api_documentation/writers/slate_writer.rb @@ -26,6 +26,7 @@ def write IndexHelper.sections(index.examples, @configuration).each do |section| file.write "# #{section[:resource_name]}\n\n" + file.write "#{section[:resource_explanation]}\n\n" section[:examples].sort_by!(&:description) unless configuration.keep_source_order section[:examples].each do |example| From 7197b0dc5f524923002220aab882d220b43c0292 Mon Sep 17 00:00:00 2001 From: Leonard Chin Date: Thu, 19 Apr 2018 15:30:15 +0900 Subject: [PATCH 2/3] Don't need to sort examples again in Slate writer IndexHelper already keeps examples sorted. --- lib/rspec_api_documentation/writers/slate_writer.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/rspec_api_documentation/writers/slate_writer.rb b/lib/rspec_api_documentation/writers/slate_writer.rb index 0dfd9b96..58a96ce4 100644 --- a/lib/rspec_api_documentation/writers/slate_writer.rb +++ b/lib/rspec_api_documentation/writers/slate_writer.rb @@ -24,10 +24,8 @@ def write file.write markup_index_class.new(index, configuration).render IndexHelper.sections(index.examples, @configuration).each do |section| - file.write "# #{section[:resource_name]}\n\n" file.write "#{section[:resource_explanation]}\n\n" - section[:examples].sort_by!(&:description) unless configuration.keep_source_order section[:examples].each do |example| markup_example = markup_example_class.new(example, configuration) From 866c3ede862140984dfc4e9f599597edc470a1dd Mon Sep 17 00:00:00 2001 From: Leonard Chin Date: Thu, 19 Apr 2018 16:48:34 +0900 Subject: [PATCH 3/3] Fix feature output expectation --- features/slate_documentation.feature | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/features/slate_documentation.feature b/features/slate_documentation.feature index 73e3b06b..e06bab9e 100644 --- a/features/slate_documentation.feature +++ b/features/slate_documentation.feature @@ -215,9 +215,10 @@ Feature: Generate Slate documentation from test examples """ # Orders + An Order represents an amount of money to be paid + ## Creating an order - An Order represents an amount of money to be paid ### Request