autodoc 0.0.6 → 0.0.7
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 +39 -3
- data/lib/autodoc/version.rb +1 -1
- data/spec/dummy/app/controllers/recipes_controller.rb +2 -2
- data/spec/dummy/doc/recipes.md +4 -4
- 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: 7b959243c809886f4e1933c89600e19549fb7bdd
|
4
|
+
data.tar.gz: 8c6413d2c36bf8e717601e4472d160ef09df28b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e37eda35bed6135a209aa11eb6858173509908bbf4a5c7f3e9ca3a5d79f84d6570739189fc1061c004af3b394d48a8a7288c6ef5c7ea2095b2457152b4bb628
|
7
|
+
data.tar.gz: 03dbc7218c2cc2bc93d30d67c6abc0d10d45b4c36d4c6ae303516971f782d7bc42b92720509e75f4925e7086dd38f4f8d6f2c25e55be24e7a0043f42583a07c4
|
data/lib/autodoc/document.rb
CHANGED
@@ -40,9 +40,7 @@ module Autodoc
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def parameters
|
43
|
-
validators.map
|
44
|
-
"* `#{validator.key}` #{validator.type}#{' (required)' if validator.required?}"
|
45
|
-
end.join("\n")
|
43
|
+
validators.map {|validator| Parameter.new(validator) }.join("\n")
|
46
44
|
end
|
47
45
|
|
48
46
|
def has_validators?
|
@@ -58,6 +56,44 @@ module Autodoc
|
|
58
56
|
"\n#{header}: #{response.headers[header]}" if response.headers[header]
|
59
57
|
end.compact.join
|
60
58
|
end
|
59
|
+
|
60
|
+
class Parameter
|
61
|
+
attr_reader :validator
|
62
|
+
|
63
|
+
def initialize(validator)
|
64
|
+
@validator = validator
|
65
|
+
end
|
66
|
+
|
67
|
+
def to_s
|
68
|
+
"#{body}#{payload}"
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
def body
|
74
|
+
"* `#{validator.key}` #{validator.type}"
|
75
|
+
end
|
76
|
+
|
77
|
+
def payload
|
78
|
+
" (#{assets.join(', ')})" if assets.any?
|
79
|
+
end
|
80
|
+
|
81
|
+
def assets
|
82
|
+
@assets ||= [required, only, except].compact
|
83
|
+
end
|
84
|
+
|
85
|
+
def required
|
86
|
+
"required" if validator.required?
|
87
|
+
end
|
88
|
+
|
89
|
+
def only
|
90
|
+
"only: `#{validator.options[:only].inspect}`" if validator.options[:only]
|
91
|
+
end
|
92
|
+
|
93
|
+
def except
|
94
|
+
"except: `#{validator.options[:except].inspect}`" if validator.options[:except]
|
95
|
+
end
|
96
|
+
end
|
61
97
|
end
|
62
98
|
end
|
63
99
|
|
data/lib/autodoc/version.rb
CHANGED
data/spec/dummy/doc/recipes.md
CHANGED
@@ -6,8 +6,8 @@ POST /recipes
|
|
6
6
|
```
|
7
7
|
|
8
8
|
### parameters
|
9
|
-
* `name` string (required)
|
10
|
-
* `type` integer
|
9
|
+
* `name` string (required, except: `["alice", "bob"]`)
|
10
|
+
* `type` integer (only: `"1".."3"`)
|
11
11
|
|
12
12
|
### response
|
13
13
|
```ruby
|
@@ -15,10 +15,10 @@ Status: 201
|
|
15
15
|
location: http://www.example.com/recipes/1
|
16
16
|
response:
|
17
17
|
{
|
18
|
-
"created_at" => "2013-06-
|
18
|
+
"created_at" => "2013-06-18T06:33:40Z",
|
19
19
|
"id" => 1,
|
20
20
|
"name" => "name",
|
21
|
-
"updated_at" => "2013-06-
|
21
|
+
"updated_at" => "2013-06-18T06:33:40Z"
|
22
22
|
}
|
23
23
|
```
|
24
24
|
|
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.7
|
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-06-
|
11
|
+
date: 2013-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|