Skip to content

Commit 5a8157a

Browse files
authored
Merge pull request #412 from E1337Kat/slate_fix
Add clearer slate support in README. Reorganize slate_example.mustach…
2 parents 5f0b3f7 + 03d2751 commit 5a8157a

File tree

4 files changed

+39
-50
lines changed

4 files changed

+39
-50
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ end
276276
* **markdown**: Generates an index file and example files in Markdown.
277277
* **api_blueprint**: Generates an index file and example files in [APIBlueprint](https://apiblueprint.org).
278278
* **append_json**: Lets you selectively run specs without destroying current documentation. See section below.
279+
* **slate**: Builds markdown files that can be used with [Slate](https://github.com/lord/slate), a beautiful static documentation builder.
279280
* **open_api**: Generates [OpenAPI Specification](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md) (OAS) (Current supported version is 2.0). Can be used for [Swagger-UI](https://swagger.io/tools/swagger-ui/)
280281

281282
### append_json

features/slate_documentation.feature

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -153,30 +153,36 @@ Feature: Generate Slate documentation from test examples
153153
154154
### Request
155155
156+
```shell
157+
curl -g "http://localhost:3000/orders" -X GET \
158+
-H "Host: example.org" \
159+
-H "Cookie: "
160+
```
161+
156162
#### Endpoint
157163
164+
`GET /orders`
165+
158166
```plaintext
159167
GET /orders
160168
Host: example.org
161169
```
162170
163-
`GET /orders`
164-
165171
#### Parameters
166172
167173
168-
None known.
169174
175+
None known.
170176
171177
### Response
172178
179+
173180
```plaintext
174181
Content-Type: application/json
175182
Content-Length: 137
176183
200 OK
177184
```
178185
179-
180186
```json
181187
{
182188
"page": 1,
@@ -196,60 +202,54 @@ Feature: Generate Slate documentation from test examples
196202
```
197203
198204
199-
200205
#### Fields
201206
202207
| Name | Description |
203208
|:-----------|:--------------------|
204209
| page | Current page |
205-
206-
207-
```shell
208-
curl -g "http://localhost:3000/orders" -X GET \
209-
-H "Host: example.org" \
210-
-H "Cookie: "
211210
"""
212211

213212
Scenario: Example 'Creating an order' docs should look like we expect
214213
Then the file "doc/api/index.html.md" should contain:
215214
"""
216-
# Orders
217-
218-
An Order represents an amount of money to be paid
219-
220215
## Creating an order
221216
222217
223218
### Request
219+
220+
```shell
221+
curl "http://localhost:3000/orders" -d 'name=Order+3&amount=33.0' -X POST \
222+
-H "Host: example.org" \
223+
-H "Content-Type: application/x-www-form-urlencoded" \
224+
-H "Cookie: "
225+
```
224226
225227
#### Endpoint
226228
229+
`POST /orders`
230+
227231
```plaintext
228232
POST /orders
229233
Host: example.org
230234
Content-Type: application/x-www-form-urlencoded
231235
```
232236
233-
`POST /orders`
234-
235237
#### Parameters
236238
237239
238240
```json
239241
name=Order+3&amount=33.0
240242
```
241243
242-
243244
| Name | Description |
244245
|:-----|:------------|
245246
| name *required* | Name of order |
246247
| amount *required* | Amount paid |
247248
| description | Some comments on the order |
248249
249-
250-
251250
### Response
252251
252+
253253
```plaintext
254254
Content-Type: text/html;charset=utf-8
255255
Content-Length: 0
@@ -258,13 +258,6 @@ Feature: Generate Slate documentation from test examples
258258
259259
260260
261-
262-
```shell
263-
curl "http://localhost:3000/orders" -d 'name=Order+3&amount=33.0' -X POST \
264-
-H "Host: example.org" \
265-
-H "Content-Type: application/x-www-form-urlencoded" \
266-
-H "Cookie: "
267-
```
268261
"""
269262

270263
Scenario: Example 'Deleting an order' docs should be created

templates/rspec_api_documentation/slate_example.mustache

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,79 +6,75 @@
66

77
### Request
88

9+
{{# requests }}
10+
{{# curl }}
11+
```shell
12+
{{{ curl }}}
13+
```
14+
{{/ curl }}
15+
{{/ requests }}
16+
917
#### Endpoint
1018

11-
{{# requests}}
19+
`{{ http_method }} {{ route }}`
20+
21+
{{# requests }}
1222
```plaintext
1323
{{ request_method }} {{ request_path }}
1424
{{ request_headers_text }}
1525
```
16-
{{/ requests}}
17-
18-
`{{ http_method }} {{ route }}`
26+
{{/ requests }}
1927

2028
#### Parameters
2129

22-
{{# requests}}
30+
{{# requests }}
2331
{{# request_query_parameters_text }}
24-
2532
```json
2633
{{ request_query_parameters_text }}
2734
```
2835
{{/ request_query_parameters_text }}
29-
{{# request_body }}
3036

37+
{{# request_body }}
3138
```json
3239
{{{ request_body }}}
3340
```
3441
{{/ request_body }}
3542

3643
{{# has_parameters? }}
37-
3844
| Name | Description |
3945
|:-----|:------------|
4046
{{# parameters }}
4147
| {{#scope}}{{scope}}[{{/scope}}{{ name }}{{#scope}}]{{/scope}} {{# required }}*required*{{/ required }} | {{{ description }}} |
4248
{{/ parameters }}
43-
4449
{{/ has_parameters? }}
4550
{{^ has_parameters? }}
4651
None known.
4752
{{/ has_parameters? }}
4853

49-
{{# response_status}}
50-
5154
### Response
5255

56+
57+
{{# response_status }}
5358
```plaintext
5459
{{ response_headers_text }}
5560
{{ response_status }} {{ response_status_text}}
5661
```
5762

5863
{{# response_body}}
59-
6064
```json
6165
{{{ response_body }}}
6266
```
6367
{{/response_body}}
64-
6568
{{/ response_status}}
6669

67-
{{# has_response_fields? }}
6870

71+
{{# has_response_fields? }}
6972
#### Fields
7073

7174
| Name | Description |
7275
|:-----------|:--------------------|
7376
{{# response_fields }}
7477
| {{#scope}}{{scope}}[{{/scope}}{{ name }}{{#scope}}]{{/scope}} | {{{ description }}} |
7578
{{/ response_fields }}
76-
7779
{{/ has_response_fields? }}
78-
79-
{{# curl }}
80-
```shell
81-
{{{ curl }}}
82-
```
83-
{{/ curl }}
84-
{{/ requests}}
80+
{{/ requests }}

templates/rspec_api_documentation/slate_index.mustache

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
title: {{ api_name }}
33
language_tabs:
4-
- json: JSON
54
- shell: cURL
65
---
76

0 commit comments

Comments
 (0)