grape-doc 0.4.3 → 0.5.0
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/grape-doc.gemspec +13 -13
- data/lib/grape-doc.rb +1 -0
- data/lib/grape/doc/doc_class.rb +1 -1
- data/lib/grape/doc/doc_class/header.rb +28 -0
- data/lib/grape/doc/generator.rb +2 -1
- data/lib/grape/doc/helper.rb +1 -1
- data/lib/grape/doc/prototype.rb +41 -10
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20c49ea385aee4168b325d4df3d75843c5fcd505
|
4
|
+
data.tar.gz: 7dfb74e1f420d008dc8ad3b66c7d262b026b8321
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd034ca8b87b1b77d87d5ae2f9db763babf1205d875722b975672155ef62ed1f318a09a61feb4a303ae7598392dad2885f4507872acab521c722ac991c998c3f
|
7
|
+
data.tar.gz: cedebfb30692dfe07801696fd2e65e567ae9c7f469ffb5ab8e1830ca19c04a2426f46fd99adf1f4e60013811fe49f58d309b280bf794fbd80785783479daedad
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/grape-doc.gemspec
CHANGED
@@ -2,27 +2,27 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
|
5
|
-
spec.name =
|
6
|
-
spec.version = File.open(File.join(File.dirname(__FILE__),
|
7
|
-
spec.authors = [
|
8
|
-
spec.email = [
|
5
|
+
spec.name = 'grape-doc'
|
6
|
+
spec.version = File.open(File.join(File.dirname(__FILE__),'VERSION')).read.split("\n")[0].chomp.gsub(' ','')
|
7
|
+
spec.authors = ['Adam Luzsi']
|
8
|
+
spec.email = ['adamluzsi@gmail.com']
|
9
9
|
|
10
|
-
spec.description = %q{ Documentation generator for Grape module compatible with Redmine and
|
10
|
+
spec.description = %q{ Documentation generator for Grape module compatible with Redmine/textile and Html formats }
|
11
11
|
spec.summary = %q{ Documentation generator for Grape module }
|
12
12
|
|
13
13
|
spec.homepage = "https://github.com/adamluzsi/#{__FILE__.split(File::Separator).last.split('.').first}"
|
14
14
|
spec.files = `git ls-files`.split($/)
|
15
15
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
16
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
-
spec.require_paths = [
|
17
|
+
spec.require_paths = ['lib']
|
18
18
|
|
19
|
-
spec.add_development_dependency
|
20
|
-
spec.add_development_dependency
|
19
|
+
spec.add_development_dependency 'bundler'
|
20
|
+
spec.add_development_dependency 'rake'
|
21
21
|
|
22
|
-
spec.add_dependency
|
23
|
-
spec.add_dependency
|
24
|
-
spec.add_dependency
|
25
|
-
spec.add_dependency
|
26
|
-
spec.add_dependency
|
22
|
+
spec.add_dependency 'grape'
|
23
|
+
spec.add_dependency 'loader'
|
24
|
+
spec.add_dependency 'RedCloth'
|
25
|
+
spec.add_dependency 'rack-test'
|
26
|
+
spec.add_dependency 'rack-test-poc','>= 1.1.0'
|
27
27
|
|
28
28
|
end
|
data/lib/grape-doc.rb
CHANGED
data/lib/grape/doc/doc_class.rb
CHANGED
@@ -1,7 +1,35 @@
|
|
1
1
|
module GrapeDoc
|
2
2
|
class ApiDocParts
|
3
3
|
|
4
|
+
module TOC
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def add_header(header_obj)
|
8
|
+
if [H1,H2].include? header_obj.class
|
9
|
+
(@headers ||= []).push(header_obj)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def create_toc
|
14
|
+
@headers.map { |header_obj|
|
15
|
+
[
|
16
|
+
'*' * header_obj.markdown.scan(/\d+$/)[0].to_i,
|
17
|
+
" \"#{header_obj.to_s}\":##{header_obj.instance_variable_get(:@opts)['id']}"
|
18
|
+
].join
|
19
|
+
}.join("\n") + "\n\n"
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
4
25
|
class H1 < StringObject
|
26
|
+
|
27
|
+
def initialize(*args)
|
28
|
+
super
|
29
|
+
@opts['id']= SecureRandom.uuid
|
30
|
+
TOC.add_header(self)
|
31
|
+
end
|
32
|
+
|
5
33
|
end
|
6
34
|
|
7
35
|
class H2 < H1
|
data/lib/grape/doc/generator.rb
CHANGED
@@ -13,8 +13,8 @@ module GrapeDoc
|
|
13
13
|
self.options['path'] = self.options['path'].to_s.sub(/\..*$/,'')
|
14
14
|
|
15
15
|
process_head
|
16
|
-
process_table_of_content
|
17
16
|
process_endpoints
|
17
|
+
process_table_of_content
|
18
18
|
|
19
19
|
end
|
20
20
|
|
@@ -48,6 +48,7 @@ module GrapeDoc
|
|
48
48
|
|
49
49
|
def process_table_of_content
|
50
50
|
#TODO: Table of content here!
|
51
|
+
document.insert 1, ApiDocParts::TOC.create_toc
|
51
52
|
end
|
52
53
|
|
53
54
|
def process_endpoints
|
data/lib/grape/doc/helper.rb
CHANGED
data/lib/grape/doc/prototype.rb
CHANGED
@@ -13,6 +13,12 @@ module GrapeDoc
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def initialize(*args)
|
16
|
+
|
17
|
+
@opts = args.select{|e| e.class <= ::Hash }
|
18
|
+
args -= @opts
|
19
|
+
|
20
|
+
@opts = @opts.reduce({}){|m,o| m.merge!(o[0].to_s => o[1]) ;m}
|
21
|
+
|
16
22
|
args[0] = Parser.parse(args[0])
|
17
23
|
self.replace(args[0].to_s)
|
18
24
|
end
|
@@ -21,27 +27,49 @@ module GrapeDoc
|
|
21
27
|
self.class.markdown
|
22
28
|
end
|
23
29
|
|
24
|
-
|
30
|
+
def to_textile
|
31
|
+
case @opts['style'].to_s.downcase
|
25
32
|
|
26
|
-
|
33
|
+
when /^mirror/
|
34
|
+
"#{markdown}#{self}#{markdown}"
|
27
35
|
|
28
|
-
|
36
|
+
when /^start/,/^begin/
|
29
37
|
|
30
|
-
|
31
|
-
|
38
|
+
options = [
|
39
|
+
@opts['class'] ? "#{@opts['class']}" : nil,
|
40
|
+
@opts['id'] ? "##{@opts['id']}" : nil
|
41
|
+
].compact
|
42
|
+
|
43
|
+
[
|
44
|
+
markdown,
|
45
|
+
options.empty? ? nil : "(#{options.join(' ')})",
|
46
|
+
'. ',
|
47
|
+
self.to_s
|
48
|
+
].compact.join
|
49
|
+
|
50
|
+
else
|
51
|
+
self.to_s
|
52
|
+
|
53
|
+
end
|
32
54
|
end
|
33
55
|
|
34
56
|
end
|
35
57
|
|
36
|
-
class
|
37
|
-
|
38
|
-
|
39
|
-
|
58
|
+
class StringObject < StringBasic
|
59
|
+
def initialize(*args)
|
60
|
+
super
|
61
|
+
@opts['style']= 'start'
|
40
62
|
end
|
63
|
+
end
|
41
64
|
|
65
|
+
class StringObjectEnded < StringObject
|
66
|
+
def initialize(*args)
|
67
|
+
super
|
68
|
+
@opts['style']= 'mirror'
|
69
|
+
end
|
42
70
|
end
|
43
71
|
|
44
|
-
class
|
72
|
+
class ArrayBasic < Array
|
45
73
|
|
46
74
|
class << self
|
47
75
|
def markdown=(obj)
|
@@ -87,5 +115,8 @@ module GrapeDoc
|
|
87
115
|
|
88
116
|
end
|
89
117
|
|
118
|
+
class ArrayObject < ArrayBasic
|
119
|
+
end
|
120
|
+
|
90
121
|
end
|
91
122
|
end
|
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.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Luzsi
|
@@ -108,8 +108,8 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 1.1.0
|
111
|
-
description: " Documentation generator for Grape module compatible with Redmine
|
112
|
-
|
111
|
+
description: " Documentation generator for Grape module compatible with Redmine/textile
|
112
|
+
and Html formats "
|
113
113
|
email:
|
114
114
|
- adamluzsi@gmail.com
|
115
115
|
executables: []
|