autodoc 0.2.5 → 0.2.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8b183416b270d62f730b447ecf874adbe4a98a3c
4
- data.tar.gz: f97bce1b7f34b7cd873027f161c8dbe03fb881fa
3
+ metadata.gz: 23c07c4c85ad1c66193733e371af30832c1ef8d0
4
+ data.tar.gz: 4da0100e043b131ffafbf8e824dcfb37c53e344e
5
5
  SHA512:
6
- metadata.gz: 1d82ae6802bd524f235ac12354426c7938ff6cb03984f6fd7e0b21433b851368b6cb41b0cdf49a3cba9b18c96bac9b83aa03b5db6fd45b03f615dfc4b783fb50
7
- data.tar.gz: 6025d431e657cc03a59f80875c1fbaf2b797e5ef0faa5f2c7c60f21a4f75ea2924b29fab7fdfef991e5d20cc209905ef2af35f31b3876e1d574300397d401978
6
+ metadata.gz: 698d341f91a205c3a89485ca9120fbfa4790e1804746ab0e23da0ffe81ace672b821ac2612de6e68be733cddca16cae0e1183c6715e7e998549de3778ef5f64f
7
+ data.tar.gz: 3df52d3c08b2f791be3363e379495338a052b03ab308e1c0e83fd9b977e2354fda31bb6b111814b8bb7fec36c4941a397d88e3c3c3fc830da2c1bf3bf53d3414
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.2.6
2
+ * fix ToC generator
3
+
1
4
  ## 0.2.5
2
5
  * add ToC generator
3
6
  * use Autodoc.configuration.path to change documents path
data/README.md CHANGED
@@ -7,31 +7,26 @@ gem "autodoc", group: :test
7
7
  ```
8
8
 
9
9
  ## Usage
10
- All request-specs tagged with `:autodoc` will be auto-documented.
10
+ Run rspec with AUTODOC=1 to generate documents for the specs tagged with `:autodoc`.
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
+
13
+ ```sh
14
+ # shell-command
15
+ AUTODOC=1 rspec
16
+ ```
11
17
 
12
18
  ```ruby
13
19
  # spec/requests/recipes_spec.rb
14
20
  describe "Recipes" do
15
- let(:params) do
16
- { name: "alice", type: 1 }
17
- end
18
-
19
21
  describe "POST /recipes", autodoc: true do
20
22
  it "creates a new recipe" do
21
- post "/recipes.json", params
23
+ post "/recipes.json", name: "alice", type: 1
22
24
  response.status.should == 201
23
25
  end
24
26
  end
25
27
  end
26
28
  ```
27
29
 
28
- Run rspec with AUTODOC=1 to generate documents. ([example](https://github.com/r7kamura/autodoc/blob/master/spec/dummy/doc/recipes.md))
29
-
30
- ```sh
31
- # shell-command
32
- AUTODOC=1 rspec
33
- ```
34
-
35
30
  ### Configuration
36
31
  You can configure `Autodoc.configuration` to change its behavior:
37
32
 
@@ -40,3 +35,9 @@ You can configure `Autodoc.configuration` to change its behavior:
40
35
  * template - [String] ERB template for each document (default: [document.md.erb](https://github.com/r7kamura/autodoc/blob/master/lib/autodoc/templates/document.md.erb))
41
36
  * toc_template - [String] ERB template for ToC (default: [toc.md.erb](https://github.com/r7kamura/autodoc/blob/master/lib/autodoc/templates/toc.md.erb))
42
37
  * toc - [Boolean] whether to generate toc.md (default: false)
38
+
39
+ ```ruby
40
+ # example
41
+ Autodoc.configuration.path = "doc/api"
42
+ Autodoc.configuration.toc = true
43
+ ```
@@ -28,7 +28,7 @@ module Autodoc
28
28
  end
29
29
 
30
30
  def identifier
31
- title.gsub(" ", "-").gsub(/[:_\/]/, "").downcase
31
+ title.gsub(" ", "-").gsub(/[:\/]/, "").downcase
32
32
  end
33
33
 
34
34
  private
@@ -26,6 +26,7 @@ module Autodoc
26
26
  end
27
27
 
28
28
  def write_toc
29
+ toc_path.parent.mkpath
29
30
  toc_path.open("w") {|file| file << render_toc }
30
31
  end
31
32
 
@@ -1,3 +1,3 @@
1
1
  module Autodoc
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
@@ -1,30 +1,21 @@
1
- ## POST /recipes
2
- Creates a new recipe.
3
-
4
- ### parameters
5
- * `name` string (required, except: `["alice", "bob"]`)
6
- * `type` integer (only: `1..3`)
1
+ ## GET /recipes/:id
2
+ Returns the recipe.
7
3
 
8
4
  ### request
9
5
  ```
10
- POST /recipes
11
- ```
12
-
13
- ```
14
- name=name&type=1
6
+ GET /recipes/:id
15
7
  ```
16
8
 
17
9
  ### response
18
10
  ```ruby
19
- Status: 201
20
- Location: http://www.example.com/recipes/1
11
+ Status: 200
21
12
  response:
22
13
  {
23
14
  "id": 1,
24
- "name": "name",
25
- "type": 1,
26
- "created_at": "2013-11-30T18:15:08.928Z",
27
- "updated_at": "2013-11-30T18:15:08.928Z"
15
+ "name": "test",
16
+ "type": 2,
17
+ "created_at": "2013-11-30T19:04:12.608Z",
18
+ "updated_at": "2013-11-30T19:04:12.608Z"
28
19
  }
29
20
  ```
30
21
 
@@ -47,13 +38,13 @@ name=name&type=1
47
38
  ### response
48
39
  ```ruby
49
40
  Status: 201
50
- Location: http://example.org/recipes/1
41
+ Location: http://www.example.com/recipes/1
51
42
  response:
52
43
  {
53
44
  "id": 1,
54
45
  "name": "name",
55
46
  "type": 1,
56
- "created_at": "2013-11-30T18:15:08.938Z",
57
- "updated_at": "2013-11-30T18:15:08.938Z"
47
+ "created_at": "2013-11-30T19:04:12.684Z",
48
+ "updated_at": "2013-11-30T19:04:12.684Z"
58
49
  }
59
50
  ```
@@ -1,4 +1,4 @@
1
1
  ## Table of Contents
2
2
  * [recipes.md](recipes.md)
3
+ * [GET /recipes/:id](recipes.md#get-recipesid)
3
4
  * [POST /recipes](recipes.md#post-recipes)
4
- * [POST /recipes](recipes.md#post-recipes-1)
@@ -6,13 +6,30 @@ describe "Recipes" do
6
6
  end
7
7
 
8
8
  let(:params) do
9
- {
10
- name: "name",
11
- type: 1,
12
- }
9
+ {}
10
+ end
11
+
12
+ describe "GET /recipes/:id" do
13
+ let(:recipe) do
14
+ Recipe.create(name: "test", type: 2)
15
+ end
16
+
17
+ context "with valid condition (using Rack::Test)", :autodoc do
18
+ include Rack::Test::Methods
19
+
20
+ it "returns the recipe" do
21
+ get "/recipes/#{recipe.id}", params, env
22
+ last_response.status.should == 200
23
+ end
24
+ end
13
25
  end
14
26
 
15
27
  describe "POST /recipes" do
28
+ before do
29
+ params[:name] = "name"
30
+ params[:type] = 1
31
+ end
32
+
16
33
  context "without required param" do
17
34
  before do
18
35
  params.delete(:name)
@@ -52,17 +69,5 @@ describe "Recipes" do
52
69
  response.status.should == 201
53
70
  end
54
71
  end
55
-
56
- context "with valid condition (client using Rack::Test)", :autodoc do
57
- include Rack::Test::Methods
58
- before do
59
- header 'Accept', 'application/json'
60
- end
61
-
62
- it "creates a new recipe" do
63
- post "/recipes", params
64
- last_response.status.should == 201
65
- end
66
- end
67
72
  end
68
73
  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.5
4
+ version: 0.2.6
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-30 00:00:00.000000000 Z
11
+ date: 2013-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -219,4 +219,3 @@ test_files:
219
219
  - spec/dummy/script/rails
220
220
  - spec/requests/recipes_spec.rb
221
221
  - spec/spec_helper.rb
222
- has_rdoc: