inch 0.5.0.rc2 → 0.5.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/defaults.rb +7 -0
- data/lib/inch/code_object/provider/yard/docstring.rb +7 -2
- data/lib/inch/code_object/provider/yard/object.rb +1 -0
- data/lib/inch/code_object/provider/yard/object/class_variable_object.rb +12 -0
- data/lib/inch/code_object/proxy.rb +1 -0
- data/lib/inch/code_object/proxy/class_variable_object.rb +8 -0
- data/lib/inch/evaluation.rb +1 -0
- data/lib/inch/evaluation/proxy.rb +1 -0
- data/lib/inch/evaluation/proxy/class_variable_object.rb +19 -0
- data/lib/inch/evaluation/role/class_variable.rb +55 -0
- data/lib/inch/version.rb +1 -1
- data/test/fixtures/simple/lib/broken.rb +3 -0
- data/test/unit/code_object/provider/yard/docstring_test.rb +43 -1
- data/test/unit/code_object/proxy/method_object_test.rb +332 -297
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad7ddc303f887e07ca647f76f002aafed4dc120e
|
4
|
+
data.tar.gz: 7c0c21ee7be201462be99951d70c7544e9a4bc52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 582a2edf65d9d3d3bd8c95ffee5c55d94a07718a2cc94bcc9c594ffe2b106ed616755d15710ef575cdd312963e54cdd92893955d0c178eeb90a7c35940003f3c
|
7
|
+
data.tar.gz: b97da1277e2c3b2644ca49250288ff9031a4fee69463b11cbae485739d6aededf536f02e7892ed365d87067ffccc2c99a63eb97baf97d838a85429333a7b4924
|
data/config/defaults.rb
CHANGED
@@ -42,11 +42,12 @@ module Inch
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def mentions_return?
|
45
|
-
last_line =~
|
45
|
+
last_line =~ /^#{tomdoc_modifiers}Returns\ /
|
46
46
|
end
|
47
47
|
|
48
48
|
def describes_return?
|
49
|
-
last_line =~
|
49
|
+
last_line =~ /^#{tomdoc_modifiers}Returns\ (\w+\s){2,}/i ||
|
50
|
+
last_line =~ /^#{tomdoc_modifiers}Returns\ (nil|nothing)\.*/i
|
50
51
|
end
|
51
52
|
|
52
53
|
def to_s
|
@@ -121,6 +122,10 @@ module Inch
|
|
121
122
|
end
|
122
123
|
end
|
123
124
|
end
|
125
|
+
|
126
|
+
def tomdoc_modifiers
|
127
|
+
/((Public|Private|Internal)\:\ )*/
|
128
|
+
end
|
124
129
|
end
|
125
130
|
end
|
126
131
|
end
|
@@ -53,6 +53,7 @@ end
|
|
53
53
|
require 'inch/code_object/provider/yard/object/base'
|
54
54
|
require 'inch/code_object/provider/yard/object/namespace_object'
|
55
55
|
require 'inch/code_object/provider/yard/object/class_object'
|
56
|
+
require 'inch/code_object/provider/yard/object/class_variable_object'
|
56
57
|
require 'inch/code_object/provider/yard/object/constant_object'
|
57
58
|
require 'inch/code_object/provider/yard/object/method_object'
|
58
59
|
require 'inch/code_object/provider/yard/object/method_parameter_object'
|
@@ -32,6 +32,7 @@ end
|
|
32
32
|
require 'inch/code_object/proxy/base'
|
33
33
|
require 'inch/code_object/proxy/namespace_object'
|
34
34
|
require 'inch/code_object/proxy/class_object'
|
35
|
+
require 'inch/code_object/proxy/class_variable_object'
|
35
36
|
require 'inch/code_object/proxy/constant_object'
|
36
37
|
require 'inch/code_object/proxy/method_object'
|
37
38
|
require 'inch/code_object/proxy/method_parameter_object'
|
data/lib/inch/evaluation.rb
CHANGED
@@ -20,6 +20,7 @@ end
|
|
20
20
|
require 'inch/evaluation/proxy/base'
|
21
21
|
require 'inch/evaluation/proxy/namespace_object'
|
22
22
|
require 'inch/evaluation/proxy/class_object'
|
23
|
+
require 'inch/evaluation/proxy/class_variable_object'
|
23
24
|
require 'inch/evaluation/proxy/constant_object'
|
24
25
|
require 'inch/evaluation/proxy/method_object'
|
25
26
|
require 'inch/evaluation/proxy/module_object'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Inch
|
2
|
+
module Evaluation
|
3
|
+
module Proxy
|
4
|
+
class ClassVariableObject < Base
|
5
|
+
protected
|
6
|
+
|
7
|
+
def relevant_roles
|
8
|
+
{
|
9
|
+
Role::ClassVariable::WithDoc => score_for(:docstring),
|
10
|
+
Role::ClassVariable::WithoutDoc => score_for(:docstring),
|
11
|
+
Role::ClassVariable::TaggedAsNodoc => nil,
|
12
|
+
Role::ClassVariable::Public => nil,
|
13
|
+
Role::ClassVariable::Private => nil,
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Inch
|
2
|
+
module Evaluation
|
3
|
+
module Role
|
4
|
+
# Roles assigned to class variables
|
5
|
+
module ClassVariable
|
6
|
+
class WithDoc < Object::WithDoc
|
7
|
+
applicable_if :has_doc?
|
8
|
+
end
|
9
|
+
class WithoutDoc < Object::WithoutDoc
|
10
|
+
applicable_unless :has_doc?
|
11
|
+
end
|
12
|
+
|
13
|
+
class TaggedAsNodoc < Object::TaggedAsNodoc
|
14
|
+
applicable_if :nodoc?
|
15
|
+
end
|
16
|
+
class InRoot < Object::InRoot
|
17
|
+
applicable_if :in_root?
|
18
|
+
end
|
19
|
+
|
20
|
+
class Public < Object::Public
|
21
|
+
applicable_if :public?
|
22
|
+
|
23
|
+
def priority
|
24
|
+
-1
|
25
|
+
end
|
26
|
+
end
|
27
|
+
class Private < Object::Private
|
28
|
+
applicable_if :private?
|
29
|
+
|
30
|
+
def priority
|
31
|
+
-3
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class WithCodeExample < Object::WithCodeExample
|
36
|
+
applicable_if do |o|
|
37
|
+
o.has_code_example? && !o.has_multiple_code_examples?
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class WithMultipleCodeExamples < Object::WithMultipleCodeExamples
|
42
|
+
applicable_if :has_multiple_code_examples?
|
43
|
+
end
|
44
|
+
|
45
|
+
class WithoutCodeExample < Object::WithoutCodeExample
|
46
|
+
applicable_unless :has_code_example?
|
47
|
+
|
48
|
+
def suggestion
|
49
|
+
nil
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/inch/version.rb
CHANGED
@@ -79,6 +79,48 @@ DOC
|
|
79
79
|
assert docstring.describes_return?
|
80
80
|
end
|
81
81
|
|
82
|
+
it "should understand 'Returns nil.'" do
|
83
|
+
text = <<-DOC
|
84
|
+
[...]
|
85
|
+
Returns nil.
|
86
|
+
DOC
|
87
|
+
docstring = described_class.new(text)
|
88
|
+
assert docstring.describes_return?
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should understand 'Returns nil.' without fullstop and in lowercase" do
|
92
|
+
text = <<-DOC
|
93
|
+
[...]
|
94
|
+
returns nil
|
95
|
+
DOC
|
96
|
+
docstring = described_class.new(text)
|
97
|
+
assert docstring.describes_return?
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should understand 'Returns nothing.'" do
|
101
|
+
text = <<-DOC
|
102
|
+
[...]
|
103
|
+
Returns nothing.
|
104
|
+
DOC
|
105
|
+
docstring = described_class.new(text)
|
106
|
+
assert docstring.describes_return?
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should understand 'Returns nothing.' without fullstop and in lowercase" do
|
110
|
+
text = <<-DOC
|
111
|
+
[...]
|
112
|
+
returns nothing
|
113
|
+
DOC
|
114
|
+
docstring = described_class.new(text)
|
115
|
+
assert docstring.describes_return?
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should understand 'Returns ...' with a visibility modifier in front of it" do
|
119
|
+
text = "Public: Returns the Integer color."
|
120
|
+
docstring = described_class.new(text)
|
121
|
+
assert docstring.mentions_return?
|
122
|
+
assert docstring.describes_return?
|
123
|
+
end
|
82
124
|
|
83
125
|
#
|
84
126
|
# PARAMETER MENTIONS
|
@@ -96,7 +138,7 @@ DOC
|
|
96
138
|
end
|
97
139
|
|
98
140
|
|
99
|
-
it "should work 2" do
|
141
|
+
it "should work 2 if correct" do
|
100
142
|
text = <<-DOC
|
101
143
|
Just because format is mentioned here, does not mean
|
102
144
|
the first parameter is meant.
|
@@ -6,47 +6,55 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
6
6
|
@objects = @codebase.objects
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
describe "Scores" do
|
10
|
+
#
|
11
|
+
it "should not count tags that are transitive" do
|
12
|
+
m = @objects.find("InchTest::Deprecated::ClassMethods")
|
13
|
+
assert_equal 0, m.score
|
14
|
+
assert m.undocumented?
|
15
|
+
end
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
it "counts a @raise tag" do
|
18
|
+
m = @objects.find("InchTest#raising_method_with_comment")
|
19
|
+
assert m.score > 0
|
20
|
+
refute m.undocumented?
|
21
|
+
end
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
it "should not count a call to `raise`" do
|
24
|
+
m = @objects.find("InchTest#raising_method")
|
25
|
+
assert_equal 0, m.score
|
26
|
+
assert m.undocumented?
|
27
|
+
end
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
it "should not count a call to `yield`" do
|
30
|
+
m = @objects.find("InchTest#yielding_method")
|
31
|
+
assert_equal 0, m.score
|
32
|
+
assert m.undocumented?
|
33
|
+
end
|
31
34
|
end
|
32
35
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
describe "Taggings" do
|
37
|
+
#
|
38
|
+
it "should recognize forms of @private-tags" do
|
39
|
+
%w( InchTest#method_with_private_tag
|
40
|
+
InchTest#private_method_with_tomdoc).each do |fullname|
|
41
|
+
m = @objects.find(fullname)
|
42
|
+
assert m.tagged_as_private?
|
43
|
+
end
|
38
44
|
end
|
39
|
-
end
|
40
45
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
+
it "should recognize forms of internal-tags" do
|
47
|
+
# @api private in YARD
|
48
|
+
# Internal: in TomDoc
|
49
|
+
%w( InchTest#private_api_with_yard
|
50
|
+
InchTest#internal_api_with_tomdoc).each do |fullname|
|
51
|
+
m = @objects.find(fullname)
|
52
|
+
assert m.tagged_as_internal_api?
|
53
|
+
end
|
46
54
|
end
|
47
55
|
end
|
48
56
|
|
49
|
-
|
57
|
+
it "should recognize undocumented methods without parameters" do
|
50
58
|
m = @objects.find("Foo::Bar#method_without_doc")
|
51
59
|
refute m.has_doc?
|
52
60
|
refute m.has_parameters?
|
@@ -56,7 +64,7 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
56
64
|
assert_equal 0, m.score
|
57
65
|
end
|
58
66
|
|
59
|
-
|
67
|
+
it "should recognize missing parameter documentation" do
|
60
68
|
m = @objects.find("Foo::Bar#method_with_missing_param_doc")
|
61
69
|
assert m.has_doc?
|
62
70
|
assert m.has_parameters?
|
@@ -67,327 +75,354 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
67
75
|
assert p.mentioned?
|
68
76
|
p = m.parameter(:param2)
|
69
77
|
assert p.mentioned?
|
70
|
-
p = m.parameter(:param3)
|
71
|
-
refute p.mentioned?
|
72
|
-
|
73
|
-
assert m.score
|
74
|
-
end
|
75
78
|
|
76
|
-
|
77
|
-
m = @objects.find("Foo::Bar#method_with_wrong_doc")
|
78
|
-
assert m.has_doc?
|
79
|
-
assert m.has_parameters?
|
80
|
-
assert m.return_mentioned?
|
81
|
-
|
82
|
-
assert_equal 4, m.parameters.size
|
83
|
-
p = m.parameter(:param1)
|
84
|
-
assert p.mentioned? # mentioned in docs, correctly
|
85
|
-
refute p.wrongly_mentioned?
|
86
|
-
p = m.parameter(:param2)
|
87
|
-
refute p.mentioned?
|
88
|
-
refute p.wrongly_mentioned? # not mentioned in docs at all
|
79
|
+
# not mentioned
|
89
80
|
p = m.parameter(:param3)
|
90
81
|
refute p.mentioned?
|
91
|
-
refute p.wrongly_mentioned? # not mentioned in docs at all
|
92
|
-
p = m.parameter(:param4)
|
93
|
-
assert p.mentioned?
|
94
|
-
assert p.wrongly_mentioned? # mentioned in docs, but not present
|
95
82
|
|
96
83
|
assert m.score
|
97
84
|
end
|
98
85
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
86
|
+
describe "Documentation Styles" do
|
87
|
+
#
|
88
|
+
it "should handle YARD when no additional docstring is given" do
|
89
|
+
m = @objects.find("Foo::Bar#method_without_docstring")
|
90
|
+
refute m.has_doc?
|
91
|
+
assert m.has_parameters?
|
92
|
+
assert m.return_mentioned?
|
104
93
|
|
105
|
-
|
106
|
-
m.parameters.each do |param|
|
107
|
-
assert param.mentioned?
|
108
|
-
assert param.typed?
|
109
|
-
assert param.described?
|
110
|
-
refute param.wrongly_mentioned?
|
94
|
+
assert m.score
|
111
95
|
end
|
112
96
|
|
113
|
-
|
114
|
-
|
97
|
+
it "should handle YARD when only @return is given" do
|
98
|
+
m = @objects.find("Foo::Bar#method_without_params_or_docstring")
|
99
|
+
refute m.has_doc?
|
100
|
+
refute m.has_parameters?
|
101
|
+
assert m.return_mentioned?
|
115
102
|
|
116
|
-
|
117
|
-
|
118
|
-
assert m.has_doc?
|
119
|
-
refute m.has_parameters?
|
120
|
-
refute m.return_mentioned?
|
103
|
+
assert m.score
|
104
|
+
end
|
121
105
|
|
122
|
-
|
123
|
-
|
106
|
+
it "should handle RDoc" do
|
107
|
+
m = @objects.find("Foo::Bar#method_with_rdoc_doc")
|
108
|
+
assert m.has_doc?
|
109
|
+
assert m.has_parameters?
|
110
|
+
p = m.parameter(:param1)
|
111
|
+
assert p.mentioned? # mentioned in docs, correctly
|
112
|
+
refute m.return_mentioned?
|
124
113
|
|
125
|
-
|
126
|
-
|
127
|
-
refute m.has_doc?
|
128
|
-
assert m.has_parameters?
|
129
|
-
assert m.return_mentioned?
|
114
|
+
assert m.score
|
115
|
+
end
|
130
116
|
|
131
|
-
|
132
|
-
|
117
|
+
it "should handle other RDoc styles" do
|
118
|
+
m = @objects.find("Foo::Bar#method_with_other_rdoc_doc")
|
119
|
+
assert m.has_doc?
|
120
|
+
assert m.has_parameters?
|
121
|
+
p = m.parameter(:param1)
|
122
|
+
assert p.mentioned? # mentioned in docs, correctly
|
123
|
+
p = m.parameter(:param2)
|
124
|
+
assert p.mentioned? # mentioned in docs, correctly
|
125
|
+
p = m.parameter(:param3)
|
126
|
+
assert p.mentioned? # mentioned in docs, correctly
|
127
|
+
refute m.return_mentioned?
|
128
|
+
|
129
|
+
assert m.score
|
130
|
+
end
|
133
131
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
132
|
+
it "should handle unstructured doc styles" do
|
133
|
+
m = @objects.find("Foo::Bar#method_with_unstructured_doc")
|
134
|
+
assert m.has_doc?
|
135
|
+
assert m.has_parameters?
|
136
|
+
p = m.parameter(:param1)
|
137
|
+
assert p.mentioned? # mentioned in docs, correctly
|
138
|
+
refute m.return_mentioned?
|
139
139
|
|
140
|
-
|
141
|
-
|
140
|
+
assert m.score
|
141
|
+
end
|
142
142
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
143
|
+
it "should handle unstructured doc styles with an undocumented param" do
|
144
|
+
m = @objects.find("Foo::Bar#method_with_unstructured_doc_missing_params")
|
145
|
+
assert m.has_doc?
|
146
|
+
assert m.has_parameters?
|
147
|
+
p = m.parameter(:format)
|
148
|
+
refute p.mentioned? # mentioned in docs, correctly
|
149
|
+
refute m.return_mentioned?
|
150
150
|
|
151
|
-
|
152
|
-
|
151
|
+
assert m.score
|
152
|
+
end
|
153
153
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
assert p.mentioned? # mentioned in docs, correctly
|
160
|
-
p = m.parameter(:param2)
|
161
|
-
assert p.mentioned? # mentioned in docs, correctly
|
162
|
-
p = m.parameter(:param3)
|
163
|
-
assert p.mentioned? # mentioned in docs, correctly
|
164
|
-
refute m.return_mentioned?
|
154
|
+
it "should handle methods (without parameters) that have only a docstring (text comment)" do
|
155
|
+
m = @objects.find("Foo::Bar#method_without_params_or_return_type")
|
156
|
+
assert m.has_doc?
|
157
|
+
refute m.has_parameters?
|
158
|
+
refute m.return_mentioned?
|
165
159
|
|
166
|
-
|
160
|
+
assert m.score
|
161
|
+
end
|
167
162
|
end
|
168
163
|
|
169
|
-
|
170
|
-
m = @objects.find("Foo::Bar#method_with_unstructured_doc")
|
171
|
-
assert m.has_doc?
|
172
|
-
assert m.has_parameters?
|
173
|
-
p = m.parameter(:param1)
|
174
|
-
assert p.mentioned? # mentioned in docs, correctly
|
175
|
-
refute m.return_mentioned?
|
164
|
+
describe "Getter/Setter Handling" do
|
176
165
|
|
177
|
-
|
178
|
-
|
166
|
+
it "should recognize a getter method" do
|
167
|
+
m = @objects.find("InchTest#getter")
|
168
|
+
assert m.getter?, "should be a getter"
|
169
|
+
refute m.setter?
|
170
|
+
refute m.has_doc?
|
171
|
+
assert_equal 0, m.score
|
172
|
+
end
|
179
173
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
174
|
+
it "should recognize a setter method" do
|
175
|
+
m = @objects.find("InchTest#attr_setter=")
|
176
|
+
refute m.getter?
|
177
|
+
assert m.setter?, "should be a setter"
|
178
|
+
refute m.has_doc?
|
179
|
+
assert_equal 0, m.score
|
180
|
+
end
|
187
181
|
|
188
|
-
|
189
|
-
|
182
|
+
it "should recognize a manually defined setter method" do
|
183
|
+
m = @objects.find("InchTest#manual_setter=")
|
184
|
+
refute m.getter?
|
185
|
+
assert m.setter?, "should be a setter"
|
186
|
+
refute m.has_doc?
|
187
|
+
assert_equal 0, m.score
|
188
|
+
end
|
190
189
|
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
190
|
+
it "should recognize a getter in a manually defined getter/setter pair" do
|
191
|
+
m = @objects.find("InchTest#manual_getset")
|
192
|
+
assert m.getter?, "should be a getter"
|
193
|
+
refute m.setter?
|
194
|
+
refute m.has_doc?
|
195
|
+
assert_equal 0, m.score
|
196
|
+
end
|
195
197
|
|
196
|
-
|
197
|
-
|
198
|
+
it "should recognize a setter in a manually defined getter/setter pair" do
|
199
|
+
m = @objects.find("InchTest#manual_getset=")
|
200
|
+
refute m.getter?
|
201
|
+
assert m.setter?, "should be a setter"
|
202
|
+
refute m.has_doc?
|
203
|
+
assert_equal 0, m.score
|
204
|
+
end
|
198
205
|
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
206
|
+
it "should recognize a getter in a getter/setter pair defined via attr_accessor" do
|
207
|
+
m = @objects.find("InchTest#attr_getset")
|
208
|
+
assert m.getter?, "should be a getter"
|
209
|
+
refute m.setter?
|
210
|
+
refute m.has_doc?
|
211
|
+
assert_equal 0, m.score
|
212
|
+
end
|
203
213
|
|
204
|
-
|
205
|
-
|
206
|
-
|
214
|
+
it "should recognize a setter in a getter/setter pair defined via attr_accessor" do
|
215
|
+
m = @objects.find("InchTest#attr_getset=")
|
216
|
+
refute m.getter?
|
217
|
+
assert m.setter?, "should be a setter"
|
218
|
+
refute m.has_doc?
|
219
|
+
assert_equal 0, m.score
|
220
|
+
end
|
207
221
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
222
|
+
it "should recognize a getter in a getter/setter pair defined via Struct" do
|
223
|
+
m = @objects.find("InchTest::StructGetSet#struct_getset")
|
224
|
+
assert m.getter?, "should be a getter"
|
225
|
+
refute m.setter?
|
226
|
+
refute m.has_doc?
|
227
|
+
assert_equal 0, m.score
|
228
|
+
end
|
212
229
|
|
213
|
-
|
214
|
-
|
230
|
+
it "should recognize a setter in a getter/setter pair defined via Struct" do
|
231
|
+
m = @objects.find("InchTest::StructGetSet#struct_getset=")
|
232
|
+
refute m.getter?
|
233
|
+
assert m.setter?, "should be a setter"
|
234
|
+
refute m.has_doc?
|
235
|
+
assert_equal 0, m.score
|
236
|
+
end
|
215
237
|
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
m = @objects.find("Foo::Bar#method_without_doc")
|
222
|
-
assert_equal 3, m.depth
|
223
|
-
end
|
238
|
+
it "should recognize docs on a getter in a getter/setter pair defined via attr_accessor" do
|
239
|
+
m = @objects.find("Attributes#username")
|
240
|
+
refute_equal 0, m.score
|
241
|
+
refute m.undocumented?
|
242
|
+
end
|
224
243
|
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
assert_equal 0, m.score
|
231
|
-
end
|
244
|
+
it "should recognize docs on a setter in a getter/setter pair defined via attr_accessor" do
|
245
|
+
m = @objects.find("Attributes#username=")
|
246
|
+
refute_equal 0, m.score
|
247
|
+
refute m.undocumented?
|
248
|
+
end
|
232
249
|
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
250
|
+
it "should recognize splat parameter notation" do
|
251
|
+
# it should assign the same score whether the parameter is
|
252
|
+
# described with or without the splat (*) operator
|
253
|
+
m1 = @objects.find("Foo#method_with_splat_parameter")
|
254
|
+
m2 = @objects.find("Foo#method_with_splat_parameter2")
|
255
|
+
assert_equal 1, m1.parameters.size
|
256
|
+
assert_equal 1, m2.parameters.size
|
257
|
+
assert_equal m1.score, m2.score
|
258
|
+
end
|
240
259
|
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
assert_equal 0, m.score
|
260
|
+
it "should recognize alias methods and aliased methods" do
|
261
|
+
m1 = @objects.find("InchTest#_aliased_method")
|
262
|
+
m2 = @objects.find("InchTest#_alias_method")
|
263
|
+
assert_equal m1.score, m2.score
|
264
|
+
end
|
247
265
|
end
|
248
266
|
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
267
|
+
describe "YARDs @!attribute directive on a class" do
|
268
|
+
#
|
269
|
+
it "should work as a reader" do
|
270
|
+
m = @objects.find("Attributes#email")
|
271
|
+
refute_equal 0, m.score
|
272
|
+
refute m.undocumented?
|
273
|
+
end
|
256
274
|
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
275
|
+
it "should work as a writer" do
|
276
|
+
m = @objects.find("Attributes#email=")
|
277
|
+
refute_equal 0, m.score
|
278
|
+
#refute m.undocumented?
|
279
|
+
# NOTE: this is undocumented since there is no original_docstring
|
280
|
+
end
|
263
281
|
end
|
264
282
|
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
283
|
+
describe "YARDs @overload tag on methods" do
|
284
|
+
#
|
285
|
+
it "should work with basic overloading" do
|
286
|
+
list = []
|
287
|
+
list << @objects.find("Overloading#rgb")
|
288
|
+
list << @objects.find("Overloading#rgba")
|
289
|
+
list << @objects.find("Overloading#change_color")
|
290
|
+
list << @objects.find("Overloading#mix")
|
291
|
+
list << @objects.find("Overloading#hooks")
|
292
|
+
list << @objects.find("Overloading#identifiers")
|
293
|
+
list << @objects.find("Overloading#params_only_in_overloads")
|
294
|
+
list.each do |m|
|
295
|
+
assert_equal 100, m.score, "#{m.fullname} did not get 100"
|
296
|
+
end
|
297
|
+
end
|
272
298
|
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
refute m.has_doc?
|
278
|
-
assert_equal 0, m.score
|
279
|
-
end
|
299
|
+
it "should work with a malformed @param tag in an overload tag" do
|
300
|
+
m = @objects.find("Overloading#missing_param_names")
|
301
|
+
refute m.has_doc? # it may be mentioned in the docs, but it's malformed.
|
302
|
+
end
|
280
303
|
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
end
|
304
|
+
it "should work with several overload tags on the same method" do
|
305
|
+
m = @objects.find("Overloading#many_overloads")
|
306
|
+
assert_equal 1, count_roles(m, Inch::Evaluation::Role::Method::WithoutReturnDescription)
|
307
|
+
assert_equal 1, count_roles(m, Inch::Evaluation::Role::Method::WithoutReturnType)
|
308
|
+
assert_equal 1, count_roles(m, Inch::Evaluation::Role::MethodParameter::WithoutMention, 'block')
|
309
|
+
end
|
288
310
|
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
311
|
+
it "should work if @param tags are only present in the @overload tags, but not on the actual method" do
|
312
|
+
m = @objects.find("Overloading#params_only_in_overloads")
|
313
|
+
unexpected_roles = [
|
314
|
+
Inch::Evaluation::Role::Object::WithoutCodeExample,
|
315
|
+
Inch::Evaluation::Role::MethodParameter::WithoutMention,
|
316
|
+
Inch::Evaluation::Role::MethodParameter::WithoutType,
|
317
|
+
]
|
318
|
+
assert_roles m, [], unexpected_roles
|
319
|
+
end
|
296
320
|
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
321
|
+
it "should work with one param missing in the overload tag" do
|
322
|
+
m = @objects.find("Overloading#one_param_missing_in_overload")
|
323
|
+
unexpected_roles = [
|
324
|
+
Inch::Evaluation::Role::Object::WithoutCodeExample,
|
325
|
+
]
|
326
|
+
expected_roles = [
|
327
|
+
Inch::Evaluation::Role::MethodParameter::WithoutMention,
|
328
|
+
Inch::Evaluation::Role::MethodParameter::WithoutType,
|
329
|
+
]
|
330
|
+
assert_roles m, expected_roles, unexpected_roles
|
331
|
+
end
|
305
332
|
end
|
306
333
|
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
334
|
+
describe "MISC" do
|
335
|
+
#
|
336
|
+
it "should recognize named parameters in Ruby 2.1" do
|
337
|
+
m = @objects.find("Foo#method_with_named_parameter")
|
338
|
+
unexpected_roles = [
|
339
|
+
Inch::Evaluation::Role::MethodParameter::WithoutMention,
|
340
|
+
Inch::Evaluation::Role::MethodParameter::WithoutType,
|
341
|
+
]
|
342
|
+
assert_roles m, [], unexpected_roles
|
343
|
+
end
|
312
344
|
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
345
|
+
it "should recognize wrong parameter documentation" do
|
346
|
+
m = @objects.find("Foo::Bar#method_with_wrong_doc")
|
347
|
+
assert m.has_doc?
|
348
|
+
assert m.has_parameters?
|
349
|
+
assert m.return_mentioned?
|
350
|
+
|
351
|
+
assert_equal 4, m.parameters.size
|
352
|
+
p = m.parameter(:param1)
|
353
|
+
assert p.mentioned? # mentioned in docs, correctly
|
354
|
+
refute p.wrongly_mentioned?
|
355
|
+
p = m.parameter(:param2)
|
356
|
+
refute p.mentioned?
|
357
|
+
refute p.wrongly_mentioned? # not mentioned in docs at all
|
358
|
+
p = m.parameter(:param3)
|
359
|
+
refute p.mentioned?
|
360
|
+
refute p.wrongly_mentioned? # not mentioned in docs at all
|
361
|
+
|
362
|
+
p = m.parameter(:param4)
|
363
|
+
assert p.mentioned?
|
364
|
+
assert p.wrongly_mentioned? # mentioned in docs, but not present
|
365
|
+
|
366
|
+
assert m.score
|
324
367
|
end
|
325
|
-
end
|
326
368
|
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
369
|
+
it "should recognize fully-documented methods with parameters" do
|
370
|
+
m = @objects.find("Foo::Bar#method_with_full_doc")
|
371
|
+
assert m.has_doc?
|
372
|
+
assert m.has_parameters?
|
373
|
+
assert m.return_mentioned?
|
374
|
+
|
375
|
+
assert_equal 2, m.parameters.size
|
376
|
+
m.parameters.each do |param|
|
377
|
+
assert param.mentioned?
|
378
|
+
assert param.typed?
|
379
|
+
assert param.described?
|
380
|
+
refute param.wrongly_mentioned?
|
381
|
+
end
|
382
|
+
|
383
|
+
assert_equal 100, m.score
|
384
|
+
end
|
331
385
|
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
end
|
386
|
+
it "should recognize question mark methods" do
|
387
|
+
m = @objects.find("InchTest#question_mark_method?")
|
388
|
+
refute m.has_doc?
|
389
|
+
refute m.has_parameters?
|
337
390
|
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
refute m.undocumented?
|
342
|
-
end
|
391
|
+
# assert it is zero, because YARD auto-assigns tags to these
|
392
|
+
assert_equal 0, m.score
|
393
|
+
end
|
343
394
|
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
end
|
395
|
+
it "should recognize question mark methods with description" do
|
396
|
+
m = @objects.find("InchTest#question_mark_method_with_description?")
|
397
|
+
refute m.has_doc?
|
398
|
+
refute m.has_parameters?
|
349
399
|
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
refute m.undocumented?
|
354
|
-
end
|
400
|
+
assert m.score > 0
|
401
|
+
assert m.score >= 50 # TODO: don't use magic numbers
|
402
|
+
end
|
355
403
|
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
assert_equal 1, count_roles(m, Inch::Evaluation::Role::MethodParameter::WithoutMention, 'block')
|
361
|
-
end
|
404
|
+
it "should recognize question mark methods with description and parameters" do
|
405
|
+
m = @objects.find("InchTest#method_with_description_and_parameters?")
|
406
|
+
refute m.has_doc?
|
407
|
+
assert m.has_parameters?
|
362
408
|
|
363
|
-
|
364
|
-
|
365
|
-
unexpected_roles = [
|
366
|
-
Inch::Evaluation::Role::Object::WithoutCodeExample,
|
367
|
-
Inch::Evaluation::Role::MethodParameter::WithoutMention,
|
368
|
-
Inch::Evaluation::Role::MethodParameter::WithoutType,
|
369
|
-
]
|
370
|
-
assert_roles m, [], unexpected_roles
|
371
|
-
end
|
409
|
+
assert m.score > 0
|
410
|
+
end
|
372
411
|
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
]
|
382
|
-
assert_roles m, expected_roles, unexpected_roles
|
383
|
-
end
|
412
|
+
it "should recognize the depth of methods" do
|
413
|
+
m = @objects.find("#root_method")
|
414
|
+
assert_equal 1, m.depth
|
415
|
+
m = @objects.find("InchTest#getter")
|
416
|
+
assert_equal 2, m.depth
|
417
|
+
m = @objects.find("Foo::Bar#method_without_doc")
|
418
|
+
assert_equal 3, m.depth
|
419
|
+
end
|
384
420
|
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
assert_roles m, [], unexpected_roles
|
421
|
+
it "should recognize docs on class variables" do
|
422
|
+
m = @objects.find("Foo::@@class_variable")
|
423
|
+
assert m.has_doc?
|
424
|
+
refute m.undocumented?
|
425
|
+
assert_equal 100, m.score
|
426
|
+
end
|
392
427
|
end
|
393
428
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.0.
|
4
|
+
version: 0.5.0.rc3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- René Föhring
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -189,6 +189,7 @@ files:
|
|
189
189
|
- lib/inch/code_object/provider/yard/object.rb
|
190
190
|
- lib/inch/code_object/provider/yard/object/base.rb
|
191
191
|
- lib/inch/code_object/provider/yard/object/class_object.rb
|
192
|
+
- lib/inch/code_object/provider/yard/object/class_variable_object.rb
|
192
193
|
- lib/inch/code_object/provider/yard/object/constant_object.rb
|
193
194
|
- lib/inch/code_object/provider/yard/object/method_object.rb
|
194
195
|
- lib/inch/code_object/provider/yard/object/method_parameter_object.rb
|
@@ -200,6 +201,7 @@ files:
|
|
200
201
|
- lib/inch/code_object/proxy.rb
|
201
202
|
- lib/inch/code_object/proxy/base.rb
|
202
203
|
- lib/inch/code_object/proxy/class_object.rb
|
204
|
+
- lib/inch/code_object/proxy/class_variable_object.rb
|
203
205
|
- lib/inch/code_object/proxy/constant_object.rb
|
204
206
|
- lib/inch/code_object/proxy/method_object.rb
|
205
207
|
- lib/inch/code_object/proxy/method_parameter_object.rb
|
@@ -224,11 +226,13 @@ files:
|
|
224
226
|
- lib/inch/evaluation/proxy.rb
|
225
227
|
- lib/inch/evaluation/proxy/base.rb
|
226
228
|
- lib/inch/evaluation/proxy/class_object.rb
|
229
|
+
- lib/inch/evaluation/proxy/class_variable_object.rb
|
227
230
|
- lib/inch/evaluation/proxy/constant_object.rb
|
228
231
|
- lib/inch/evaluation/proxy/method_object.rb
|
229
232
|
- lib/inch/evaluation/proxy/module_object.rb
|
230
233
|
- lib/inch/evaluation/proxy/namespace_object.rb
|
231
234
|
- lib/inch/evaluation/role/base.rb
|
235
|
+
- lib/inch/evaluation/role/class_variable.rb
|
232
236
|
- lib/inch/evaluation/role/constant.rb
|
233
237
|
- lib/inch/evaluation/role/method.rb
|
234
238
|
- lib/inch/evaluation/role/method_parameter.rb
|