inch 0.4.6 → 0.4.7
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/.rubocop.yml +15 -0
- data/.rubocop_todo.yml +113 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +5 -2
- data/README.md +2 -2
- data/Rakefile +2 -2
- data/bin/inch +3 -2
- data/config/defaults.rb +7 -0
- data/inch.gemspec +7 -7
- data/lib/inch.rb +9 -10
- data/lib/inch/api.rb +10 -10
- data/lib/inch/api/compare.rb +2 -2
- data/lib/inch/api/compare/code_objects.rb +2 -3
- data/lib/inch/api/compare/codebases.rb +1 -1
- data/lib/inch/api/diff.rb +6 -9
- data/lib/inch/api/options/base.rb +4 -4
- data/lib/inch/api/options/suggest.rb +1 -1
- data/lib/inch/api/stats.rb +0 -1
- data/lib/inch/api/suggest.rb +8 -9
- data/lib/inch/cli.rb +6 -6
- data/lib/inch/cli/command.rb +15 -15
- data/lib/inch/cli/command/base.rb +2 -2
- data/lib/inch/cli/command/console.rb +5 -5
- data/lib/inch/cli/command/diff.rb +7 -8
- data/lib/inch/cli/command/inspect.rb +5 -4
- data/lib/inch/cli/command/list.rb +4 -4
- data/lib/inch/cli/command/options/base.rb +8 -8
- data/lib/inch/cli/command/options/base_list.rb +9 -5
- data/lib/inch/cli/command/options/console.rb +4 -3
- data/lib/inch/cli/command/options/diff.rb +6 -4
- data/lib/inch/cli/command/options/inspect.rb +2 -2
- data/lib/inch/cli/command/options/list.rb +4 -3
- data/lib/inch/cli/command/options/show.rb +2 -2
- data/lib/inch/cli/command/options/stats.rb +2 -1
- data/lib/inch/cli/command/options/suggest.rb +6 -3
- data/lib/inch/cli/command/output/base.rb +2 -4
- data/lib/inch/cli/command/output/console.rb +4 -5
- data/lib/inch/cli/command/output/diff.rb +6 -6
- data/lib/inch/cli/command/output/inspect.rb +6 -8
- data/lib/inch/cli/command/output/list.rb +0 -1
- data/lib/inch/cli/command/output/show.rb +4 -5
- data/lib/inch/cli/command/output/stats.rb +21 -21
- data/lib/inch/cli/command/output/suggest.rb +28 -26
- data/lib/inch/cli/command/show.rb +4 -4
- data/lib/inch/cli/command/stats.rb +4 -4
- data/lib/inch/cli/command/suggest.rb +6 -6
- data/lib/inch/cli/command_parser.rb +6 -5
- data/lib/inch/cli/sparkline_helper.rb +2 -2
- data/lib/inch/cli/trace_helper.rb +1 -1
- data/lib/inch/cli/yardopts_helper.rb +4 -3
- data/lib/inch/code_object.rb +3 -3
- data/lib/inch/code_object/converter.rb +6 -8
- data/lib/inch/code_object/provider.rb +1 -1
- data/lib/inch/code_object/provider/yard.rb +10 -12
- data/lib/inch/code_object/provider/yard/docstring.rb +53 -21
- data/lib/inch/code_object/provider/yard/nodoc_helper.rb +3 -3
- data/lib/inch/code_object/provider/yard/object.rb +11 -9
- data/lib/inch/code_object/provider/yard/object/base.rb +33 -9
- data/lib/inch/code_object/provider/yard/object/class_variable_object.rb +12 -0
- data/lib/inch/code_object/provider/yard/object/method_object.rb +36 -11
- data/lib/inch/code_object/provider/yard/object/method_parameter_object.rb +2 -2
- data/lib/inch/code_object/provider/yard/object/method_signature.rb +11 -8
- data/lib/inch/code_object/provider/yard/object/namespace_object.rb +1 -4
- data/lib/inch/code_object/provider/yard/parser.rb +2 -2
- data/lib/inch/code_object/proxy.rb +10 -9
- data/lib/inch/code_object/proxy/base.rb +8 -8
- data/lib/inch/code_object/proxy/class_variable_object.rb +8 -0
- data/lib/inch/code_object/proxy/method_object.rb +3 -2
- data/lib/inch/code_object/proxy/method_parameter_object.rb +1 -1
- data/lib/inch/codebase.rb +4 -5
- data/lib/inch/codebase/objects_filter.rb +2 -4
- data/lib/inch/codebase/serializer.rb +3 -3
- data/lib/inch/config.rb +2 -2
- data/lib/inch/config/base.rb +0 -1
- data/lib/inch/config/codebase.rb +3 -3
- data/lib/inch/core_ext.rb +1 -1
- data/lib/inch/core_ext/string.rb +1 -1
- data/lib/inch/evaluation.rb +16 -15
- data/lib/inch/evaluation/grade_list.rb +2 -2
- data/lib/inch/evaluation/object_schema.rb +1 -1
- data/lib/inch/evaluation/proxy.rb +8 -7
- data/lib/inch/evaluation/proxy/base.rb +12 -7
- data/lib/inch/evaluation/proxy/class_variable_object.rb +19 -0
- data/lib/inch/evaluation/proxy/constant_object.rb +1 -1
- data/lib/inch/evaluation/proxy/method_object.rb +12 -5
- data/lib/inch/evaluation/proxy/module_object.rb +1 -1
- data/lib/inch/evaluation/proxy/namespace_object.rb +1 -1
- data/lib/inch/evaluation/role/base.rb +1 -1
- data/lib/inch/evaluation/role/class_variable.rb +55 -0
- data/lib/inch/evaluation/role/method.rb +0 -1
- data/lib/inch/evaluation/role/method_parameter.rb +2 -1
- data/lib/inch/evaluation/role/object.rb +2 -2
- data/lib/inch/rake.rb +2 -2
- data/lib/inch/rake/suggest.rb +2 -2
- data/lib/inch/utils/shell_helper.rb +1 -1
- data/lib/inch/utils/ui.rb +5 -5
- data/lib/inch/utils/weighted_list.rb +2 -3
- data/lib/inch/version.rb +1 -1
- data/test/fixtures/simple/lib/broken.rb +35 -7
- data/test/fixtures/simple/lib/broken_ruby_2_0_features.rb +7 -0
- data/test/fixtures/simple/lib/directives.rb +8 -0
- data/test/fixtures/simple/lib/foo.rb +17 -0
- data/test/integration/api/compare/codebases.rb +1 -1
- data/test/integration/cli/command/console_test.rb +5 -5
- data/test/integration/cli/command/inspect_test.rb +4 -5
- data/test/integration/cli/command/list_test.rb +3 -4
- data/test/integration/cli/command/show_test.rb +4 -4
- data/test/integration/cli/command/stats_test.rb +2 -2
- data/test/integration/cli/command/suggest_test.rb +7 -7
- data/test/integration/stats_options_test.rb +3 -3
- data/test/integration/visibility_options_test.rb +13 -13
- data/test/shared/base_list.rb +4 -3
- data/test/test_helper.rb +16 -5
- data/test/unit/api/filter_test.rb +7 -7
- data/test/unit/api/get_test.rb +1 -1
- data/test/unit/api/list_test.rb +1 -1
- data/test/unit/api/options/base_test.rb +3 -3
- data/test/unit/api/stats_test.rb +1 -1
- data/test/unit/api/suggest_test.rb +3 -3
- data/test/unit/cli/arguments_test.rb +1 -1
- data/test/unit/cli/command/base_test.rb +1 -1
- data/test/unit/cli/command/options/base_list_test.rb +2 -2
- data/test/unit/cli/command/options/base_object_test.rb +1 -1
- data/test/unit/cli/command/options/base_test.rb +1 -1
- data/test/unit/cli/command_parser_test.rb +2 -2
- data/test/unit/cli/trace_helper_test.rb +1 -1
- data/test/unit/cli/yardopts_helper_test.rb +4 -3
- data/test/unit/code_object/converter_test.rb +1 -1
- data/test/unit/code_object/provider/yard/docstring_test.rb +105 -28
- data/test/unit/code_object/provider/yard/nodoc_helper_test.rb +5 -5
- data/test/unit/code_object/provider/yard/object/method_object_test.rb +20 -10
- data/test/unit/code_object/provider/yard_test.rb +4 -4
- data/test/unit/code_object/provider_test.rb +1 -1
- data/test/unit/code_object/proxy/method_object_test.rb +366 -262
- data/test/unit/code_object/proxy_test.rb +1 -1
- data/test/unit/codebase/objects_test.rb +2 -2
- data/test/unit/codebase/proxy_test.rb +1 -1
- data/test/unit/config/codebase_test.rb +1 -1
- data/test/unit/evaluation/role/base_test.rb +1 -1
- data/test/unit/utils/ui_test.rb +4 -4
- data/test/unit/utils/weighted_list_test.rb +7 -4
- metadata +12 -2
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../test_helper")
|
2
2
|
|
3
3
|
describe ::Inch::CLI::YardoptsHelper do
|
4
4
|
before do
|
@@ -9,7 +9,7 @@ describe ::Inch::CLI::YardoptsHelper do
|
|
9
9
|
|
10
10
|
it "should run without args" do
|
11
11
|
out, err = capture_io do
|
12
|
-
@command.run
|
12
|
+
@command.run
|
13
13
|
end
|
14
14
|
refute out.empty?, "there should be some output"
|
15
15
|
assert err.empty?, "there should be no errors"
|
@@ -56,7 +56,8 @@ describe ::Inch::CLI::YardoptsHelper do
|
|
56
56
|
end
|
57
57
|
refute out.empty?, "there should be some output"
|
58
58
|
assert_match /\bUsage\b.+list/, out
|
59
|
-
#assert_match /\b\-\-\[no\-\]yardopts\b/, out,
|
59
|
+
# assert_match /\b\-\-\[no\-\]yardopts\b/, out,
|
60
|
+
# "--[no-]yardopts should be mentioned"
|
60
61
|
assert err.empty?, "there should be no errors"
|
61
62
|
end
|
62
63
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../../test_helper")
|
2
2
|
|
3
3
|
describe ::Inch::CodeObject::Provider::YARD::Docstring do
|
4
4
|
let(:described_class) { ::Inch::CodeObject::Provider::YARD::Docstring }
|
@@ -7,9 +7,8 @@ describe ::Inch::CodeObject::Provider::YARD::Docstring do
|
|
7
7
|
# loose TomDoc compatibility
|
8
8
|
#
|
9
9
|
|
10
|
-
|
11
10
|
it "should notice things in tomdoc style docs" do
|
12
|
-
text = <<-DOC
|
11
|
+
text = <<-DOC
|
13
12
|
Internal: Detects the Language of the blob.
|
14
13
|
|
15
14
|
param1 - String filename
|
@@ -19,7 +18,7 @@ param2 - String blob data. A block also maybe passed in for lazy
|
|
19
18
|
param3 - Optional String mode (defaults to nil)
|
20
19
|
|
21
20
|
Returns Language or nil.
|
22
|
-
DOC
|
21
|
+
DOC
|
23
22
|
docstring = described_class.new(text)
|
24
23
|
assert docstring.describes_internal_api?
|
25
24
|
assert docstring.mentions_parameter?(:param1)
|
@@ -34,7 +33,7 @@ DOC
|
|
34
33
|
end
|
35
34
|
|
36
35
|
it "should notice things in tomdoc style docs 2" do
|
37
|
-
text = <<-DOC
|
36
|
+
text = <<-DOC
|
38
37
|
Public: Look up Language by one of its aliases.
|
39
38
|
|
40
39
|
param1 - A String alias of the Language
|
@@ -45,7 +44,7 @@ Examples
|
|
45
44
|
# => #<Language name="C++">
|
46
45
|
|
47
46
|
Returns the Lexer or nil if none was found.
|
48
|
-
DOC
|
47
|
+
DOC
|
49
48
|
docstring = described_class.new(text)
|
50
49
|
assert docstring.mentions_parameter?(:param1)
|
51
50
|
assert docstring.describes_parameter?(:param1)
|
@@ -56,8 +55,33 @@ DOC
|
|
56
55
|
assert docstring.describes_return?
|
57
56
|
end
|
58
57
|
|
58
|
+
it "should notice multi-line returns in tomdoc style docs" do
|
59
|
+
text = <<-DOC
|
60
|
+
Public: Look up Language by one of its aliases.
|
61
|
+
|
62
|
+
Returns the Lexer or nil
|
63
|
+
if none was found.
|
64
|
+
DOC
|
65
|
+
docstring = described_class.new(text)
|
66
|
+
assert docstring.mentions_return?
|
67
|
+
assert docstring.describes_return?
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should notice multi-line returns in tomdoc style docs 2" do
|
71
|
+
text = <<-DOC
|
72
|
+
Public: Look up Language by one of its aliases.
|
73
|
+
|
74
|
+
Returns the Lexer or nil
|
75
|
+
if none
|
76
|
+
was found.
|
77
|
+
DOC
|
78
|
+
docstring = described_class.new(text)
|
79
|
+
assert docstring.mentions_return?
|
80
|
+
assert docstring.describes_return?
|
81
|
+
end
|
82
|
+
|
59
83
|
it "should notice things in tomdoc style docs 3" do
|
60
|
-
text = <<-DOC
|
84
|
+
text = <<-DOC
|
61
85
|
Public: Look up Language by one of its aliases.
|
62
86
|
|
63
87
|
param1 - A String alias of the Language
|
@@ -68,7 +92,7 @@ Examples
|
|
68
92
|
# => #<Language name="C++">
|
69
93
|
|
70
94
|
Returns the Lexer or nil if none was found.
|
71
|
-
DOC
|
95
|
+
DOC
|
72
96
|
docstring = described_class.new(text)
|
73
97
|
assert docstring.mentions_parameter?(:param1)
|
74
98
|
assert docstring.describes_parameter?(:param1)
|
@@ -79,42 +103,79 @@ DOC
|
|
79
103
|
assert docstring.describes_return?
|
80
104
|
end
|
81
105
|
|
106
|
+
it "should understand 'Returns nil.'" do
|
107
|
+
text = <<-DOC
|
108
|
+
[...]
|
109
|
+
Returns nil.
|
110
|
+
DOC
|
111
|
+
docstring = described_class.new(text)
|
112
|
+
assert docstring.describes_return?
|
113
|
+
end
|
114
|
+
|
115
|
+
it "should understand 'Returns nil.' without fullstop and in lowercase" do
|
116
|
+
text = <<-DOC
|
117
|
+
[...]
|
118
|
+
returns nil
|
119
|
+
DOC
|
120
|
+
docstring = described_class.new(text)
|
121
|
+
assert docstring.describes_return?
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should understand 'Returns nothing.'" do
|
125
|
+
text = <<-DOC
|
126
|
+
[...]
|
127
|
+
Returns nothing.
|
128
|
+
DOC
|
129
|
+
docstring = described_class.new(text)
|
130
|
+
assert docstring.describes_return?
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should understand 'Returns nothing.' without fullstop and in lowercase" do
|
134
|
+
text = <<-DOC
|
135
|
+
[...]
|
136
|
+
returns nothing
|
137
|
+
DOC
|
138
|
+
docstring = described_class.new(text)
|
139
|
+
assert docstring.describes_return?
|
140
|
+
end
|
141
|
+
|
142
|
+
it "should understand 'Returns ...' with a visibility modifier in front of it" do
|
143
|
+
text = "Public: Returns the Integer color."
|
144
|
+
docstring = described_class.new(text)
|
145
|
+
assert docstring.mentions_return?
|
146
|
+
assert docstring.describes_return?
|
147
|
+
end
|
82
148
|
|
83
149
|
#
|
84
150
|
# PARAMETER MENTIONS
|
85
151
|
#
|
86
152
|
|
87
|
-
|
88
153
|
it "should work 2" do
|
89
|
-
text = <<-DOC
|
154
|
+
text = <<-DOC
|
90
155
|
Just because format_html is mentioned here, does not mean
|
91
156
|
the first parameter is mentioned.
|
92
|
-
DOC
|
157
|
+
DOC
|
93
158
|
docstring = described_class.new(text)
|
94
159
|
refute docstring.mentions_parameter?(:format)
|
95
160
|
refute docstring.contains_code_example?
|
96
161
|
end
|
97
162
|
|
98
|
-
|
99
|
-
|
100
|
-
text = <<-DOC
|
163
|
+
it "should work 2 if correct" do
|
164
|
+
text = <<-DOC
|
101
165
|
Just because format is mentioned here, does not mean
|
102
166
|
the first parameter is meant.
|
103
|
-
DOC
|
167
|
+
DOC
|
104
168
|
docstring = described_class.new(text)
|
105
169
|
refute docstring.mentions_parameter?(:format)
|
106
170
|
refute docstring.contains_code_example?
|
107
171
|
end
|
108
172
|
|
109
|
-
|
110
|
-
|
111
173
|
#
|
112
174
|
# CODE EXAMPLES
|
113
175
|
#
|
114
176
|
|
115
|
-
|
116
177
|
it "should work 3" do
|
117
|
-
text = <<-DOC
|
178
|
+
text = <<-DOC
|
118
179
|
An example of a method using RDoc rather than YARD.
|
119
180
|
|
120
181
|
== Parameters:
|
@@ -123,13 +184,13 @@ param1::
|
|
123
184
|
|
124
185
|
== Returns:
|
125
186
|
A string in the specified format.
|
126
|
-
DOC
|
187
|
+
DOC
|
127
188
|
docstring = described_class.new(text)
|
128
189
|
refute docstring.contains_code_example?
|
129
190
|
end
|
130
191
|
|
131
192
|
it "should work with code example" do
|
132
|
-
text = <<-DOC
|
193
|
+
text = <<-DOC
|
133
194
|
Another example.
|
134
195
|
|
135
196
|
method_with_code_example() # => some value
|
@@ -138,7 +199,7 @@ Params:
|
|
138
199
|
+param1+:: param1 line string to be executed by the system
|
139
200
|
+param2+:: +Proc+ object that takes a pipe object as first and only param (may be nil)
|
140
201
|
+param3+:: +Proc+ object that takes a pipe object as first and only param (may be nil)
|
141
|
-
DOC
|
202
|
+
DOC
|
142
203
|
docstring = described_class.new(text)
|
143
204
|
assert docstring.contains_code_example?
|
144
205
|
assert docstring.mentions_parameter?(:param1)
|
@@ -149,21 +210,37 @@ DOC
|
|
149
210
|
assert docstring.describes_parameter?(:param3)
|
150
211
|
end
|
151
212
|
|
213
|
+
it "should recognize several parameter notations" do
|
214
|
+
text = <<-DOC
|
215
|
+
Params:
|
216
|
+
+param1<String>+:: param1 line string to be executed by the system
|
217
|
+
+param2<String,nil>+:: +Proc+ object that takes a pipe object as first and only param (may be nil)
|
218
|
+
+param3<String|Class>+:: +Proc+ object that takes a pipe object as first and only param (may be nil)
|
219
|
+
DOC
|
220
|
+
docstring = described_class.new(text)
|
221
|
+
assert docstring.mentions_parameter?(:param1), "should mention param1"
|
222
|
+
assert docstring.mentions_parameter?(:param2), "should mention param2"
|
223
|
+
assert docstring.mentions_parameter?(:param3), "should mention param3"
|
224
|
+
assert docstring.describes_parameter?(:param1), "should describe param1"
|
225
|
+
assert docstring.describes_parameter?(:param2), "should describe param2"
|
226
|
+
assert docstring.describes_parameter?(:param3), "should describe param3"
|
227
|
+
end
|
228
|
+
|
152
229
|
it "should work with code example 2" do
|
153
|
-
text = <<-DOC
|
230
|
+
text = <<-DOC
|
154
231
|
Just because format_html is mentioned here, does not mean
|
155
232
|
the first parameter is mentioned.
|
156
233
|
|
157
234
|
method_with_code_example() # => some value
|
158
235
|
method_with_missing_param_doc(param1, param2, param3)
|
159
|
-
DOC
|
236
|
+
DOC
|
160
237
|
docstring = described_class.new(text)
|
161
238
|
assert docstring.contains_code_example?
|
162
239
|
assert_equal 1, docstring.code_examples.size
|
163
240
|
end
|
164
241
|
|
165
242
|
it "should work with code example 3" do
|
166
|
-
text = <<-DOC
|
243
|
+
text = <<-DOC
|
167
244
|
An example of a method using RDoc rather than YARD.
|
168
245
|
|
169
246
|
method_with_code_example() # => some value
|
@@ -174,7 +251,7 @@ param1::
|
|
174
251
|
|
175
252
|
== Returns:
|
176
253
|
A string in the specified format.
|
177
|
-
DOC
|
254
|
+
DOC
|
178
255
|
docstring = described_class.new(text)
|
179
256
|
assert docstring.contains_code_example?
|
180
257
|
assert_equal 1, docstring.code_examples.size
|
@@ -183,7 +260,7 @@ DOC
|
|
183
260
|
end
|
184
261
|
|
185
262
|
it "should work with multiple code examples" do
|
186
|
-
text = <<-DOC
|
263
|
+
text = <<-DOC
|
187
264
|
An example of a method using RDoc rather than YARD.
|
188
265
|
|
189
266
|
method_with_code_example() # => some value
|
@@ -199,7 +276,7 @@ param1::
|
|
199
276
|
|
200
277
|
== Returns:
|
201
278
|
A string in the specified format.
|
202
|
-
DOC
|
279
|
+
DOC
|
203
280
|
docstring = described_class.new(text)
|
204
281
|
assert docstring.contains_code_example?
|
205
282
|
assert_equal 2, docstring.code_examples.size
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../../test_helper")
|
2
2
|
|
3
3
|
describe ::Inch::CodeObject::Provider::YARD::NodocHelper do
|
4
4
|
before do
|
@@ -17,9 +17,9 @@ describe ::Inch::CodeObject::Provider::YARD::NodocHelper do
|
|
17
17
|
"Foo::HiddenClass::EvenMoreHiddenClass",
|
18
18
|
"Foo::HiddenClass::EvenMoreHiddenClass#method_with_implicit_nodoc",
|
19
19
|
"Foo::HiddenClassViaTag",
|
20
|
-
"Foo::HiddenClassViaTag#some_value"
|
20
|
+
"Foo::HiddenClassViaTag#some_value"
|
21
21
|
].each do |query|
|
22
|
-
m = @objects.
|
22
|
+
m = @objects.find { |o| o.fullname == query }
|
23
23
|
assert m.nodoc?, "nodoc? should return true for #{query}"
|
24
24
|
end
|
25
25
|
end
|
@@ -30,9 +30,9 @@ describe ::Inch::CodeObject::Provider::YARD::NodocHelper do
|
|
30
30
|
"Foo::Qux::Quux::PUBLIC_VALUE",
|
31
31
|
"Foo::Qux::DOCCED_VALUE",
|
32
32
|
"Foo::HiddenClass::EvenMoreHiddenClass::SuddenlyVisibleClass",
|
33
|
-
"Foo::HiddenClass::EvenMoreHiddenClass::SuddenlyVisibleClass#method_with_implicit_doc"
|
33
|
+
"Foo::HiddenClass::EvenMoreHiddenClass::SuddenlyVisibleClass#method_with_implicit_doc"
|
34
34
|
].each do |query|
|
35
|
-
m = @objects.
|
35
|
+
m = @objects.find { |o| o.fullname == query }
|
36
36
|
refute m.nodoc?, "nodoc? should return false for #{query}"
|
37
37
|
end
|
38
38
|
end
|
@@ -1,14 +1,17 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../../../test_helper")
|
2
2
|
|
3
3
|
describe ::Inch::CodeObject::Provider::YARD::Parser do
|
4
4
|
before do
|
5
5
|
@config = Inch::Config.codebase
|
6
|
-
@parser = ::Inch::CodeObject::Provider::YARD::Parser.parse(
|
6
|
+
@parser = ::Inch::CodeObject::Provider::YARD::Parser.parse(
|
7
|
+
fixture_path(:simple), @config)
|
7
8
|
@objects = @parser.objects
|
8
9
|
end
|
9
10
|
|
10
11
|
it "should work for Overloading#params_also_in_overloads" do
|
11
|
-
m = @objects.
|
12
|
+
m = @objects.find do |o|
|
13
|
+
o.fullname == "Overloading#params_also_in_overloads"
|
14
|
+
end
|
12
15
|
|
13
16
|
assert m.has_code_example?
|
14
17
|
|
@@ -16,7 +19,8 @@ describe ::Inch::CodeObject::Provider::YARD::Parser do
|
|
16
19
|
assert_equal 2, m.parameters.size # at this moment, this counts all parameters in all overloaded signatures
|
17
20
|
|
18
21
|
signature = m.signatures[0]
|
19
|
-
assert_equal "params_also_in_overloads(user_options = {})",
|
22
|
+
assert_equal "params_also_in_overloads(user_options = {})",
|
23
|
+
signature.signature
|
20
24
|
assert_equal 1, signature.parameters.size
|
21
25
|
refute signature.parameter(:user_options).nil?
|
22
26
|
assert signature.has_code_example?
|
@@ -24,7 +28,8 @@ describe ::Inch::CodeObject::Provider::YARD::Parser do
|
|
24
28
|
|
25
29
|
signature = m.signatures[1]
|
26
30
|
assert_equal "params_also_in_overloads()", signature.signature
|
27
|
-
assert signature.parameters.empty?,
|
31
|
+
assert signature.parameters.empty?,
|
32
|
+
"Should have been empty: #{signature.parameters.inspect}"
|
28
33
|
assert signature.has_code_example?
|
29
34
|
refute signature.has_doc?
|
30
35
|
|
@@ -37,7 +42,9 @@ describe ::Inch::CodeObject::Provider::YARD::Parser do
|
|
37
42
|
end
|
38
43
|
|
39
44
|
it "should work for Overloading#params_only_in_overloads" do
|
40
|
-
m = @objects.
|
45
|
+
m = @objects.find do |o|
|
46
|
+
o.fullname == "Overloading#params_only_in_overloads"
|
47
|
+
end
|
41
48
|
|
42
49
|
assert m.has_code_example?
|
43
50
|
|
@@ -46,7 +53,8 @@ describe ::Inch::CodeObject::Provider::YARD::Parser do
|
|
46
53
|
|
47
54
|
signature = m.signatures[0]
|
48
55
|
assert_equal "params_only_in_overloads()", signature.signature
|
49
|
-
assert signature.parameters.empty?,
|
56
|
+
assert signature.parameters.empty?,
|
57
|
+
"Should have been empty: #{signature.parameters.inspect}"
|
50
58
|
assert signature.has_code_example?
|
51
59
|
refute signature.has_doc?
|
52
60
|
|
@@ -62,17 +70,19 @@ describe ::Inch::CodeObject::Provider::YARD::Parser do
|
|
62
70
|
assert_equal 1, signature.parameters.size
|
63
71
|
refute signature.parameter(:user_options).nil?
|
64
72
|
assert signature.has_code_example?
|
65
|
-
#assert signature.has_doc?
|
73
|
+
# assert signature.has_doc?
|
66
74
|
end
|
67
75
|
|
68
76
|
it "should work" do
|
69
|
-
m = @objects.
|
77
|
+
m = @objects.find do |o|
|
78
|
+
o.fullname == "Foo::Bar#method_with_unstructured_doc"
|
79
|
+
end
|
70
80
|
assert_equal 1, m.signatures.size
|
71
81
|
assert_equal 1, m.parameters.size
|
72
82
|
end
|
73
83
|
|
74
84
|
it "should work 2" do
|
75
|
-
m = @objects.
|
85
|
+
m = @objects.find { |o| o.fullname == "Foo#method_with_splat_parameter" }
|
76
86
|
assert_equal 1, m.signatures.size
|
77
87
|
assert_equal 1, m.parameters.size
|
78
88
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../test_helper")
|
2
2
|
|
3
3
|
describe ::Inch::CodeObject::Provider::YARD do
|
4
4
|
let(:described_class) { ::Inch::CodeObject::Provider::YARD }
|
@@ -12,14 +12,14 @@ describe ::Inch::CodeObject::Provider::YARD do
|
|
12
12
|
fullname = "Foo#b"
|
13
13
|
|
14
14
|
provider1 = described_class.parse(fixture_path(:diff1))
|
15
|
-
object1 = provider1.objects.
|
15
|
+
object1 = provider1.objects.find { |o| o.fullname == fullname }
|
16
16
|
|
17
17
|
provider2 = described_class.parse(fixture_path(:diff2))
|
18
|
-
object2 = provider2.objects.
|
18
|
+
object2 = provider2.objects.find { |o| o.fullname == fullname }
|
19
19
|
|
20
20
|
refute object1.nil?
|
21
21
|
refute object2.nil?
|
22
22
|
assert object1.object_id != object2.object_id
|
23
23
|
end
|
24
24
|
|
25
|
-
end
|
25
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../test_helper")
|
2
2
|
|
3
3
|
describe ::Inch::CodeObject::Proxy::MethodObject do
|
4
4
|
before do
|
@@ -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,287 +75,383 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
67
75
|
assert p.mentioned?
|
68
76
|
p = m.parameter(:param2)
|
69
77
|
assert p.mentioned?
|
78
|
+
|
79
|
+
# not mentioned
|
70
80
|
p = m.parameter(:param3)
|
71
81
|
refute p.mentioned?
|
72
82
|
|
73
83
|
assert m.score
|
74
84
|
end
|
75
85
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
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?
|
81
93
|
|
82
|
-
|
83
|
-
|
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
|
89
|
-
p = m.parameter(:param3)
|
90
|
-
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
|
94
|
+
assert m.score
|
95
|
+
end
|
95
96
|
|
96
|
-
|
97
|
-
|
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?
|
98
102
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
103
|
+
assert m.score
|
104
|
+
end
|
105
|
+
|
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?
|
104
113
|
|
105
|
-
|
106
|
-
m.parameters.each do |param|
|
107
|
-
assert param.mentioned?
|
108
|
-
assert param.typed?
|
109
|
-
assert param.described?
|
110
|
-
refute param.wrongly_mentioned?
|
114
|
+
assert m.score
|
111
115
|
end
|
112
116
|
|
113
|
-
|
114
|
-
|
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
|
115
131
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
132
|
+
it "should handle yet other RDoc styles" do
|
133
|
+
m = @objects.find("Foo::Bar#method_with_yet_another_rdoc_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
|
+
p = m.parameter(:param2)
|
139
|
+
assert p.mentioned? # mentioned in docs, correctly
|
121
140
|
|
122
|
-
|
123
|
-
|
141
|
+
assert m.score
|
142
|
+
end
|
124
143
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
144
|
+
it "should handle unstructured doc styles" do
|
145
|
+
m = @objects.find("Foo::Bar#method_with_unstructured_doc")
|
146
|
+
assert m.has_doc?
|
147
|
+
assert m.has_parameters?
|
148
|
+
p = m.parameter(:param1)
|
149
|
+
assert p.mentioned? # mentioned in docs, correctly
|
150
|
+
refute m.return_mentioned?
|
130
151
|
|
131
|
-
|
132
|
-
|
152
|
+
assert m.score
|
153
|
+
end
|
133
154
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
155
|
+
it "should handle unstructured doc styles with an undocumented param" do
|
156
|
+
m = @objects.find("Foo::Bar#method_with_unstructured_doc_missing_params")
|
157
|
+
assert m.has_doc?
|
158
|
+
assert m.has_parameters?
|
159
|
+
p = m.parameter(:format)
|
160
|
+
refute p.mentioned? # mentioned in docs, correctly
|
161
|
+
refute m.return_mentioned?
|
139
162
|
|
140
|
-
|
141
|
-
|
163
|
+
assert m.score
|
164
|
+
end
|
142
165
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
assert p.mentioned? # mentioned in docs, correctly
|
149
|
-
refute m.return_mentioned?
|
166
|
+
it "should handle methods (without parameters) that have only a docstring (text comment)" do
|
167
|
+
m = @objects.find("Foo::Bar#method_without_params_or_return_type")
|
168
|
+
assert m.has_doc?
|
169
|
+
refute m.has_parameters?
|
170
|
+
refute m.return_mentioned?
|
150
171
|
|
151
|
-
|
172
|
+
assert m.score
|
173
|
+
end
|
152
174
|
end
|
153
175
|
|
154
|
-
|
155
|
-
m = @objects.find("Foo::Bar#method_with_other_rdoc_doc")
|
156
|
-
assert m.has_doc?
|
157
|
-
assert m.has_parameters?
|
158
|
-
p = m.parameter(:param1)
|
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?
|
176
|
+
describe "Getter/Setter Handling" do
|
165
177
|
|
166
|
-
|
167
|
-
|
178
|
+
it "should recognize a getter method" do
|
179
|
+
m = @objects.find("InchTest#getter")
|
180
|
+
assert m.getter?, "should be a getter"
|
181
|
+
refute m.setter?
|
182
|
+
refute m.has_doc?
|
183
|
+
assert_equal 0, m.score
|
184
|
+
end
|
168
185
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
186
|
+
it "should recognize a setter method" do
|
187
|
+
m = @objects.find("InchTest#attr_setter=")
|
188
|
+
refute m.getter?
|
189
|
+
assert m.setter?, "should be a setter"
|
190
|
+
refute m.has_doc?
|
191
|
+
assert_equal 0, m.score
|
192
|
+
end
|
176
193
|
|
177
|
-
|
178
|
-
|
194
|
+
it "should recognize a manually defined setter method" do
|
195
|
+
m = @objects.find("InchTest#manual_setter=")
|
196
|
+
refute m.getter?
|
197
|
+
assert m.setter?, "should be a setter"
|
198
|
+
refute m.has_doc?
|
199
|
+
assert_equal 0, m.score
|
200
|
+
end
|
179
201
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
202
|
+
it "should recognize a getter in a manually defined getter/setter pair" do
|
203
|
+
m = @objects.find("InchTest#manual_getset")
|
204
|
+
assert m.getter?, "should be a getter"
|
205
|
+
refute m.setter?
|
206
|
+
refute m.has_doc?
|
207
|
+
assert_equal 0, m.score
|
208
|
+
end
|
187
209
|
|
188
|
-
|
189
|
-
|
210
|
+
it "should recognize a setter in a manually defined getter/setter pair" do
|
211
|
+
m = @objects.find("InchTest#manual_getset=")
|
212
|
+
refute m.getter?
|
213
|
+
assert m.setter?, "should be a setter"
|
214
|
+
refute m.has_doc?
|
215
|
+
assert_equal 0, m.score
|
216
|
+
end
|
190
217
|
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
218
|
+
it "should recognize a getter in a getter/setter pair defined via attr_accessor" do
|
219
|
+
m = @objects.find("InchTest#attr_getset")
|
220
|
+
assert m.getter?, "should be a getter"
|
221
|
+
refute m.setter?
|
222
|
+
refute m.has_doc?
|
223
|
+
assert_equal 0, m.score
|
224
|
+
end
|
195
225
|
|
196
|
-
|
197
|
-
|
226
|
+
it "should recognize a setter in a getter/setter pair defined via attr_accessor" do
|
227
|
+
m = @objects.find("InchTest#attr_getset=")
|
228
|
+
refute m.getter?
|
229
|
+
assert m.setter?, "should be a setter"
|
230
|
+
refute m.has_doc?
|
231
|
+
assert_equal 0, m.score
|
232
|
+
end
|
198
233
|
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
234
|
+
it "should recognize a getter in a getter/setter pair defined via Struct" do
|
235
|
+
m = @objects.find("InchTest::StructGetSet#struct_getset")
|
236
|
+
assert m.getter?, "should be a getter"
|
237
|
+
refute m.setter?
|
238
|
+
refute m.has_doc?
|
239
|
+
assert_equal 0, m.score
|
240
|
+
end
|
203
241
|
|
204
|
-
|
205
|
-
|
206
|
-
|
242
|
+
it "should recognize a setter in a getter/setter pair defined via Struct" do
|
243
|
+
m = @objects.find("InchTest::StructGetSet#struct_getset=")
|
244
|
+
refute m.getter?
|
245
|
+
assert m.setter?, "should be a setter"
|
246
|
+
refute m.has_doc?
|
247
|
+
assert_equal 0, m.score
|
248
|
+
end
|
207
249
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
250
|
+
it "should recognize docs on a getter in a getter/setter pair defined via attr_accessor" do
|
251
|
+
m = @objects.find("Attributes#username")
|
252
|
+
refute_equal 0, m.score
|
253
|
+
refute m.undocumented?
|
254
|
+
end
|
212
255
|
|
213
|
-
|
214
|
-
|
256
|
+
it "should recognize docs on a setter in a getter/setter pair defined via attr_accessor" do
|
257
|
+
m = @objects.find("Attributes#username=")
|
258
|
+
refute_equal 0, m.score
|
259
|
+
refute m.undocumented?
|
260
|
+
end
|
215
261
|
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
262
|
+
it "should recognize splat parameter notation" do
|
263
|
+
# it should assign the same score whether the parameter is
|
264
|
+
# described with or without the splat (*) operator
|
265
|
+
m1 = @objects.find("Foo#method_with_splat_parameter")
|
266
|
+
m2 = @objects.find("Foo#method_with_splat_parameter2")
|
267
|
+
assert_equal 1, m1.parameters.size
|
268
|
+
assert_equal 1, m2.parameters.size
|
269
|
+
assert_equal m1.score, m2.score
|
270
|
+
end
|
224
271
|
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
assert_equal 0, m.score
|
272
|
+
it "should recognize alias methods and aliased methods" do
|
273
|
+
m1 = @objects.find("InchTest#_aliased_method")
|
274
|
+
m2 = @objects.find("InchTest#_alias_method")
|
275
|
+
assert_equal m1.score, m2.score
|
276
|
+
end
|
231
277
|
end
|
232
278
|
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
279
|
+
describe "YARDs @!attribute directive on a class" do
|
280
|
+
#
|
281
|
+
it "should work as a reader" do
|
282
|
+
m = @objects.find("Attributes#email")
|
283
|
+
refute_equal 0, m.score
|
284
|
+
refute m.undocumented?
|
285
|
+
end
|
240
286
|
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
287
|
+
it "should work as a writer" do
|
288
|
+
m = @objects.find("Attributes#email=")
|
289
|
+
refute_equal 0, m.score
|
290
|
+
# refute m.undocumented?
|
291
|
+
# NOTE: this is undocumented since there is no original_docstring
|
292
|
+
end
|
247
293
|
end
|
248
294
|
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
295
|
+
describe "YARDs @overload tag on methods" do
|
296
|
+
#
|
297
|
+
it "should work with basic overloading" do
|
298
|
+
list = []
|
299
|
+
list << @objects.find("Overloading#rgb")
|
300
|
+
list << @objects.find("Overloading#rgba")
|
301
|
+
list << @objects.find("Overloading#change_color")
|
302
|
+
list << @objects.find("Overloading#mix")
|
303
|
+
list << @objects.find("Overloading#hooks")
|
304
|
+
list << @objects.find("Overloading#identifiers")
|
305
|
+
list << @objects.find("Overloading#params_only_in_overloads")
|
306
|
+
list.each do |m|
|
307
|
+
assert_equal 100, m.score, "#{m.fullname} did not get 100"
|
308
|
+
end
|
309
|
+
end
|
256
310
|
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
refute m.has_doc?
|
262
|
-
assert_equal 0, m.score
|
263
|
-
end
|
311
|
+
it "should work with a malformed @param tag in an overload tag" do
|
312
|
+
m = @objects.find("Overloading#missing_param_names")
|
313
|
+
refute m.has_doc? # it may be mentioned in the docs, but it's malformed.
|
314
|
+
end
|
264
315
|
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
316
|
+
it "should work with several overload tags on the same method" do
|
317
|
+
skip
|
318
|
+
m = @objects.find("Overloading#many_overloads")
|
319
|
+
assert_equal 1, count_roles(
|
320
|
+
m, Inch::Evaluation::Role::Method::WithoutReturnDescription)
|
321
|
+
assert_equal 1, count_roles(
|
322
|
+
m, Inch::Evaluation::Role::Method::WithoutReturnType)
|
323
|
+
assert_equal 1, count_roles(
|
324
|
+
m, Inch::Evaluation::Role::MethodParameter::WithoutMention, "block")
|
325
|
+
end
|
272
326
|
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
327
|
+
it "should work if @param tags are only present in the @overload tags, but not on the actual method" do
|
328
|
+
m = @objects.find("Overloading#params_only_in_overloads")
|
329
|
+
unexpected_roles = [
|
330
|
+
Inch::Evaluation::Role::Object::WithoutCodeExample,
|
331
|
+
Inch::Evaluation::Role::MethodParameter::WithoutMention,
|
332
|
+
Inch::Evaluation::Role::MethodParameter::WithoutType
|
333
|
+
]
|
334
|
+
assert_roles m, [], unexpected_roles
|
335
|
+
end
|
280
336
|
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
337
|
+
it "should work with one param missing in the overload tag" do
|
338
|
+
m = @objects.find("Overloading#one_param_missing_in_overload")
|
339
|
+
unexpected_roles = [
|
340
|
+
Inch::Evaluation::Role::Object::WithoutCodeExample
|
341
|
+
]
|
342
|
+
expected_roles = [
|
343
|
+
Inch::Evaluation::Role::MethodParameter::WithoutMention,
|
344
|
+
Inch::Evaluation::Role::MethodParameter::WithoutType
|
345
|
+
]
|
346
|
+
assert_roles m, expected_roles, unexpected_roles
|
347
|
+
end
|
287
348
|
end
|
288
349
|
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
refute m.has_doc?
|
294
|
-
assert_equal 0, m.score
|
295
|
-
end
|
350
|
+
describe "MISC" do
|
351
|
+
#
|
352
|
+
it "should recognize named parameters in Ruby 2.1" do
|
353
|
+
skip # unless RUBY_VERSION =~ /^2/
|
296
354
|
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
assert_equal m1.score, m2.score
|
305
|
-
end
|
355
|
+
m = @objects.find("Foo#method_with_named_parameter")
|
356
|
+
unexpected_roles = [
|
357
|
+
Inch::Evaluation::Role::MethodParameter::WithoutMention,
|
358
|
+
Inch::Evaluation::Role::MethodParameter::WithoutType
|
359
|
+
]
|
360
|
+
assert_roles m, [], unexpected_roles
|
361
|
+
end
|
306
362
|
|
307
|
-
|
308
|
-
|
309
|
-
m2 = @objects.find("InchTest#_alias_method")
|
310
|
-
assert_equal m1.score, m2.score
|
311
|
-
end
|
363
|
+
it "should recognize indented parameter documentation" do
|
364
|
+
skip # YARD cannot parse this
|
312
365
|
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
list << @objects.find("Overloading#hooks")
|
320
|
-
list << @objects.find("Overloading#identifiers")
|
321
|
-
list << @objects.find("Overloading#params_only_in_overloads")
|
322
|
-
list.each do |m|
|
323
|
-
assert_equal 100, m.score, "#{m.fullname} did not get 100"
|
366
|
+
m = @objects.find("Foo#method_with_indented_param_tag")
|
367
|
+
unexpected_roles = [
|
368
|
+
Inch::Evaluation::Role::MethodParameter::WithoutMention,
|
369
|
+
Inch::Evaluation::Role::MethodParameter::WithoutType
|
370
|
+
]
|
371
|
+
assert_roles m, [], unexpected_roles
|
324
372
|
end
|
325
|
-
end
|
326
373
|
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
374
|
+
it "should recognize wrong parameter documentation" do
|
375
|
+
m = @objects.find("Foo::Bar#method_with_wrong_doc")
|
376
|
+
assert m.has_doc?
|
377
|
+
assert m.has_parameters?
|
378
|
+
assert m.return_mentioned?
|
379
|
+
|
380
|
+
assert_equal 4, m.parameters.size
|
381
|
+
p = m.parameter(:param1)
|
382
|
+
assert p.mentioned? # mentioned in docs, correctly
|
383
|
+
refute p.wrongly_mentioned?
|
384
|
+
p = m.parameter(:param2)
|
385
|
+
refute p.mentioned?
|
386
|
+
refute p.wrongly_mentioned? # not mentioned in docs at all
|
387
|
+
p = m.parameter(:param3)
|
388
|
+
refute p.mentioned?
|
389
|
+
refute p.wrongly_mentioned? # not mentioned in docs at all
|
390
|
+
|
391
|
+
p = m.parameter(:param4)
|
392
|
+
assert p.mentioned?
|
393
|
+
assert p.wrongly_mentioned? # mentioned in docs, but not present
|
394
|
+
|
395
|
+
assert m.score
|
396
|
+
end
|
331
397
|
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
398
|
+
it "should recognize fully-documented methods with parameters" do
|
399
|
+
m = @objects.find("Foo::Bar#method_with_full_doc")
|
400
|
+
assert m.has_doc?
|
401
|
+
assert m.has_parameters?
|
402
|
+
assert m.return_mentioned?
|
403
|
+
|
404
|
+
assert_equal 2, m.parameters.size
|
405
|
+
m.parameters.each do |param|
|
406
|
+
assert param.mentioned?
|
407
|
+
assert param.typed?
|
408
|
+
assert param.described?
|
409
|
+
refute param.wrongly_mentioned?
|
410
|
+
end
|
411
|
+
|
412
|
+
assert_equal 100, m.score
|
413
|
+
end
|
414
|
+
|
415
|
+
it "should recognize question mark methods" do
|
416
|
+
m = @objects.find("InchTest#question_mark_method?")
|
417
|
+
refute m.has_doc?
|
418
|
+
refute m.has_parameters?
|
419
|
+
|
420
|
+
# assert it is zero, because YARD auto-assigns tags to these
|
421
|
+
assert_equal 0, m.score
|
422
|
+
end
|
341
423
|
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
424
|
+
it "should recognize question mark methods with description" do
|
425
|
+
m = @objects.find("InchTest#question_mark_method_with_description?")
|
426
|
+
refute m.has_doc?
|
427
|
+
refute m.has_parameters?
|
428
|
+
|
429
|
+
assert m.score > 0
|
430
|
+
assert m.score >= 50 # TODO: don't use magic numbers
|
431
|
+
end
|
432
|
+
|
433
|
+
it "should recognize question mark methods with description and parameters" do
|
434
|
+
m = @objects.find("InchTest#method_with_description_and_parameters?")
|
435
|
+
refute m.has_doc?
|
436
|
+
assert m.has_parameters?
|
437
|
+
|
438
|
+
assert m.score > 0
|
439
|
+
end
|
440
|
+
|
441
|
+
it "should recognize the depth of methods" do
|
442
|
+
m = @objects.find("#root_method")
|
443
|
+
assert_equal 1, m.depth
|
444
|
+
m = @objects.find("InchTest#getter")
|
445
|
+
assert_equal 2, m.depth
|
446
|
+
m = @objects.find("Foo::Bar#method_without_doc")
|
447
|
+
assert_equal 3, m.depth
|
448
|
+
end
|
449
|
+
|
450
|
+
it "should recognize docs on class variables" do
|
451
|
+
m = @objects.find("Foo::@@class_variable")
|
452
|
+
assert m.has_doc?
|
453
|
+
refute m.undocumented?
|
454
|
+
assert_equal 100, m.score
|
455
|
+
end
|
352
456
|
end
|
353
457
|
end
|