autodoc 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +21 -3
- data/lib/autodoc/document.rb +5 -0
- data/lib/autodoc/templates/document.md.erb +1 -1
- data/lib/autodoc/version.rb +1 -1
- data/spec/dummy/doc/entries.md +19 -0
- data/spec/dummy/doc/recipes.md +4 -4
- data/spec/dummy/doc/toc.md +2 -0
- data/spec/requests/entries_spec.rb +39 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 818671b2a03b5e5604d72453279a0f75e54055be
|
4
|
+
data.tar.gz: 1fd0c526cb6eafd0cb9da26016629157165d78fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b16942b38765ea37ba19bcf5898c0ef82c9d79c73b1620f88b89f6a428888c9717c06a930df535b416a36af506977888ab3446ed4666669b6bfc3fc318ca9e00
|
7
|
+
data.tar.gz: d8ec61fb2a070a0e5b5405b3c7628fb5ab17ffea611609272db228b5e4c33e79c8001932feb1f7bfd37ca2be8af899643aebdc8217a5fbae21477fc714799a0c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Autodoc
|
2
|
-
|
2
|
+
Generate documentation from your rack application & request-spec.
|
3
3
|
|
4
4
|
## Installation
|
5
5
|
```ruby
|
@@ -7,7 +7,7 @@ gem "autodoc", group: :test
|
|
7
7
|
```
|
8
8
|
|
9
9
|
## Usage
|
10
|
-
Run rspec with AUTODOC=1 to generate documents for
|
10
|
+
Run rspec with AUTODOC=1 to generate documents for your request-specs tagged with `:autodoc`.
|
11
11
|
example: [doc/recipes.md](https://github.com/r7kamura/autodoc/blob/master/spec/dummy/doc/recipes.md), [doc/toc.md](https://github.com/r7kamura/autodoc/blob/master/spec/dummy/doc/toc.md)
|
12
12
|
|
13
13
|
```sh
|
@@ -15,12 +15,30 @@ example: [doc/recipes.md](https://github.com/r7kamura/autodoc/blob/master/spec/d
|
|
15
15
|
AUTODOC=1 rspec
|
16
16
|
```
|
17
17
|
|
18
|
+
### Example for any Rack application with rack-test
|
19
|
+
```ruby
|
20
|
+
# spec/requests/entries_spec.rb
|
21
|
+
describe "Entries" do
|
22
|
+
include Rack::Test::Methods
|
23
|
+
|
24
|
+
let(:app) do
|
25
|
+
MyRackApplication
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "GET /entries", autodoc: true do
|
29
|
+
get "/entries"
|
30
|
+
last_response.status.should == 200
|
31
|
+
end
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
35
|
+
### Example for Rails application with rspec-rails
|
18
36
|
```ruby
|
19
37
|
# spec/requests/recipes_spec.rb
|
20
38
|
describe "Recipes" do
|
21
39
|
describe "POST /recipes", autodoc: true do
|
22
40
|
it "creates a new recipe" do
|
23
|
-
post "/recipes
|
41
|
+
post "/recipes", name: "alice", type: 1
|
24
42
|
response.status.should == 201
|
25
43
|
end
|
26
44
|
end
|
data/lib/autodoc/document.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "action_dispatch/http/request"
|
2
|
+
require "uri"
|
2
3
|
require "erb"
|
3
4
|
require "pathname"
|
4
5
|
|
@@ -57,6 +58,10 @@ module Autodoc
|
|
57
58
|
request.method
|
58
59
|
end
|
59
60
|
|
61
|
+
def request_query
|
62
|
+
"?#{URI.unescape(request.query_string)}" unless request.query_string.empty?
|
63
|
+
end
|
64
|
+
|
60
65
|
def request_body
|
61
66
|
request.body.string
|
62
67
|
end
|
data/lib/autodoc/version.rb
CHANGED
data/spec/dummy/doc/recipes.md
CHANGED
@@ -14,8 +14,8 @@ response:
|
|
14
14
|
"id": 1,
|
15
15
|
"name": "test",
|
16
16
|
"type": 2,
|
17
|
-
"created_at": "2013-
|
18
|
-
"updated_at": "2013-
|
17
|
+
"created_at": "2013-12-10T02:07:44.282Z",
|
18
|
+
"updated_at": "2013-12-10T02:07:44.282Z"
|
19
19
|
}
|
20
20
|
```
|
21
21
|
|
@@ -44,7 +44,7 @@ response:
|
|
44
44
|
"id": 1,
|
45
45
|
"name": "name",
|
46
46
|
"type": 1,
|
47
|
-
"created_at": "2013-
|
48
|
-
"updated_at": "2013-
|
47
|
+
"created_at": "2013-12-10T02:07:44.355Z",
|
48
|
+
"updated_at": "2013-12-10T02:07:44.355Z"
|
49
49
|
}
|
50
50
|
```
|
data/spec/dummy/doc/toc.md
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Entries" do
|
4
|
+
include Rack::Test::Methods
|
5
|
+
|
6
|
+
let(:env) do
|
7
|
+
{ "HTTP_ACCEPT" => "application/json" }
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:params) do
|
11
|
+
{}
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:app) do
|
15
|
+
lambda do |env|
|
16
|
+
[
|
17
|
+
200,
|
18
|
+
{},
|
19
|
+
[
|
20
|
+
[
|
21
|
+
{
|
22
|
+
title: "Test Title",
|
23
|
+
body: "Lorem Ipsum",
|
24
|
+
},
|
25
|
+
].to_json,
|
26
|
+
],
|
27
|
+
]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "GET /entries" do
|
32
|
+
context "with Rack::Test", :autodoc do
|
33
|
+
it "returns entries" do
|
34
|
+
get "/entries", params, env
|
35
|
+
last_response.status.should == 200
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
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.2.
|
4
|
+
version: 0.2.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-12-
|
11
|
+
date: 2013-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -144,6 +144,7 @@ files:
|
|
144
144
|
- spec/dummy/config/routes.rb
|
145
145
|
- spec/dummy/db/migrate/20130607075126_create_recipes.rb
|
146
146
|
- spec/dummy/db/schema.rb
|
147
|
+
- spec/dummy/doc/entries.md
|
147
148
|
- spec/dummy/doc/recipes.md
|
148
149
|
- spec/dummy/doc/toc.md
|
149
150
|
- spec/dummy/lib/assets/.gitkeep
|
@@ -153,6 +154,7 @@ files:
|
|
153
154
|
- spec/dummy/public/500.html
|
154
155
|
- spec/dummy/public/favicon.ico
|
155
156
|
- spec/dummy/script/rails
|
157
|
+
- spec/requests/entries_spec.rb
|
156
158
|
- spec/requests/recipes_spec.rb
|
157
159
|
- spec/spec_helper.rb
|
158
160
|
homepage: https://github.com/r7kamura/autodoc
|
@@ -208,6 +210,7 @@ test_files:
|
|
208
210
|
- spec/dummy/config/routes.rb
|
209
211
|
- spec/dummy/db/migrate/20130607075126_create_recipes.rb
|
210
212
|
- spec/dummy/db/schema.rb
|
213
|
+
- spec/dummy/doc/entries.md
|
211
214
|
- spec/dummy/doc/recipes.md
|
212
215
|
- spec/dummy/doc/toc.md
|
213
216
|
- spec/dummy/lib/assets/.gitkeep
|
@@ -217,5 +220,6 @@ test_files:
|
|
217
220
|
- spec/dummy/public/500.html
|
218
221
|
- spec/dummy/public/favicon.ico
|
219
222
|
- spec/dummy/script/rails
|
223
|
+
- spec/requests/entries_spec.rb
|
220
224
|
- spec/requests/recipes_spec.rb
|
221
225
|
- spec/spec_helper.rb
|