cabbage_doc 0.1.1 → 0.1.2
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 +4 -4
- data/lib/cabbage_doc/action.rb +11 -13
- data/lib/cabbage_doc/parameter.rb +1 -1
- data/lib/cabbage_doc/version.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 055cffe940d79679c10fcea332f7c1bc6bad9d06
|
4
|
+
data.tar.gz: 8721f7a7df58917bc532cf5540d1d96d0a50f47b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32c88f44aeca133c811f1ae80b7592eea6ed682ba80f4378355d0ce9a5e84714b30a351ac7acebbb4a42400d8bfe24f2204ebb8dabf9844acc82e030cc798852
|
7
|
+
data.tar.gz: ece56a88a5b0e29fd5125be604f301961e0471b52da71b1db455eaacdb48ca1b97fcf70cc684d28d476366128952ac3a7214a46b853079069beebcf5a7293c8f
|
data/lib/cabbage_doc/action.rb
CHANGED
@@ -4,6 +4,7 @@ module CabbageDoc
|
|
4
4
|
|
5
5
|
METHODS = %w(GET POST PUT DELETE).freeze
|
6
6
|
METHODS_REGEXP = METHODS.join('|').freeze
|
7
|
+
SECTION_REGEXP = "Parameters|Examples|#{METHODS_REGEXP}|#{VISIBILITY_REGEXP}".freeze
|
7
8
|
|
8
9
|
attr_reader :label, :name, :description, :path, :method, :parameters, :examples, :visibility
|
9
10
|
|
@@ -37,22 +38,12 @@ module CabbageDoc
|
|
37
38
|
|
38
39
|
private
|
39
40
|
|
40
|
-
# FIXME: get rid of this and optimize direct regex matches
|
41
|
-
def text_to_lines(text)
|
42
|
-
text.gsub(/\r\n?/, "\n").split(/\n/)[0..-2].map do |line|
|
43
|
-
line.strip!
|
44
|
-
line.slice!(0)
|
45
|
-
line.strip!
|
46
|
-
line if line.size > 0
|
47
|
-
end.compact
|
48
|
-
end
|
49
|
-
|
50
41
|
def parse_parameters_and_examples(text)
|
51
42
|
# FIXME: rewrite this to do a 'scan' with the right Regexp
|
52
43
|
parameters = []
|
53
44
|
examples = []
|
54
45
|
|
55
|
-
lines = text_to_lines(text)
|
46
|
+
lines = text_to_lines(text).map(&:strip).select { |line| line.size > 0 }
|
56
47
|
|
57
48
|
lines.each do |line|
|
58
49
|
if parameter = Parameter.parse(line)
|
@@ -81,8 +72,8 @@ module CabbageDoc
|
|
81
72
|
end
|
82
73
|
|
83
74
|
def parse_description(text)
|
84
|
-
m = text.match(/#\s*Description
|
85
|
-
m[1].strip if m
|
75
|
+
m = text.match(/#\s*Description:\s+(.*?)(#\s*(#{SECTION_REGEXP}):|\z)/m)
|
76
|
+
text_to_lines(m[1]).join("\n").strip if m
|
86
77
|
end
|
87
78
|
|
88
79
|
def parse_visibility(text)
|
@@ -93,5 +84,12 @@ module CabbageDoc
|
|
93
84
|
VISIBILITY.first
|
94
85
|
end
|
95
86
|
end
|
87
|
+
|
88
|
+
def text_to_lines(text)
|
89
|
+
text.strip.gsub(/\r\n?/, "\n").split("\n").map do |line|
|
90
|
+
line.sub!(/^(\s+)?#\s*/, "")
|
91
|
+
line if line !~ /#\s+?#{MARKER}$/
|
92
|
+
end.compact
|
93
|
+
end
|
96
94
|
end
|
97
95
|
end
|
@@ -2,7 +2,7 @@ module CabbageDoc
|
|
2
2
|
class Parameter
|
3
3
|
include Parser
|
4
4
|
|
5
|
-
TYPES = %i(numeric decimal integer string id enumeration array date time timestamp hash)
|
5
|
+
TYPES = %i(numeric decimal integer string id enumeration array date time timestamp hash number)
|
6
6
|
|
7
7
|
attr_reader :label, :name, :type, :type_label, :default, :values, :required
|
8
8
|
|
data/lib/cabbage_doc/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cabbage_doc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mihail Szabolcs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redcarpet
|
@@ -28,14 +28,14 @@ dependencies:
|
|
28
28
|
name: haml
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 4.0.6
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 4.0.6
|
41
41
|
- !ruby/object:Gem::Dependency
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: httparty
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.15.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 0.15.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: json
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -244,7 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
244
244
|
version: '0'
|
245
245
|
requirements: []
|
246
246
|
rubyforge_project:
|
247
|
-
rubygems_version: 2.
|
247
|
+
rubygems_version: 2.5.1
|
248
248
|
signing_key:
|
249
249
|
specification_version: 4
|
250
250
|
summary: Interactive API documentation generator.
|