inch 0.5.0.rc11 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -113,7 +113,7 @@ describe ::Inch::CLI::Command::Suggest do
113
113
 
114
114
  it 'should run on elixir codebase with --read-from-dump' do
115
115
  out, err = capture_io do
116
- Dir.chdir fixture_path(:elixir, :simple)
116
+ Dir.chdir fixture_path(:elixir, :inch_test)
117
117
  @command.run('--language=elixir', '--read-from-dump=all.json')
118
118
  end
119
119
  refute out.empty?, 'there should be some output'
@@ -2,46 +2,70 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../../test_helper')
2
2
 
3
3
  describe ::Inch::Language::Elixir::CodeObject::FunctionObject do
4
4
  before do
5
- @codebase = fresh_codebase(:elixir, :simple, 'all.json')
5
+ @codebase = fresh_codebase(:elixir, :inch_test, 'all.json')
6
6
  @objects = @codebase.objects
7
7
  end
8
8
 
9
9
  describe 'Scores' do
10
10
  #
11
11
  it 'should not' do
12
- m = @objects.find('InchEx.generate_docs/4')
12
+ m = @objects.find('InchTest.generate_docs/4')
13
13
  assert m.score >= 50
14
14
  end
15
15
  end
16
16
 
17
17
  it 'should recognize the relationship between modules and functions' do
18
- mod = @objects.find('InchEx')
18
+ mod = @objects.find('InchTest')
19
19
  assert mod.has_children?
20
20
  assert mod.children.size > 1
21
- fun = @objects.find('InchEx.generate_docs/4')
21
+ fun = @objects.find('InchTest.generate_docs/4')
22
22
  assert_equal mod, fun.parent
23
23
  end
24
24
 
25
25
  it 'should recognize the depth of methods' do
26
- m = @objects.find('InchEx')
26
+ m = @objects.find('InchTest')
27
27
  assert_equal 1, m.depth
28
- m = @objects.find('InchEx.Config')
28
+ m = @objects.find('InchTest.Config')
29
29
  assert_equal 2, m.depth
30
- m = @objects.find('InchEx.Docs.Formatter')
30
+ m = @objects.find('InchTest.Docs.Formatter')
31
31
  assert_equal 3, m.depth
32
- m = @objects.find('InchEx.Docs.Formatter.run/3')
32
+ m = @objects.find('InchTest.Docs.Formatter.run/3')
33
33
  assert_equal 4, m.depth
34
34
  end
35
35
 
36
- it "should parse parameters correctly" do
37
- m = @objects.find("Mix.Tasks.Inch.run/4")
38
- assert_equal 4, m.parameters.size
36
+ it 'should parse parameters correctly' do
37
+ m = @objects.find('InchTest.Docs.Formatter.run/3')
38
+ assert_equal 3, m.parameters.size
39
+ end
40
+
41
+ it 'should parse parameters correctly' do
42
+ m = @objects.find('InchTest.Functions.full_doc/2')
43
+ assert_equal 2, m.parameters.size
44
+ assert_equal 'A', m.grade.to_s
45
+ end
46
+
47
+ it 'should parse parameters correctly' do
48
+ m = @objects.find('InchTest.Functions.full_doc_second_parameter_unnamed/2')
49
+ assert_equal 2, m.parameters.size
50
+ assert_equal '', m.parameters.last.name
51
+ assert m.parameters.last.unnamed?
52
+ assert_equal 'A', m.grade.to_s
53
+ end
54
+
55
+ it 'should recognize code examples' do
56
+ m = @objects.find('InchTest.CodeExamples.single_code_example/0')
57
+ assert m.has_code_example?
58
+ refute m.has_multiple_code_examples?
59
+
60
+ m = @objects.find('InchTest.CodeExamples.multiple_code_examples/0')
61
+ assert m.has_code_example?
62
+ assert m.has_multiple_code_examples?
39
63
  end
40
64
 
41
65
  # TODO: move to own test file
42
- it "should parse parameters correctly 1" do
66
+ it 'should parse parameters correctly 1' do
43
67
  klass = ::Inch::Language::Elixir::Provider::Reader::Object::FunctionObject::FunctionSignature
44
- fn = klass.new([["args", [], nil ], ["\\\\", [], [["config", [], nil ], [[".", {line: 10 }, ["Elixir.Mix.Project", "config"] ], {line: 10 }, [] ] ] ], ["\\\\", [], [["generator", [], nil ], [[".", [], ["erlang", "make_fun"] ], {line: 10 }, ["Elixir.InchEx", "generate_docs", 4 ] ] ] ], ["\\\\", [], [["reporter", [], nil ], "Elixir.InchEx.Reporter.Local"] ] ])
68
+ fn = klass.new([['args', [], nil ], ['\\\\', [], [['config', [], nil ], [['.', {line: 10 }, ['Elixir.Mix.Project', 'config'] ], {line: 10 }, [] ] ] ], ['\\\\', [], [['generator', [], nil ], [['.', [], ['erlang', 'make_fun'] ], {line: 10 }, ['Elixir.InchTest', 'generate_docs', 4 ] ] ] ], ['\\\\', [], [['reporter', [], nil ], 'Elixir.InchTest.Reporter.Local'] ] ])
45
69
  assert_equal %w(args config generator reporter), fn.parameter_names
46
70
  end
47
71
  end
@@ -12,21 +12,21 @@ describe ::Inch::Language::Ruby::Provider::YARD::Docstring do
12
12
  Internal: Detects the Language of the blob.
13
13
 
14
14
  param1 - String filename
15
- param2 - String blob data. A block also maybe passed in for lazy
15
+ p2 - String blob data. A block also maybe passed in for lazy
16
16
  loading. This behavior is deprecated and you should always
17
17
  pass in a String.
18
- param3 - Optional String mode (defaults to nil)
18
+ prm3 - Optional String mode (defaults to nil)
19
19
 
20
20
  Returns Language or nil.
21
21
  DOC
22
22
  docstring = described_class.new(text)
23
23
  assert docstring.describes_internal_api?
24
24
  assert docstring.mentions_parameter?(:param1)
25
- assert docstring.mentions_parameter?(:param2)
26
- assert docstring.mentions_parameter?(:param3)
25
+ assert docstring.mentions_parameter?(:p2)
26
+ assert docstring.mentions_parameter?(:prm3)
27
27
  assert docstring.describes_parameter?(:param1)
28
- assert docstring.describes_parameter?(:param2)
29
- assert docstring.describes_parameter?(:param3)
28
+ assert docstring.describes_parameter?(:p2)
29
+ assert docstring.describes_parameter?(:prm3)
30
30
  refute docstring.contains_code_example?
31
31
  assert docstring.mentions_return?
32
32
  assert docstring.describes_return?
@@ -130,6 +130,33 @@ Returns nothing.
130
130
  assert docstring.describes_return?
131
131
  end
132
132
 
133
+ it "should understand 'Gets/Sets nothing.'" do
134
+ text = <<-DOC
135
+ [...]
136
+ Gets/Sets nothing.
137
+ DOC
138
+ docstring = described_class.new(text)
139
+ assert docstring.describes_return?
140
+ end
141
+
142
+ it "should understand 'Gets nothing.'" do
143
+ text = <<-DOC
144
+ [...]
145
+ Gets nothing.
146
+ DOC
147
+ docstring = described_class.new(text)
148
+ assert docstring.describes_return?
149
+ end
150
+
151
+ it "should understand 'Sets nothing.'" do
152
+ text = <<-DOC
153
+ [...]
154
+ Sets nothing.
155
+ DOC
156
+ docstring = described_class.new(text)
157
+ assert docstring.describes_return?
158
+ end
159
+
133
160
  it "should understand 'Returns nothing.' without fullstop and in lowercase" do
134
161
  text = <<-DOC
135
162
  [...]
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.rc11
4
+ version: 0.5.0
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-10-02 00:00:00.000000000 Z
11
+ date: 2014-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -307,7 +307,7 @@ files:
307
307
  - lib/inch/utils/ui.rb
308
308
  - lib/inch/utils/weighted_list.rb
309
309
  - lib/inch/version.rb
310
- - test/fixtures/elixir/simple/all.json
310
+ - test/fixtures/elixir/inch_test/all.json
311
311
  - test/fixtures/ruby/alias_cycle/lib/alias.rb
312
312
  - test/fixtures/ruby/code_examples/lib/foo.rb
313
313
  - test/fixtures/ruby/diff1/lib/diff1.rb
@@ -390,9 +390,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
390
390
  version: '0'
391
391
  required_rubygems_version: !ruby/object:Gem::Requirement
392
392
  requirements:
393
- - - ">"
393
+ - - ">="
394
394
  - !ruby/object:Gem::Version
395
- version: 1.3.1
395
+ version: '0'
396
396
  requirements: []
397
397
  rubyforge_project:
398
398
  rubygems_version: 2.2.2
@@ -400,7 +400,7 @@ signing_key:
400
400
  specification_version: 4
401
401
  summary: Documentation measurement tool for Ruby
402
402
  test_files:
403
- - test/fixtures/elixir/simple/all.json
403
+ - test/fixtures/elixir/inch_test/all.json
404
404
  - test/fixtures/ruby/alias_cycle/lib/alias.rb
405
405
  - test/fixtures/ruby/code_examples/lib/foo.rb
406
406
  - test/fixtures/ruby/diff1/lib/diff1.rb
@@ -1,530 +0,0 @@
1
- {
2
- "args": [],
3
- "language": "elixir",
4
- "objects": [
5
- {
6
- "id": "InchEx",
7
- "module": "Elixir.InchEx",
8
- "moduledoc": null,
9
- "object_type": "ModuleObject",
10
- "source": null,
11
- "type": null,
12
- "typespecs": []
13
- },
14
- {
15
- "id": "InchEx.Config",
16
- "module": "Elixir.InchEx.Config",
17
- "moduledoc": null,
18
- "object_type": "ModuleObject",
19
- "source": null,
20
- "type": null,
21
- "typespecs": []
22
- },
23
- {
24
- "id": "InchEx.Docs.Formatter",
25
- "module": "Elixir.InchEx.Docs.Formatter",
26
- "moduledoc": "Provide JSON-formatted documentation\n",
27
- "object_type": "ModuleObject",
28
- "source": null,
29
- "type": null,
30
- "typespecs": []
31
- },
32
- {
33
- "id": "InchEx.Docs.Retriever",
34
- "module": "Elixir.InchEx.Docs.Retriever",
35
- "moduledoc": "Functions to extract documentation information from modules.\n",
36
- "object_type": "ModuleObject",
37
- "source": null,
38
- "type": null,
39
- "typespecs": []
40
- },
41
- {
42
- "id": "InchEx.Docs.Retriever.Error",
43
- "module": "Elixir.InchEx.Docs.Retriever.Error",
44
- "moduledoc": null,
45
- "object_type": "ModuleObject",
46
- "source": null,
47
- "type": "exception",
48
- "typespecs": []
49
- },
50
- {
51
- "id": "InchEx.FunctionObject",
52
- "module": "Elixir.InchEx.FunctionObject",
53
- "moduledoc": null,
54
- "object_type": "ModuleObject",
55
- "source": null,
56
- "type": null,
57
- "typespecs": []
58
- },
59
- {
60
- "id": "InchEx.ModuleObject",
61
- "module": "Elixir.InchEx.ModuleObject",
62
- "moduledoc": null,
63
- "object_type": "ModuleObject",
64
- "source": null,
65
- "type": null,
66
- "typespecs": []
67
- },
68
- {
69
- "id": "InchEx.Reporter.Local",
70
- "module": "Elixir.InchEx.Reporter.Local",
71
- "moduledoc": null,
72
- "object_type": "ModuleObject",
73
- "source": null,
74
- "type": null,
75
- "typespecs": []
76
- },
77
- {
78
- "id": "InchEx.Reporter.Remote",
79
- "module": "Elixir.InchEx.Reporter.Remote",
80
- "moduledoc": null,
81
- "object_type": "ModuleObject",
82
- "source": null,
83
- "type": null,
84
- "typespecs": []
85
- },
86
- {
87
- "id": "InchEx.TypeObject",
88
- "module": "Elixir.InchEx.TypeObject",
89
- "moduledoc": null,
90
- "object_type": "ModuleObject",
91
- "source": null,
92
- "type": null,
93
- "typespecs": []
94
- },
95
- {
96
- "id": "Mix.Tasks.Inch",
97
- "module": "Elixir.Mix.Tasks.Inch",
98
- "moduledoc": null,
99
- "object_type": "ModuleObject",
100
- "source": null,
101
- "type": null,
102
- "typespecs": []
103
- },
104
- {
105
- "arity": 4,
106
- "doc": false,
107
- "id": "generate_docs/4",
108
- "module_id": "InchEx",
109
- "name": "generate_docs",
110
- "object_type": "FunctionObject",
111
- "signature": [
112
- [
113
- "project",
114
- [],
115
- null
116
- ],
117
- [
118
- "version",
119
- [],
120
- null
121
- ],
122
- [
123
- "args",
124
- [],
125
- null
126
- ],
127
- [
128
- "options",
129
- [],
130
- null
131
- ]
132
- ],
133
- "source": null,
134
- "specs": [],
135
- "type": "def"
136
- },
137
- {
138
- "arity": 3,
139
- "doc": "Generate JSON documentation for the given modules\n",
140
- "id": "run/3",
141
- "module_id": "InchEx.Docs.Formatter",
142
- "name": "run",
143
- "object_type": "FunctionObject",
144
- "signature": [
145
- [
146
- "modules",
147
- [],
148
- null
149
- ],
150
- [
151
- "args",
152
- [],
153
- null
154
- ],
155
- [
156
- "config",
157
- [],
158
- null
159
- ]
160
- ],
161
- "source": null,
162
- "specs": [],
163
- "type": "def"
164
- },
165
- {
166
- "arity": 2,
167
- "doc": "Extract documentation from all modules in the specified directory\n",
168
- "id": "docs_from_dir/2",
169
- "module_id": "InchEx.Docs.Retriever",
170
- "name": "docs_from_dir",
171
- "object_type": "FunctionObject",
172
- "signature": [
173
- [
174
- "dir",
175
- [],
176
- null
177
- ],
178
- [
179
- "config",
180
- [],
181
- null
182
- ]
183
- ],
184
- "source": null,
185
- "specs": [],
186
- "type": "def"
187
- },
188
- {
189
- "arity": 2,
190
- "doc": "Extract documentation from all modules in the specified list of files\n",
191
- "id": "docs_from_files/2",
192
- "module_id": "InchEx.Docs.Retriever",
193
- "name": "docs_from_files",
194
- "object_type": "FunctionObject",
195
- "signature": [
196
- [
197
- "files",
198
- [],
199
- null
200
- ],
201
- [
202
- "config",
203
- [],
204
- null
205
- ]
206
- ],
207
- "source": null,
208
- "specs": [],
209
- "type": "def"
210
- },
211
- {
212
- "arity": 2,
213
- "doc": "Extract documentation from all modules in the list `modules`\n",
214
- "id": "docs_from_modules/2",
215
- "module_id": "InchEx.Docs.Retriever",
216
- "name": "docs_from_modules",
217
- "object_type": "FunctionObject",
218
- "signature": [
219
- [
220
- "modules",
221
- [],
222
- null
223
- ],
224
- [
225
- "config",
226
- [],
227
- null
228
- ]
229
- ],
230
- "source": null,
231
- "specs": [],
232
- "type": "def"
233
- },
234
- {
235
- "arity": 1,
236
- "doc": "Callback implementation of `Exception.exception/1`.",
237
- "id": "exception/1",
238
- "module_id": "InchEx.Docs.Retriever.Error",
239
- "name": "exception",
240
- "object_type": "FunctionObject",
241
- "signature": [
242
- [
243
- "args",
244
- [],
245
- null
246
- ]
247
- ],
248
- "source": null,
249
- "specs": [
250
- [
251
- "::",
252
- {
253
- "line": 19
254
- },
255
- [
256
- [
257
- "exception",
258
- {
259
- "line": 19
260
- },
261
- [
262
- [
263
- [
264
- ".",
265
- {
266
- "line": 19
267
- },
268
- [
269
- "Elixir.Keyword",
270
- "t"
271
- ]
272
- ],
273
- {
274
- "line": 19
275
- },
276
- []
277
- ]
278
- ]
279
- ],
280
- [
281
- [
282
- ".",
283
- {
284
- "line": 19
285
- },
286
- [
287
- "Elixir.Exception",
288
- "t"
289
- ]
290
- ],
291
- {
292
- "line": 19
293
- },
294
- []
295
- ]
296
- ]
297
- ]
298
- ],
299
- "type": "def"
300
- },
301
- {
302
- "arity": 1,
303
- "doc": "Callback implementation of `Exception.message/1`.",
304
- "id": "message/1",
305
- "module_id": "InchEx.Docs.Retriever.Error",
306
- "name": "message",
307
- "object_type": "FunctionObject",
308
- "signature": [
309
- [
310
- "exception",
311
- [],
312
- null
313
- ]
314
- ],
315
- "source": null,
316
- "specs": [
317
- [
318
- "::",
319
- {
320
- "line": 19
321
- },
322
- [
323
- [
324
- "message",
325
- {
326
- "line": 19
327
- },
328
- [
329
- [
330
- [
331
- ".",
332
- {
333
- "line": 19
334
- },
335
- [
336
- "Elixir.Exception",
337
- "t"
338
- ]
339
- ],
340
- {
341
- "line": 19
342
- },
343
- []
344
- ]
345
- ]
346
- ],
347
- [
348
- [
349
- ".",
350
- {
351
- "line": 19
352
- },
353
- [
354
- "Elixir.String",
355
- "t"
356
- ]
357
- ],
358
- {
359
- "line": 19
360
- },
361
- []
362
- ]
363
- ]
364
- ]
365
- ],
366
- "type": "def"
367
- },
368
- {
369
- "arity": 2,
370
- "doc": " Runs inch locally, if installed. If you want to force usage of a particular\n inch installation, set INCH_PATH environment variable:\n\n export INCH_PATH=/home/rrrene/projects/inch\n\n Otherwise, InchEx will take whatever `inch` command it finds. If it does\n not find any, it sends the data to the open API at inch-ci.org to perform\n the analysis and reports the findings back.\n",
371
- "id": "run/2",
372
- "module_id": "InchEx.Reporter.Local",
373
- "name": "run",
374
- "object_type": "FunctionObject",
375
- "signature": [
376
- [
377
- "filename",
378
- [],
379
- null
380
- ],
381
- [
382
- "\\\\",
383
- [],
384
- [
385
- [
386
- "args",
387
- [],
388
- null
389
- ],
390
- []
391
- ]
392
- ]
393
- ],
394
- "source": null,
395
- "specs": [],
396
- "type": "def"
397
- },
398
- {
399
- "arity": 2,
400
- "doc": " Runs inch remotely, if already invented.\n",
401
- "id": "run/2",
402
- "module_id": "InchEx.Reporter.Remote",
403
- "name": "run",
404
- "object_type": "FunctionObject",
405
- "signature": [
406
- [
407
- "filename",
408
- [],
409
- null
410
- ],
411
- [
412
- "\\\\",
413
- [],
414
- [
415
- [
416
- "config",
417
- [],
418
- null
419
- ],
420
- [
421
- [
422
- ".",
423
- {
424
- "line": 7
425
- },
426
- [
427
- "Elixir.Mix.Project",
428
- "config"
429
- ]
430
- ],
431
- {
432
- "line": 7
433
- },
434
- []
435
- ]
436
- ]
437
- ]
438
- ],
439
- "source": null,
440
- "specs": [],
441
- "type": "def"
442
- },
443
- {
444
- "arity": 4,
445
- "doc": false,
446
- "id": "run/4",
447
- "module_id": "Mix.Tasks.Inch",
448
- "name": "run",
449
- "object_type": "FunctionObject",
450
- "signature": [
451
- [
452
- "args",
453
- [],
454
- null
455
- ],
456
- [
457
- "\\\\",
458
- [],
459
- [
460
- [
461
- "config",
462
- [],
463
- null
464
- ],
465
- [
466
- [
467
- ".",
468
- {
469
- "line": 10
470
- },
471
- [
472
- "Elixir.Mix.Project",
473
- "config"
474
- ]
475
- ],
476
- {
477
- "line": 10
478
- },
479
- []
480
- ]
481
- ]
482
- ],
483
- [
484
- "\\\\",
485
- [],
486
- [
487
- [
488
- "generator",
489
- [],
490
- null
491
- ],
492
- [
493
- [
494
- ".",
495
- [],
496
- [
497
- "erlang",
498
- "make_fun"
499
- ]
500
- ],
501
- {
502
- "line": 10
503
- },
504
- [
505
- "Elixir.InchEx",
506
- "generate_docs",
507
- 4
508
- ]
509
- ]
510
- ]
511
- ],
512
- [
513
- "\\\\",
514
- [],
515
- [
516
- [
517
- "reporter",
518
- [],
519
- null
520
- ],
521
- "Elixir.InchEx.Reporter.Local"
522
- ]
523
- ]
524
- ],
525
- "source": null,
526
- "specs": [],
527
- "type": "def"
528
- }
529
- ]
530
- }