inch 0.4.4.rc1 → 0.4.4.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/inch/code_object/provider/yard/docstring.rb +16 -0
- data/lib/inch/code_object/provider/yard/object/method_object.rb +7 -2
- data/lib/inch/code_object/provider/yard/object/method_signature.rb +3 -14
- data/lib/inch/version.rb +1 -1
- data/test/unit/code_object/proxy/method_object_test.rb +12 -0
- 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: 939665081ef1fae175405f3e47c6aab33b96449a
|
4
|
+
data.tar.gz: 384311683a56411b6408f0206af6e5428c828d04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38867d8c71272f70cc7195cc2e65a1830b0cd63a88738ee23bc1cc04d4a5ee90e28ecdfb511f442655708841a1cb747919c4adec8596a194daee63cfb4f8e241
|
7
|
+
data.tar.gz: dc096ab206cc711c66203426303b5e44aff321dbcf849a7579da4ba91db842b1fc320c88206de44858a3aaa3ee9527a2bb6a3b823f3fe598097ac89102276c10
|
@@ -3,6 +3,22 @@ module Inch
|
|
3
3
|
module Provider
|
4
4
|
module YARD
|
5
5
|
class Docstring
|
6
|
+
# Returns +true+ if the docstring was generated by YARD
|
7
|
+
#
|
8
|
+
# @param docstring [Docstring,String]
|
9
|
+
# @param method [MethodObject]
|
10
|
+
def self.implicit?(docstring, method)
|
11
|
+
name = method.name
|
12
|
+
if method.getter?
|
13
|
+
docstring.to_s == "Returns the value of attribute #{name}"
|
14
|
+
elsif method.setter?
|
15
|
+
basename = name.to_s.gsub(/(\=)$/, '')
|
16
|
+
docstring.to_s == "Sets the attribute #{basename}"
|
17
|
+
else
|
18
|
+
false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
6
22
|
def initialize(text)
|
7
23
|
@text = text.to_s
|
8
24
|
end
|
@@ -64,12 +64,12 @@ module Inch
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def return_mentioned?
|
67
|
-
!return_tags.empty? || docstring.mentions_return?
|
67
|
+
!return_tags.empty? || docstring.mentions_return? && !implicit_docstring?
|
68
68
|
end
|
69
69
|
|
70
70
|
def return_described?
|
71
71
|
return_tags.any? { |t| !t.text.empty? } ||
|
72
|
-
docstring.describes_return?
|
72
|
+
docstring.describes_return? && !implicit_docstring?
|
73
73
|
end
|
74
74
|
|
75
75
|
def return_typed?
|
@@ -98,6 +98,11 @@ module Inch
|
|
98
98
|
|
99
99
|
private
|
100
100
|
|
101
|
+
# Returns +true+ if the docstring was generated by YARD
|
102
|
+
def implicit_docstring?
|
103
|
+
Docstring.implicit?(docstring, self)
|
104
|
+
end
|
105
|
+
|
101
106
|
def overload_tags
|
102
107
|
object.tags(:overload)
|
103
108
|
end
|
@@ -5,13 +5,14 @@ module Inch
|
|
5
5
|
module Object
|
6
6
|
# Utility class to describe (overloaded) method signatures
|
7
7
|
class MethodSignature < Struct.new(:method, :yard_tag)
|
8
|
-
attr_reader :method
|
8
|
+
attr_reader :method, :docstring
|
9
9
|
|
10
10
|
# @param method [Provider::YARD::Object::MethodObject]
|
11
11
|
# @param method [::YARD::Tags::Tag,nil] if nil, the method's normal signature is used
|
12
12
|
def initialize(method, yard_tag = nil)
|
13
13
|
@method = method
|
14
14
|
@yard_tag = yard_tag
|
15
|
+
@docstring = Provider::YARD::Docstring.new(relevant_object.docstring)
|
15
16
|
end
|
16
17
|
|
17
18
|
def all_signature_parameter_names
|
@@ -67,21 +68,9 @@ module Inch
|
|
67
68
|
end.compact.uniq
|
68
69
|
end
|
69
70
|
|
70
|
-
def docstring
|
71
|
-
@docstring ||= Docstring.new(relevant_object.docstring)
|
72
|
-
end
|
73
|
-
|
74
71
|
# Returns +true+ if the docstring was generated by YARD
|
75
72
|
def implicit_docstring?
|
76
|
-
|
77
|
-
if method.getter?
|
78
|
-
docstring.to_s == "Returns the value of attribute #{name}"
|
79
|
-
elsif method.setter?
|
80
|
-
basename = name.to_s.gsub(/(\=)$/, '')
|
81
|
-
docstring.to_s == "Sets the attribute #{basename}"
|
82
|
-
else
|
83
|
-
false
|
84
|
-
end
|
73
|
+
Docstring.implicit?(docstring, method)
|
85
74
|
end
|
86
75
|
|
87
76
|
# Returns how the given parameter is noted in the method's
|
data/lib/inch/version.rb
CHANGED
@@ -220,30 +220,40 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
220
220
|
m = @objects.find("InchTest#getter")
|
221
221
|
assert m.getter?, "should be a getter"
|
222
222
|
refute m.setter?
|
223
|
+
refute m.has_doc?
|
224
|
+
assert_equal 0, m.score
|
223
225
|
end
|
224
226
|
|
225
227
|
def test_setter
|
226
228
|
m = @objects.find("InchTest#attr_setter=")
|
227
229
|
refute m.getter?
|
228
230
|
assert m.setter?, "should be a setter"
|
231
|
+
refute m.has_doc?
|
232
|
+
assert_equal 0, m.score
|
229
233
|
end
|
230
234
|
|
231
235
|
def test_setter2
|
232
236
|
m = @objects.find("InchTest#manual_setter=")
|
233
237
|
refute m.getter?
|
234
238
|
assert m.setter?, "should be a setter"
|
239
|
+
refute m.has_doc?
|
240
|
+
assert_equal 0, m.score
|
235
241
|
end
|
236
242
|
|
237
243
|
def test_manual_getset
|
238
244
|
m = @objects.find("InchTest#manual_getset")
|
239
245
|
assert m.getter?, "should be a getter"
|
240
246
|
refute m.setter?
|
247
|
+
refute m.has_doc?
|
248
|
+
assert_equal 0, m.score
|
241
249
|
end
|
242
250
|
|
243
251
|
def test_manual_getset2
|
244
252
|
m = @objects.find("InchTest#manual_getset=")
|
245
253
|
refute m.getter?
|
246
254
|
assert m.setter?, "should be a setter"
|
255
|
+
refute m.has_doc?
|
256
|
+
assert_equal 0, m.score
|
247
257
|
end
|
248
258
|
|
249
259
|
def test_attr_getset
|
@@ -251,6 +261,7 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
251
261
|
assert m.getter?, "should be a getter"
|
252
262
|
refute m.setter?
|
253
263
|
refute m.has_doc?
|
264
|
+
assert_equal 0, m.score
|
254
265
|
end
|
255
266
|
|
256
267
|
def test_attr_getset2
|
@@ -258,6 +269,7 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
258
269
|
refute m.getter?
|
259
270
|
assert m.setter?, "should be a setter"
|
260
271
|
refute m.has_doc?
|
272
|
+
assert_equal 0, m.score
|
261
273
|
end
|
262
274
|
|
263
275
|
def test_splat_parameter_notation
|