diff --git a/README.md b/README.md index f6b00f65..6151e8ec 100644 --- a/README.md +++ b/README.md @@ -276,6 +276,7 @@ end * **markdown**: Generates an index file and example files in Markdown. * **api_blueprint**: Generates an index file and example files in [APIBlueprint](https://apiblueprint.org). * **append_json**: Lets you selectively run specs without destroying current documentation. See section below. +* **slate**: Builds markdown files that can be used with [Slate](https://github.com/lord/slate), a beautiful static documentation builder. * **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/) ### append_json diff --git a/features/slate_documentation.feature b/features/slate_documentation.feature index e06bab9e..0dcd026c 100644 --- a/features/slate_documentation.feature +++ b/features/slate_documentation.feature @@ -153,30 +153,36 @@ Feature: Generate Slate documentation from test examples ### Request + ```shell + curl -g "http://localhost:3000/orders" -X GET \ + -H "Host: example.org" \ + -H "Cookie: " + ``` + #### Endpoint + `GET /orders` + ```plaintext GET /orders Host: example.org ``` - `GET /orders` - #### Parameters - None known. + None known. ### Response + ```plaintext Content-Type: application/json Content-Length: 137 200 OK ``` - ```json { "page": 1, @@ -196,42 +202,38 @@ Feature: Generate Slate documentation from test examples ``` - #### Fields | Name | Description | |:-----------|:--------------------| | page | Current page | - - - ```shell - curl -g "http://localhost:3000/orders" -X GET \ - -H "Host: example.org" \ - -H "Cookie: " """ Scenario: Example 'Creating an order' docs should look like we expect Then the file "doc/api/index.html.md" should contain: """ - # Orders - - An Order represents an amount of money to be paid - ## Creating an order ### Request + + ```shell + curl "http://localhost:3000/orders" -d 'name=Order+3&amount=33.0' -X POST \ + -H "Host: example.org" \ + -H "Content-Type: application/x-www-form-urlencoded" \ + -H "Cookie: " + ``` #### Endpoint + `POST /orders` + ```plaintext POST /orders Host: example.org Content-Type: application/x-www-form-urlencoded ``` - `POST /orders` - #### Parameters @@ -239,17 +241,15 @@ Feature: Generate Slate documentation from test examples name=Order+3&amount=33.0 ``` - | Name | Description | |:-----|:------------| | name *required* | Name of order | | amount *required* | Amount paid | | description | Some comments on the order | - - ### Response + ```plaintext Content-Type: text/html;charset=utf-8 Content-Length: 0 @@ -258,13 +258,6 @@ Feature: Generate Slate documentation from test examples - - ```shell - curl "http://localhost:3000/orders" -d 'name=Order+3&amount=33.0' -X POST \ - -H "Host: example.org" \ - -H "Content-Type: application/x-www-form-urlencoded" \ - -H "Cookie: " - ``` """ Scenario: Example 'Deleting an order' docs should be created diff --git a/templates/rspec_api_documentation/slate_example.mustache b/templates/rspec_api_documentation/slate_example.mustache index 01fafb9f..f07233a4 100644 --- a/templates/rspec_api_documentation/slate_example.mustache +++ b/templates/rspec_api_documentation/slate_example.mustache @@ -6,66 +6,69 @@ ### Request +{{# requests }} +{{# curl }} +```shell +{{{ curl }}} +``` +{{/ curl }} +{{/ requests }} + #### Endpoint -{{# requests}} +`{{ http_method }} {{ route }}` + +{{# requests }} ```plaintext {{ request_method }} {{ request_path }} {{ request_headers_text }} ``` -{{/ requests}} - -`{{ http_method }} {{ route }}` +{{/ requests }} #### Parameters -{{# requests}} +{{# requests }} {{# request_query_parameters_text }} - ```json {{ request_query_parameters_text }} ``` {{/ request_query_parameters_text }} -{{# request_body }} +{{# request_body }} ```json {{{ request_body }}} ``` {{/ request_body }} {{# has_parameters? }} - | Name | Description | |:-----|:------------| {{# parameters }} | {{#scope}}{{scope}}[{{/scope}}{{ name }}{{#scope}}]{{/scope}} {{# required }}*required*{{/ required }} | {{{ description }}} | {{/ parameters }} - {{/ has_parameters? }} {{^ has_parameters? }} None known. {{/ has_parameters? }} -{{# response_status}} - ### Response + +{{# response_status }} ```plaintext {{ response_headers_text }} {{ response_status }} {{ response_status_text}} ``` {{# response_body}} - ```json {{{ response_body }}} ``` {{/response_body}} - {{/ response_status}} -{{# has_response_fields? }} +{{# has_response_fields? }} #### Fields | Name | Description | @@ -73,12 +76,5 @@ None known. {{# response_fields }} | {{#scope}}{{scope}}[{{/scope}}{{ name }}{{#scope}}]{{/scope}} | {{{ description }}} | {{/ response_fields }} - {{/ has_response_fields? }} - -{{# curl }} -```shell -{{{ curl }}} -``` -{{/ curl }} -{{/ requests}} +{{/ requests }} \ No newline at end of file diff --git a/templates/rspec_api_documentation/slate_index.mustache b/templates/rspec_api_documentation/slate_index.mustache index be0e5ae8..1592f604 100644 --- a/templates/rspec_api_documentation/slate_index.mustache +++ b/templates/rspec_api_documentation/slate_index.mustache @@ -1,7 +1,6 @@ --- title: {{ api_name }} language_tabs: - - json: JSON - shell: cURL ---