grape-doc 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2663f1be3ceff0b795fab8fd8b6b7ade751ae9b9
4
- data.tar.gz: 0a3c33f2094b71b751ab3b7e6b03a42cbcfeb92a
3
+ metadata.gz: 8bdde98c671823057861492304f607ee723bc1e2
4
+ data.tar.gz: 01a9a3b5767bb4329a66592adbd34a595c9074e5
5
5
  SHA512:
6
- metadata.gz: 4ac309e0dca87872ad31477a9bd2c9009c7b556165a99b9d07911f334b7594fc146b78b895460a23fcb260f07f3e1794ba88f8069945dad0796dbb21811cb6e8
7
- data.tar.gz: 7b2d9c0e55d506ba5101b58f601da249895265ae450c672e5370d5b8c1bedbd53d5d5d3b885ce309136c13be71fe0745a7ec1c0eca8d05e0b8d8b40b96b88afa
6
+ metadata.gz: 17904dfb4e24e8b44000b64805026c1084a6cc7a6b16c011c6986fd27a7e52f03707d6287d81b7ec37002063f7a1b39e6d11ceee1622773411c4eaaa62572953
7
+ data.tar.gz: 15b5bffa2724452f02d4fb1dd68e0b5d8925b7ab47853ae961c8e91b2157884bcc801a16421a64e4ddc3bad36dbc79e878c0871ce2e10a40eb42628c783c5067
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.0
1
+ 0.6.1
@@ -2,6 +2,11 @@ module GrapeDoc
2
2
 
3
3
  class ApiDocumentation < Array
4
4
 
5
+ def initialize(opts={})
6
+ raise(ArgumentError) unless opts.class <= Hash
7
+ @opts = opts.reduce({}){|m,o| m.merge!(o[0].to_s => o[1].to_s.downcase) ;m}
8
+ end
9
+
5
10
  def build(type,*args)
6
11
  raise(ArgumentError,'invalid type') unless [String,Symbol].any?{ |klass| type.class <= klass }
7
12
  return Helpers.constantize("GrapeDoc::ApiDocParts::#{Helpers.camelize(type)}").new(*args)
@@ -13,9 +18,16 @@ module GrapeDoc
13
18
 
14
19
  def add_toc(*args)
15
20
  @toc_added ||= ->{
21
+ case @opts['format']
22
+
23
+ when 'redmine'
24
+ self.insert(1,'{{toc}}')
25
+
26
+ else
27
+ args.map!{|e| Helpers.constantize("GrapeDoc::ApiDocParts::#{Helpers.camelize(e)}") }
28
+ self.insert(1,ApiDocParts::TOC.new(*self.select{|e| args.any?{|klass| e.class == klass }}))
16
29
 
17
- args.map!{|e| Helpers.constantize("GrapeDoc::ApiDocParts::#{Helpers.camelize(e)}") }
18
- self.insert(1,ApiDocParts::TOC.new(*self.select{|e| args.any?{|klass| e.class == klass }}))
30
+ end
19
31
  true
20
32
 
21
33
  }.call
@@ -39,7 +39,7 @@ module GrapeDoc
39
39
  private
40
40
 
41
41
  def document
42
- @api_doc ||= ApiDocumentation.new
42
+ @api_doc ||= ApiDocumentation.new(format: @options['format'])
43
43
  end
44
44
 
45
45
  def process_head
@@ -104,12 +104,20 @@ module GrapeDoc
104
104
  k =~ /^#{route_path_var}\.?/ && v.keys.include?(route_method_var)
105
105
  }
106
106
 
107
- document.add :h3,'Response'
108
- document.add :h4,'Example(s)'
109
107
 
110
108
  poc_cases.each do |poc_path,poc_data|
111
109
  poc_examples = poc_data[route_method_var] || next
112
110
  poc_examples.each_with_index do |poc_opts,i|
111
+
112
+ @resp_head ||= {}
113
+ @resp_head["#{route_method_var}:#{route_method_var}"] ||= ->{
114
+
115
+ document.add :h3,'Response'
116
+ document.add :h4,'Example(s)'
117
+
118
+ true
119
+ }.call
120
+
113
121
  i = i + 1
114
122
  begin
115
123
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-doc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Luzsi