From f808b514663527b988cb0c11535e4af670e2e808 Mon Sep 17 00:00:00 2001 From: Ian Ker-Seymer Date: Fri, 19 Feb 2016 16:19:43 -0500 Subject: [PATCH] Use tables to represent markdown parameters --- features/markdown_documentation.feature | 13 +++++-------- .../views/markdown_example.rb | 6 ++++++ .../markdown_example.mustache | 7 ++++--- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/features/markdown_documentation.feature b/features/markdown_documentation.feature index 268b1234..c5e87681 100644 --- a/features/markdown_documentation.feature +++ b/features/markdown_documentation.feature @@ -226,14 +226,11 @@ Feature: Generate Markdown documentation from test examples ### Parameters - Name : name *- required -* - Description : Name of order - - Name : amount *- required -* - Description : Amount paid - - Name : description - Description : Some comments on the order + | Name | Description | Required | Scope | + |------|-------------|----------|-------| + | name | Name of order | true | | + | amount | Amount paid | true | | + | description | Some comments on the order | false | | ### Request diff --git a/lib/rspec_api_documentation/views/markdown_example.rb b/lib/rspec_api_documentation/views/markdown_example.rb index 86de45e8..06c556df 100644 --- a/lib/rspec_api_documentation/views/markdown_example.rb +++ b/lib/rspec_api_documentation/views/markdown_example.rb @@ -8,6 +8,12 @@ def initialize(example, configuration) self.template_name = "rspec_api_documentation/markdown_example" end + def parameters + super.each do |parameter| + parameter[:required] = parameter[:required] ? 'true' : 'false' + end + end + def extension EXTENSION end diff --git a/templates/rspec_api_documentation/markdown_example.mustache b/templates/rspec_api_documentation/markdown_example.mustache index 1183f707..dd67b56c 100644 --- a/templates/rspec_api_documentation/markdown_example.mustache +++ b/templates/rspec_api_documentation/markdown_example.mustache @@ -10,10 +10,11 @@ {{# has_parameters? }} ### Parameters -{{# parameters }} -Name : {{ name }}{{# required }} *- required -*{{/ required }} -Description : {{ description }} +| Name | Description | Required | Scope | +|------|-------------|----------|-------| +{{# parameters }} +| {{ name }} | {{ description }} | {{ required }} | {{ scope }} | {{/ parameters }} {{/ has_parameters? }}