api_doc_generation 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +34 -0
- data/lib/api_doc_generation/version.rb +1 -1
- data/lib/api_doc_generation/view_helper.rb +1 -1
- data/templates/doc_detailed.html.erb +32 -23
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: efc63e80bddcc349ab44b58451186d2a8cfbad04
|
4
|
+
data.tar.gz: e20a6e3d6621ea10514d813512ef744225556a1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21741fec7a85800ac87c17968e6800fe12a89b1d01e5aefb70bdd97173189006fb751cd6e6ad110c28e0da984c0f2dbfeecb4143457eccb26452a3a024f7777f
|
7
|
+
data.tar.gz: 41d826effb4a3f52517c2d5193e76e6bcc36a7b59bb8ac9f8cffc84c365f988291631ffaa7e11d513adda0e31c7aeeadb8740b52e178c85994c8a8df0d36e5e6
|
data/README.md
CHANGED
@@ -20,6 +20,40 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
`rake doc:api [CODES_PATH=app/controllers/api]`
|
22
22
|
|
23
|
+
__代码注释格式:__
|
24
|
+
|
25
|
+
```
|
26
|
+
class Api::UsersController < class Api::BaseController
|
27
|
+
# 取得所有用户
|
28
|
+
#
|
29
|
+
# Params:
|
30
|
+
# page: [Integer] 页数
|
31
|
+
# perpage: [Integer] 每页数量
|
32
|
+
# Return:
|
33
|
+
# count: [Integer] 数据总条数
|
34
|
+
# items: [Array] 当前页数据的数组
|
35
|
+
def list
|
36
|
+
# ...
|
37
|
+
end
|
38
|
+
|
39
|
+
# (api说明)取得一个用户的信息
|
40
|
+
#
|
41
|
+
# Params:
|
42
|
+
# user_id: [String] 用户的id
|
43
|
+
# Return:
|
44
|
+
# name: [String] xxx
|
45
|
+
# Error:
|
46
|
+
# info: [String] 自己定义的错误信息
|
47
|
+
# other: [String] 如果不设置的,将生成默认的
|
48
|
+
def show
|
49
|
+
# ...
|
50
|
+
end
|
51
|
+
end
|
52
|
+
```
|
53
|
+
|
54
|
+
上面已经给出了api说明,参数,返回,错误信息,而api地址和请求方法将会自动从Rails中查找出来
|
55
|
+
|
56
|
+
|
23
57
|
## Contributing
|
24
58
|
|
25
59
|
1. Fork it
|
@@ -108,16 +108,16 @@
|
|
108
108
|
<div class='action action-<%= i % 2 == 0 ? 'even' : 'odd' %>'
|
109
109
|
id='<%= action_identifer(controller[:klass], action[:name]) %>'>
|
110
110
|
|
111
|
-
<
|
112
|
-
<p class='about'><%= action[:desc] %></p>
|
111
|
+
<h4>功能说明</h4>
|
112
|
+
<p class='about text-info'><%= action[:desc] %></p>
|
113
113
|
|
114
|
-
<
|
115
|
-
<p class='about'><%= action[:path] %></p>
|
114
|
+
<h4>请求地址</h4>
|
115
|
+
<p class='about text-info'><%= action[:path] %></p>
|
116
116
|
|
117
|
-
<
|
118
|
-
<p class='about'><%= action[:method] %></p>
|
117
|
+
<h4>请求方法</h4>
|
118
|
+
<p class='about text-info'><%= action[:method] %></p>
|
119
119
|
|
120
|
-
<
|
120
|
+
<h4>参数说明</h4>
|
121
121
|
<table class='table table-bordered table-striped'>
|
122
122
|
<thead>
|
123
123
|
<th>参数名</th>
|
@@ -149,7 +149,8 @@
|
|
149
149
|
</tbody>
|
150
150
|
</table>
|
151
151
|
|
152
|
-
<
|
152
|
+
<h4>正常返回信息</h4>
|
153
|
+
<p class='about text-info'>正常完成时response.status 为 200.</p>
|
153
154
|
<table class='table table-bordered table-striped'>
|
154
155
|
<thead>
|
155
156
|
<th>参数名</th>
|
@@ -159,7 +160,7 @@
|
|
159
160
|
|
160
161
|
<tbody>
|
161
162
|
<% (action['Return'] || []).each do |param| %>
|
162
|
-
<%
|
163
|
+
<% format_response_param(param) %>
|
163
164
|
|
164
165
|
<tr>
|
165
166
|
<% [:name, :type, :val].each do |key| %>
|
@@ -170,18 +171,27 @@
|
|
170
171
|
</tbody>
|
171
172
|
</table>
|
172
173
|
|
173
|
-
<
|
174
|
-
<p class='about'>
|
175
|
-
|
174
|
+
<h4>出错误时信息</h4>
|
175
|
+
<p class='about text-info'>出错时response.status 为 400.</p>
|
176
|
+
<table class='table table-bordered table-striped'>
|
177
|
+
<thead>
|
178
|
+
<th>参数名</th>
|
179
|
+
<th>参数类型</th>
|
180
|
+
<th>描述</th>
|
181
|
+
</thead>
|
176
182
|
|
177
|
-
<
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
<th>描述</th>
|
182
|
-
</thead>
|
183
|
+
<tbody>
|
184
|
+
<% if action['Error'] %>
|
185
|
+
<% action['Error'].each do |param| %>
|
186
|
+
<% format_response_param(param) %>
|
183
187
|
|
184
|
-
|
188
|
+
<tr>
|
189
|
+
<% [:name, :type, :val].each do |key| %>
|
190
|
+
<td><%= param[key] %></td>
|
191
|
+
<% end %>
|
192
|
+
</tr>
|
193
|
+
<% end %>
|
194
|
+
<% else %>
|
185
195
|
<tr>
|
186
196
|
<td>error</td>
|
187
197
|
<td>String</td>
|
@@ -193,10 +203,9 @@
|
|
193
203
|
<td>String</td>
|
194
204
|
<td>错误具体描述</td>
|
195
205
|
</tr>
|
196
|
-
|
197
|
-
</
|
198
|
-
|
199
|
-
</p>
|
206
|
+
<% end %>
|
207
|
+
</tbody>
|
208
|
+
</table>
|
200
209
|
|
201
210
|
<br /><hr />
|
202
211
|
</div>
|