apiculture 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/gemfiles/Gemfile.rack-1.x +1 -1
- data/gemfiles/Gemfile.rack-2.x +1 -1
- data/lib/apiculture/method_documentation.rb +10 -5
- data/lib/apiculture/version.rb +1 -1
- data/spec/apiculture/app_documentation_spec.rb +10 -3
- data/spec/apiculture/method_documentation_spec.rb +5 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bf044e0978c4650b72aa2b337fe9cb000ecd546
|
4
|
+
data.tar.gz: 010b7cfb597e96aba2554b32e00b9fd3773e5169
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b2db79c161620c9f1d8cd22cfb252d7e0ac6013c42de0e87368c819334df7c5b9f8b6a666e0ea380e847d8d0c52dca98afdf94db97e25b3670880f5dc0eff7d
|
7
|
+
data.tar.gz: 2b89340ef4473feb21e7c5c49018f5b0bb68748dd8b0d536c5bc0090253bc1d1952db3900839dc40e412a19ba02051cd8889c4a5b0d5afa3fc03a86eeec5816e
|
data/gemfiles/Gemfile.rack-1.x
CHANGED
data/gemfiles/Gemfile.rack-2.x
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'builder'
|
2
|
+
require 'rdiscount'
|
3
|
+
|
2
4
|
# Generates Markdown/HTML documentation about a single API action.
|
3
5
|
#
|
4
6
|
# Formats route parameters and request/QS parameters as a neat HTML
|
@@ -26,12 +28,15 @@ class Apiculture::MethodDocumentation
|
|
26
28
|
|
27
29
|
# Compose an HTML string by converting the result of +to_markdown+
|
28
30
|
def to_html_fragment
|
29
|
-
|
30
|
-
RDiscount.new(to_markdown).to_html
|
31
|
+
markdown_string_to_html(to_markdown)
|
31
32
|
end
|
32
33
|
|
33
34
|
private
|
34
35
|
|
36
|
+
def markdown_string_to_html(str)
|
37
|
+
RDiscount.new(str.to_s).to_html
|
38
|
+
end
|
39
|
+
|
35
40
|
class StringBuf #:nodoc:
|
36
41
|
def initialize; @blocks = []; end
|
37
42
|
def <<(block); @blocks << block.to_s; self; end
|
@@ -59,7 +64,7 @@ class Apiculture::MethodDocumentation
|
|
59
64
|
@definition.route_parameters.each do | param |
|
60
65
|
html.tr do
|
61
66
|
html.td { html.tt(':%s' % param.name) }
|
62
|
-
html.td(param.description)
|
67
|
+
html.td { html << markdown_string_to_html(param.description) }
|
63
68
|
end
|
64
69
|
end
|
65
70
|
end
|
@@ -98,7 +103,7 @@ class Apiculture::MethodDocumentation
|
|
98
103
|
@definition.responses.each do | resp |
|
99
104
|
html.tr do
|
100
105
|
html.td { html.b(resp.http_status_code) }
|
101
|
-
html.td resp.description
|
106
|
+
html.td { html << markdown_string_to_html(resp.description) }
|
102
107
|
html.td { html.pre { html.code(body_example(resp)) }}
|
103
108
|
end
|
104
109
|
end
|
@@ -139,7 +144,7 @@ class Apiculture::MethodDocumentation
|
|
139
144
|
html.td { html.tt(param.name.to_s) }
|
140
145
|
html.td(param.required ? 'Yes' : 'No')
|
141
146
|
html.td(param.matchable.inspect)
|
142
|
-
html.td(param.description
|
147
|
+
html.td { html << markdown_string_to_html(param.description) }
|
143
148
|
end
|
144
149
|
end
|
145
150
|
end
|
data/lib/apiculture/version.rb
CHANGED
@@ -10,9 +10,16 @@ describe "Apiculture.api_documentation" do
|
|
10
10
|
documentation_build_time!
|
11
11
|
|
12
12
|
desc 'Order a pancake'
|
13
|
-
required_param :diameter, "Diameter of the pancake", Integer
|
13
|
+
required_param :diameter, "Diameter of the pancake. The pancake will be **bold**", Integer
|
14
14
|
param :topping, 'Type of topping', String
|
15
|
-
|
15
|
+
pancake_response_info = <<~EOS
|
16
|
+
When the pancake has been baked succesfully
|
17
|
+
The pancake will have the following properties:
|
18
|
+
|
19
|
+
* It is going to be round
|
20
|
+
* It is going to be delicious
|
21
|
+
EOS
|
22
|
+
responds_with 200, pancake_response_info, {id: 'abdef..c21'}
|
16
23
|
api_method :post, '/pancakes' do
|
17
24
|
end
|
18
25
|
|
@@ -58,7 +65,7 @@ describe "Apiculture.api_documentation" do
|
|
58
65
|
|
59
66
|
expect(generated_html).to include('<body')
|
60
67
|
expect(generated_html).to include('Pancake ID to check status on')
|
61
|
-
expect(generated_html).to include('When the pancake
|
68
|
+
expect(generated_html).to include('When the pancake has been baked succesfully')
|
62
69
|
expect(generated_html).to include('"id": "abdef..c21"')
|
63
70
|
end
|
64
71
|
|
@@ -7,7 +7,7 @@ describe Apiculture::MethodDocumentation do
|
|
7
7
|
|
8
8
|
definition.description = "This action bakes pancakes"
|
9
9
|
definition.parameters << Apiculture::Parameter.new(:name, 'Pancake name', true, String, :to_s)
|
10
|
-
definition.parameters << Apiculture::Parameter.new(:thickness, 'Pancake
|
10
|
+
definition.parameters << Apiculture::Parameter.new(:thickness, 'Pancake **thick**ness', false, Float, :to_f)
|
11
11
|
definition.parameters << Apiculture::Parameter.new(:diameter, 'Pancake diameter', false, Integer, :to_i)
|
12
12
|
|
13
13
|
definition.route_parameters << Apiculture::RouteParameter.new(:pan_id, 'ID of the pancake frying pan')
|
@@ -28,9 +28,9 @@ describe Apiculture::MethodDocumentation do
|
|
28
28
|
expect(generated_html).to include('<h3>URL parameters</h3>')
|
29
29
|
expect(generated_html).to include('ID of the pancake frying pan')
|
30
30
|
expect(generated_html).to include('<h3>Request parameters</h3>')
|
31
|
-
expect(generated_html).to include('<
|
32
|
-
expect(generated_html).to include('<
|
33
|
-
expect(generated_html).to include('<
|
31
|
+
expect(generated_html).to include('<p>Pancake name</p>')
|
32
|
+
expect(generated_html).to include('<p>Pancake has been baked</p>')
|
33
|
+
expect(generated_html).to include('<p>Frying pan too cold</p>')
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'generates HTML from an ActionDefinition without route params' do
|
@@ -38,7 +38,7 @@ describe Apiculture::MethodDocumentation do
|
|
38
38
|
|
39
39
|
definition.description = "This action bakes pancakes"
|
40
40
|
definition.parameters << Apiculture::Parameter.new(:name, 'Pancake name', true, String, :to_s)
|
41
|
-
definition.parameters << Apiculture::Parameter.new(:thickness, 'Pancake
|
41
|
+
definition.parameters << Apiculture::Parameter.new(:thickness, 'Pancake **thick**ness', false, Float, :to_f)
|
42
42
|
definition.parameters << Apiculture::Parameter.new(:diameter, 'Pancake diameter', false, Integer, :to_i)
|
43
43
|
|
44
44
|
definition.http_verb = 'get'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apiculture
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julik Tarkhanov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-02-
|
12
|
+
date: 2019-02-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mustermann
|