autodoc 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/autodoc/document.rb +20 -6
- data/lib/autodoc/version.rb +1 -1
- data/spec/dummy/doc/recipes.md +11 -6
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d6bfb36e5c0208cc5d6b9eec52aab2c27494c4d
|
4
|
+
data.tar.gz: 69af7a3f323a6dff4053c133e304606ae379d207
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27ad733e1e05f272b165cbb99617abb74efa465b430bbf819ea6955b0c13c8655774938c576b957e87e098b177052f51dcd8468bd0a064ecce04699c591160f2
|
7
|
+
data.tar.gz: 4c78e9ead939463818b20d20e48885bbb5dd73f4d47f4bf600e7928e4e9841c4f254a3009bce2edc83b039696ead3ea8db658af0d2feba62da277f41d152aa7e
|
data/lib/autodoc/document.rb
CHANGED
@@ -27,12 +27,17 @@ module Autodoc
|
|
27
27
|
example.full_description[%r<(GET|POST|PUT|DELETE) ([^ ]+)>, 2]
|
28
28
|
end
|
29
29
|
|
30
|
-
|
31
|
-
def request_body
|
30
|
+
def response_body
|
32
31
|
"\n" + JSON.parse(response.body).ai(plain: true, indent: -2, index: false)
|
33
32
|
rescue JSON::ParserError
|
34
33
|
end
|
35
34
|
|
35
|
+
def request_body_section
|
36
|
+
if has_request_body?
|
37
|
+
"\n```\n#{request_body}\n```\n"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
36
41
|
def parameters_section
|
37
42
|
if has_validators?
|
38
43
|
"\n### parameters\n#{parameters}\n"
|
@@ -43,6 +48,14 @@ module Autodoc
|
|
43
48
|
validators.map {|validator| Parameter.new(validator) }.join("\n")
|
44
49
|
end
|
45
50
|
|
51
|
+
def request_body
|
52
|
+
request.body.string
|
53
|
+
end
|
54
|
+
|
55
|
+
def has_request_body?
|
56
|
+
request_body.present?
|
57
|
+
end
|
58
|
+
|
46
59
|
def has_validators?
|
47
60
|
!!(defined?(WeakParameters) && validators)
|
48
61
|
end
|
@@ -99,15 +112,16 @@ end
|
|
99
112
|
|
100
113
|
__END__
|
101
114
|
## <%= request.method %> <%= path %>
|
102
|
-
<%= example.
|
103
|
-
|
115
|
+
<%= example.full_description %>.
|
116
|
+
<%= parameters_section %>
|
117
|
+
### request
|
104
118
|
```
|
105
119
|
<%= request.method %> <%= request.path %>
|
106
120
|
```
|
107
|
-
<%=
|
121
|
+
<%= request_body_section %>
|
108
122
|
### response
|
109
123
|
```ruby
|
110
124
|
Status: <%= response.status %><%= headers %>
|
111
|
-
response: <%=
|
125
|
+
response: <%= response_body %>
|
112
126
|
```
|
113
127
|
|
data/lib/autodoc/version.rb
CHANGED
data/spec/dummy/doc/recipes.md
CHANGED
@@ -1,13 +1,18 @@
|
|
1
1
|
## POST /recipes
|
2
|
-
|
2
|
+
Recipes POST /recipes with valid condition creates a new recipe.
|
3
3
|
|
4
|
+
### parameters
|
5
|
+
* `name` string (required, except: `["alice", "bob"]`)
|
6
|
+
* `type` integer (only: `"1".."3"`)
|
7
|
+
|
8
|
+
### request
|
4
9
|
```
|
5
10
|
POST /recipes
|
6
11
|
```
|
7
12
|
|
8
|
-
|
9
|
-
|
10
|
-
|
13
|
+
```
|
14
|
+
name=name&type=1
|
15
|
+
```
|
11
16
|
|
12
17
|
### response
|
13
18
|
```ruby
|
@@ -15,10 +20,10 @@ Status: 201
|
|
15
20
|
location: http://www.example.com/recipes/1
|
16
21
|
response:
|
17
22
|
{
|
18
|
-
"created_at" => "2013-
|
23
|
+
"created_at" => "2013-07-08T06:11:46Z",
|
19
24
|
"id" => 1,
|
20
25
|
"name" => "name",
|
21
|
-
"updated_at" => "2013-
|
26
|
+
"updated_at" => "2013-07-08T06:11:46Z"
|
22
27
|
}
|
23
28
|
```
|
24
29
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: autodoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|
@@ -170,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
170
|
version: '0'
|
171
171
|
requirements: []
|
172
172
|
rubyforge_project:
|
173
|
-
rubygems_version: 2.0.
|
173
|
+
rubygems_version: 2.0.3
|
174
174
|
signing_key:
|
175
175
|
specification_version: 4
|
176
176
|
summary: Auto-generate API documents from your request-specs.
|