Skip to content

Commit f96ea3f

Browse files
committed
HTML documentation displays multilevel scopes correctly
1 parent 067c8bb commit f96ea3f

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

features/html_documentation.feature

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Feature: Generate HTML documentation from test examples
2929
get "/greetings" do
3030
parameter :target, "The thing you want to greet"
3131
parameter :scoped, "This is a scoped variable", :scope => :scope
32+
parameter :sub, "This is scoped", :scope => [:scope, :further]
3233
3334
response_field :hello, "The greeted thing"
3435
@@ -65,9 +66,10 @@ Feature: Generate HTML documentation from test examples
6566
When I open the index
6667
And I navigate to "Greeting your favorite gem"
6768
Then I should see the following parameters:
68-
| name | description |
69-
| target | The thing you want to greet |
70-
| scope[scoped] | This is a scoped variable |
69+
| name | description |
70+
| target | The thing you want to greet |
71+
| scope[scoped] | This is a scoped variable |
72+
| scope[further][sub] | This is scoped |
7173

7274
Scenario: Examle HTML documentation should include the response fields
7375
When I open the index

lib/rspec_api_documentation/views/markup_example.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,21 @@ def filename
2828
"#{basename}.#{extension}"
2929
end
3030

31+
def parameters
32+
super.each do |parameter|
33+
if parameter.has_key?(:scope)
34+
scope = Array(parameter[:scope]).each_with_index.map do |scope, index|
35+
if index == 0
36+
scope
37+
else
38+
"[#{scope}]"
39+
end
40+
end.join
41+
parameter[:scope] = scope
42+
end
43+
end
44+
end
45+
3146
def requests
3247
super.map do |hash|
3348
hash[:request_headers_text] = format_hash(hash[:request_headers])

0 commit comments

Comments
 (0)