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 +4 -4
- data/VERSION +1 -1
- data/lib/grape/doc/doc_class.rb +14 -2
- data/lib/grape/doc/generator.rb +11 -3
- 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: 8bdde98c671823057861492304f607ee723bc1e2
|
4
|
+
data.tar.gz: 01a9a3b5767bb4329a66592adbd34a595c9074e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17904dfb4e24e8b44000b64805026c1084a6cc7a6b16c011c6986fd27a7e52f03707d6287d81b7ec37002063f7a1b39e6d11ceee1622773411c4eaaa62572953
|
7
|
+
data.tar.gz: 15b5bffa2724452f02d4fb1dd68e0b5d8925b7ab47853ae961c8e91b2157884bcc801a16421a64e4ddc3bad36dbc79e878c0871ce2e10a40eb42628c783c5067
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.1
|
data/lib/grape/doc/doc_class.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/grape/doc/generator.rb
CHANGED
@@ -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
|
|