api_doc_generation 0.0.8 → 0.0.9

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: 4a59367781747d4ca6e94511c8045e8d74321ca1
4
- data.tar.gz: 4eb0b36c7174d662bf5d9e32b0ffcc8bd56be26c
3
+ metadata.gz: 8a872e53bc7f3cf10f4ab8a3eee37af883c06c4e
4
+ data.tar.gz: 57a8595fa489c5f3d4247c1e6df6c5d8b9312f57
5
5
  SHA512:
6
- metadata.gz: 4c05f53ce3c4ea401131c8eff1ce55a80c9af707f59324efee5f99d5b4008659d7146ab5df2647a9be91c3351484eebecca557956bfc3106adb651986ec54688
7
- data.tar.gz: 22b878cb56d46e98e571d02375d94970c35f6641fe7b78a24550cf8dfc76fd24b88a5f1407e1ea984a8883a10a8d6240199fdfa2808663fd66fbbbdba899bfe6
6
+ metadata.gz: 7a72d59cdedafec4bcad569ae07fd8de99eebcf7e2e027e10c6682c220036d34c9d7ed01bcf5dd790dc6a2c5c83688158987f0a981308b89dbcad23d1da77884
7
+ data.tar.gz: 36e1d8d4dd28af3fb6b7061bac1ae256fbc13034abec4c6e682869822862c06e0624f80add0fdb50d5ca23aa3de5c61957f23a86fbb1bf55465c5f659e9d1279
data/README.md CHANGED
@@ -32,6 +32,7 @@ __代码注释格式:__
32
32
  # Return:
33
33
  # count: [Integer] 数据总条数
34
34
  # items: [Array] 当前页数据的数组
35
+ # Level: read
35
36
  def list
36
37
  # ...
37
38
  end
@@ -54,6 +55,16 @@ __代码注释格式:__
54
55
  上面已经给出了api说明,参数,返回,错误信息,而api地址和请求方法将会自动从Rails中查找出来
55
56
 
56
57
 
58
+ ## Level
59
+ * 默认level显示所有
60
+ * 输出时只会显示指定level的api
61
+ * 所有的level为:
62
+ ```read search update create delete```
63
+ * 使用:
64
+ ``` rake doc:api LEVEL=read,search```
65
+
66
+
67
+
57
68
  ## Contributing
58
69
 
59
70
  1. Fork it
@@ -1,3 +1,3 @@
1
1
  module ApiDocGeneration
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -24,25 +24,25 @@ module ApiDocGeneration; class Generation
24
24
  end
25
25
 
26
26
 
27
- def generate_html_string
27
+ def generate_html_string(opts = {})
28
28
  template = ERB.new(
29
29
  File.read(File.expand_path('../../templates/doc.html.erb', __FILE__))
30
30
  )
31
31
 
32
- ViewHelper.render(template, {
32
+ ViewHelper.render(template, opts.merge({
33
33
  :documents => @controller_documents
34
- })
34
+ }))
35
35
  end
36
36
 
37
37
 
38
- def generate_detailed_html_string
38
+ def generate_detailed_html_string(opts = {})
39
39
  template = ERB.new(
40
40
  File.read(File.expand_path('../../templates/doc_detailed.html.erb', __FILE__))
41
41
  )
42
42
 
43
- ViewHelper.render(template, {
43
+ ViewHelper.render(template, opts.merge({
44
44
  :documents => @controller_documents
45
- })
45
+ }))
46
46
  end
47
47
 
48
48
 
@@ -5,17 +5,24 @@ namespace :doc do
5
5
 
6
6
  out_format = ENV['OUT_FORMAT'] || 'detailed_html'
7
7
  codes_path = ENV['CODES_PATH'] || File.expand_path('app/controllers/api', Rails.root)
8
+ level = ENV['LEVEL'] ? ENV['LEVEL'].split(',') : nil
8
9
 
9
10
  puts out_format
10
11
 
11
12
  case out_format
12
13
  when 'simple_html'
13
14
  File.open("./tmp/api_doc.html", "w+") do |f|
14
- f.write(ApiDocGeneration::Generation.new(codes_path).generate_html_string)
15
+ f.write(
16
+ ApiDocGeneration::Generation.new(codes_path)
17
+ .generate_html_string(:level => level)
18
+ )
15
19
  end
16
20
  when 'detailed_html'
17
21
  File.open("./tmp/api_detailed_doc.html", 'w+') do |f|
18
- f.write(ApiDocGeneration::Generation.new(codes_path).generate_detailed_html_string)
22
+ f.write(
23
+ ApiDocGeneration::Generation.new(codes_path)
24
+ .generate_detailed_html_string(:level => level)
25
+ )
19
26
  end
20
27
  else
21
28
  puts "undefined OUT_FORMAT: '#{out_format}'"
@@ -86,6 +86,8 @@
86
86
 
87
87
  <ul class='ul-controller'>
88
88
  <% controller[:actions].each do |action| %>
89
+ <% next if @level && !@level.include?(action['Level'].strip) %>
90
+
89
91
  <li>
90
92
  <input type='checkbox' class='no_print no_opacity print_selector' checked=1 />
91
93
  <a href='#<%= action_identifer(controller[:klass], action[:name]) %>'>
@@ -105,6 +107,8 @@
105
107
  <h2 class='controller-title'><%= controller[:about] %></h2>
106
108
 
107
109
  <% controller[:actions].each_with_index do |action, i| %>
110
+ <% next if @level && !@level.include?(action['Level'].strip) %>
111
+
108
112
  <div class='action action-<%= i % 2 == 0 ? 'even' : 'odd' %>'
109
113
  id='<%= action_identifer(controller[:klass], action[:name]) %>'>
110
114
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api_doc_generation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - jiangzhi.xie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-25 00:00:00.000000000 Z
11
+ date: 2013-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler