rubocop-yardoc 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/cops.adoc ADDED
@@ -0,0 +1,823 @@
1
+ ////
2
+ Do NOT edit this file by hand directly, as it is automatically generated.
3
+
4
+ Please make any necessary changes to the cop documentation within the source files themselves.
5
+ ////
6
+
7
+ = Yardoc
8
+
9
+ [#yardocclassdescription]
10
+ == Yardoc/ClassDescription
11
+
12
+ |===
13
+ | Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
14
+
15
+ | Enabled
16
+ | Yes
17
+ | No
18
+ | -
19
+ | -
20
+ |===
21
+
22
+ Ensures all classes have YARD documentation.
23
+
24
+ Classes can be ignored by exact name, qualified name, or regexp pattern.
25
+
26
+ [#examples-yardocclassdescription]
27
+ === Examples
28
+
29
+ [source,ruby]
30
+ ----
31
+ # bad
32
+
33
+ class MyClass; end
34
+
35
+ # good
36
+
37
+ # A useful class.
38
+ class MyClass; end
39
+ ----
40
+
41
+ [#ignore_-___myclass__-_internal__-_mymodule__myotherclass___-yardocclassdescription]
42
+ ==== Ignore: `['MyClass', '/Internal/', 'MyModule::MyOtherClass']`
43
+
44
+ [source,ruby]
45
+ ----
46
+ # good (ignored with 'MyClass')
47
+
48
+ class MyClass; end
49
+
50
+ # good (ignored with /Internal/)
51
+
52
+ class MyInternalClass; end
53
+
54
+ module MyModule
55
+ # bad
56
+
57
+ class MyCustomClass; end
58
+
59
+ # good (ignored with 'MyClass')
60
+
61
+ class MyClass; end
62
+
63
+ # good (ignored with 'MyModule::MyOtherClass)
64
+
65
+ class MyOtherClass; end
66
+ end
67
+ ----
68
+
69
+ [#configurable-attributes-yardocclassdescription]
70
+ === Configurable attributes
71
+
72
+ |===
73
+ | Name | Default value | Configurable values
74
+
75
+ | Ignore
76
+ | `[]`
77
+ | Array
78
+ |===
79
+
80
+ [#yardoccolumnparams]
81
+ == Yardoc/ColumnParams
82
+
83
+ |===
84
+ | Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
85
+
86
+ | Enabled
87
+ | Yes
88
+ | Always
89
+ | -
90
+ | -
91
+ |===
92
+
93
+ Ensures @param tags are correctly formatted and aligned.
94
+
95
+ Rules enforced:
96
+ - Type must appear in square brackets directly after the param name
97
+ - All @param type columns must be aligned
98
+ - All @param description columns must be aligned
99
+ - Multiline descriptions must align with the first description character
100
+
101
+ [#examples-yardoccolumnparams]
102
+ === Examples
103
+
104
+ [source,ruby]
105
+ ----
106
+ # bad
107
+
108
+ # @param foo [String] a foo
109
+ # @param longer_name [Integer] a number
110
+ # @param bar [String] A multiline, non aligned
111
+ # description
112
+ def my_method(foo, longer_name, bar); end
113
+
114
+ # good
115
+
116
+ # @param foo [String] a foo
117
+ # @param longer_name [Integer] a number
118
+ # @param bar [String] A multiline, aligned
119
+ # description
120
+ def my_method(foo, longer_name, bar); end
121
+ ----
122
+
123
+ [#yardocconstantdescription]
124
+ == Yardoc/ConstantDescription
125
+
126
+ |===
127
+ | Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
128
+
129
+ | Enabled
130
+ | Yes
131
+ | No
132
+ | -
133
+ | -
134
+ |===
135
+
136
+ Ensures all constants have YARD documentation.
137
+
138
+ They can be ignored via `Ignore`, by providing the name or a regexp
139
+
140
+ [#examples-yardocconstantdescription]
141
+ === Examples
142
+
143
+ [source,ruby]
144
+ ----
145
+ # bad
146
+
147
+ MY_CONST = 10
148
+
149
+ # good
150
+
151
+ # That's 9 + 1
152
+ MY_CONST = 10
153
+ ----
154
+
155
+ [#ignores_-___my_const___-yardocconstantdescription]
156
+ ==== Ignores: `['MY_CONST']`
157
+
158
+ [source,ruby]
159
+ ----
160
+ # bad
161
+
162
+ A_CONST = 'something'
163
+
164
+ # good (ignored)
165
+
166
+ MY_CONST = 10
167
+
168
+ class MyClass
169
+ # good (ignored)
170
+
171
+ MY_CONST
172
+ end
173
+ ----
174
+
175
+ [#ignores_-____my_const___-yardocconstantdescription]
176
+ ==== Ignores: `['/^MY_CONST/']`
177
+
178
+ [source,ruby]
179
+ ----
180
+ # bad
181
+
182
+ A_CONST = 'something'
183
+
184
+ # good (ignored)
185
+
186
+ MY_CONST = 10
187
+
188
+ class MyClass
189
+ # bad
190
+
191
+ MY_CONST
192
+ end
193
+ ----
194
+
195
+ [#ignores_-___myclass__my_const___-yardocconstantdescription]
196
+ ==== Ignores: `['MyClass::MY_CONST']`
197
+
198
+ [source,ruby]
199
+ ----
200
+ # bad
201
+
202
+ A_CONST = 'something'
203
+
204
+ # bad
205
+
206
+ MY_CONST = 10
207
+
208
+ class MyClass
209
+ # good (ignored)
210
+
211
+ MY_CONST
212
+ end
213
+ ----
214
+
215
+ [#configurable-attributes-yardocconstantdescription]
216
+ === Configurable attributes
217
+
218
+ |===
219
+ | Name | Default value | Configurable values
220
+
221
+ | Ignore
222
+ | `[]`
223
+ | Array
224
+ |===
225
+
226
+ [#yardocmethoddescription]
227
+ == Yardoc/MethodDescription
228
+
229
+ |===
230
+ | Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
231
+
232
+ | Enabled
233
+ | Yes
234
+ | No
235
+ | -
236
+ | -
237
+ |===
238
+
239
+ Ensures all methods have a description.
240
+
241
+ This does not ensure parameters and other documentation, only the description
242
+
243
+ Private/protected methods are skipped unless `DocumentPrivate: true`.
244
+ Methods can be ignored via `Ignore`.
245
+
246
+ [#examples-yardocmethoddescription]
247
+ === Examples
248
+
249
+ [#documentprivate_-_true_-_default_-yardocmethoddescription]
250
+ ==== DocumentPrivate: `true` (default)
251
+
252
+ [source,ruby]
253
+ ----
254
+ # bad
255
+
256
+ def my_method; end
257
+
258
+ # bad
259
+
260
+ # @param name [String] The name
261
+ def some_method(name); end
262
+
263
+ # good
264
+
265
+ # Does something useful.
266
+ def my_other_method; end
267
+
268
+ private
269
+
270
+ # good
271
+
272
+ # Does something useful.
273
+ # def my_other_other_method; end
274
+ ----
275
+
276
+ [#documentprivate_-_true_-yardocmethoddescription]
277
+ ==== DocumentPrivate: `true`
278
+
279
+ [source,ruby]
280
+ ----
281
+ private
282
+
283
+ # good
284
+
285
+ def secret; end
286
+ ----
287
+
288
+ [#ignore_-___a_method___-yardocmethoddescription]
289
+ ==== Ignore: `['a_method']`
290
+
291
+ [source,ruby]
292
+ ----
293
+ # bad
294
+
295
+ def something; end
296
+
297
+ # good (ignored)
298
+
299
+ def a_method; end
300
+
301
+ class MyClass
302
+ # good (ignored)
303
+
304
+ def a_method; end
305
+ end
306
+ ----
307
+
308
+ [#ignore_-____a_m___-yardocmethoddescription]
309
+ ==== Ignore: `['/^a_m/']`
310
+
311
+ [source,ruby]
312
+ ----
313
+ # bad
314
+
315
+ def something; end
316
+
317
+ # good (ignored)
318
+
319
+ def a_method; end
320
+
321
+ class MyClass
322
+ # good (ignored)
323
+
324
+ def a_method; end
325
+ end
326
+ ----
327
+
328
+ [#ignore_-___myclass__a_method___-yardocmethoddescription]
329
+ ==== Ignore: `['MyClass::a_method']`
330
+
331
+ [source,ruby]
332
+ ----
333
+ # bad
334
+
335
+ def something; end
336
+
337
+ # bad
338
+
339
+ def a_method; end
340
+
341
+ class MyClass
342
+ # good (ignored)
343
+
344
+ def a_method; end
345
+ end
346
+ ----
347
+
348
+ [#configurable-attributes-yardocmethoddescription]
349
+ === Configurable attributes
350
+
351
+ |===
352
+ | Name | Default value | Configurable values
353
+
354
+ | DocumentPrivate
355
+ | `true`
356
+ | Boolean
357
+
358
+ | Ignore
359
+ | `[]`
360
+ | Array
361
+ |===
362
+
363
+ [#yardocmoduledescription]
364
+ == Yardoc/ModuleDescription
365
+
366
+ |===
367
+ | Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
368
+
369
+ | Enabled
370
+ | Yes
371
+ | No
372
+ | -
373
+ | -
374
+ |===
375
+
376
+ Ensures all modules have YARD documentation.
377
+
378
+ Modules can be ignored by exact name, qualified name, or regexp pattern.
379
+
380
+ [#examples-yardocmoduledescription]
381
+ === Examples
382
+
383
+ [source,ruby]
384
+ ----
385
+ # bad
386
+
387
+ module MyModule; end
388
+
389
+ # good
390
+
391
+ # A useful module.
392
+ module MyModule; end
393
+ ----
394
+
395
+ [#ignore_-___mymodule__-_internal__-_mymodule__mysubmodule___-yardocmoduledescription]
396
+ ==== Ignore: `['MyModule', '/Internal/', 'MyModule::MySubModule']`
397
+
398
+ [source,ruby]
399
+ ----
400
+ # good (ignored with '/Internal/')
401
+
402
+ module MyInternalModule; end
403
+
404
+ # good (ignored with 'MyModule')
405
+
406
+ module MyModule; end
407
+
408
+ # bad
409
+
410
+ module MyOtherModule
411
+ # good (ignored with 'MyModule::MySubModule')
412
+
413
+ module MySubModule; end
414
+
415
+ # good (ignored with 'MyModule')
416
+
417
+ module MyModule; end
418
+ end
419
+ ----
420
+
421
+ [#configurable-attributes-yardocmoduledescription]
422
+ === Configurable attributes
423
+
424
+ |===
425
+ | Name | Default value | Configurable values
426
+
427
+ | Ignore
428
+ | `[]`
429
+ | Array
430
+ |===
431
+
432
+ [#yardocparamdescriptioncasing]
433
+ == Yardoc/ParamDescriptionCasing
434
+
435
+ |===
436
+ | Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
437
+
438
+ | Enabled
439
+ | Yes
440
+ | Always
441
+ | -
442
+ | -
443
+ |===
444
+
445
+ Ensure every "param" and "return" tag starts with an uppercased letter
446
+
447
+ It ignores description starting with non latin characters
448
+
449
+ [#examples-yardocparamdescriptioncasing]
450
+ === Examples
451
+
452
+ [source,ruby]
453
+ ----
454
+ # bad
455
+
456
+ # @param x [Integer] desc
457
+ # @return [void] desc
458
+ def my_method(x); end
459
+
460
+ # good
461
+
462
+ # @param x [Integer] Desc
463
+ # @return [void] Desc
464
+ def my_method(x); end
465
+ ----
466
+
467
+ [#yardocparamdocumentation]
468
+ == Yardoc/ParamDocumentation
469
+
470
+ |===
471
+ | Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
472
+
473
+ | Enabled
474
+ | Yes
475
+ | No
476
+ | -
477
+ | -
478
+ |===
479
+
480
+ Ensures all method parameters are documented with @param tags.
481
+
482
+ By default, each @param must include a name, type, and description.
483
+ Set `RequireDescription: false` to only require name and type.
484
+
485
+ [#examples-yardocparamdocumentation]
486
+ === Examples
487
+
488
+ [#requiredescription_-_true_-_default_-yardocparamdocumentation]
489
+ ==== RequireDescription: `true` (default)
490
+
491
+ [source,ruby]
492
+ ----
493
+ # bad
494
+
495
+ # @param name [String]
496
+ def greet(name); end
497
+
498
+ # good
499
+
500
+ # @param name [String] the name to greet
501
+ def greet(name); end
502
+ ----
503
+
504
+ [#requiredescription_-_false_-yardocparamdocumentation]
505
+ ==== RequireDescription: `false`
506
+
507
+ [source,ruby]
508
+ ----
509
+ # good
510
+
511
+ # @param name [String]
512
+ def greet(name); end
513
+ ----
514
+
515
+ [#configurable-attributes-yardocparamdocumentation]
516
+ === Configurable attributes
517
+
518
+ |===
519
+ | Name | Default value | Configurable values
520
+
521
+ | RequireDescription
522
+ | `true`
523
+ | Boolean
524
+ |===
525
+
526
+ [#yardocseparatetagsblocks]
527
+ == Yardoc/SeparateTagsBlocks
528
+
529
+ |===
530
+ | Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
531
+
532
+ | Enabled
533
+ | Yes
534
+ | Always
535
+ | -
536
+ | -
537
+ |===
538
+
539
+ Ensures there are blank comment lines between blocks of tags in
540
+ documentation comments.
541
+
542
+ [#examples-yardocseparatetagsblocks]
543
+ === Examples
544
+
545
+ [source,ruby]
546
+ ----
547
+ # bad
548
+
549
+ # Title
550
+ # @param x [Integer] desc
551
+ # @param y [Integer] desc
552
+ # @return [void]
553
+ def my_method(x, y); end
554
+
555
+ # good
556
+
557
+ # Title
558
+ #
559
+ # @param x [Integer] desc
560
+ # @param y [Integer] desc
561
+ #
562
+ # @return [void]
563
+ def my_method(x, y); end
564
+ ----
565
+
566
+ [#yardocsupportedtags]
567
+ == Yardoc/SupportedTags
568
+
569
+ |===
570
+ | Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
571
+
572
+ | Enabled
573
+ | Yes
574
+ | No
575
+ | -
576
+ | -
577
+ |===
578
+
579
+ Ensures only supported YARD tags are used.
580
+
581
+ The built-in supported tags follow the official YARD tag list.
582
+
583
+ Additional tags can be whitelisted via `AdditionalTags` if they are
584
+ not properly registered in Yardoc
585
+ See Adding Custom Tags: https://rubydoc.info/gems/yard/file/docs/TagsArch.md#Adding_Custom_Tags
586
+
587
+ Meta tags are not supported (`@!<tag>`, used when metaprogramming).
588
+
589
+ [#examples-yardocsupportedtags]
590
+ === Examples
591
+
592
+ [source,ruby]
593
+ ----
594
+ # good
595
+
596
+ # @param name [String] a name
597
+ # @return [void]
598
+ def foo(name); end
599
+
600
+ # bad
601
+
602
+ # @unknown_tag some value
603
+ def foo; end
604
+ ----
605
+
606
+ [#additionaltags_-___custom_tag___-yardocsupportedtags]
607
+ ==== AdditionalTags: `['custom_tag']`
608
+
609
+ [source,ruby]
610
+ ----
611
+ # good
612
+
613
+ # @custom_tag some value
614
+ def foo; end
615
+ ----
616
+
617
+ [#configurable-attributes-yardocsupportedtags]
618
+ === Configurable attributes
619
+
620
+ |===
621
+ | Name | Default value | Configurable values
622
+
623
+ | AdditionalTags
624
+ | `[]`
625
+ | Array
626
+ |===
627
+
628
+ [#yardoctagorder]
629
+ == Yardoc/TagOrder
630
+
631
+ |===
632
+ | Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
633
+
634
+ | Enabled
635
+ | Yes
636
+ | No
637
+ | -
638
+ | -
639
+ |===
640
+
641
+ Ensures YARD tags appear in the configured order.
642
+
643
+ Override with the `Order` config option.
644
+
645
+ [#examples-yardoctagorder]
646
+ === Examples
647
+
648
+ [source,ruby]
649
+ ----
650
+ # bad
651
+
652
+ # @return [void]
653
+ # @param name [String] a name
654
+ def foo(name); end
655
+
656
+ # good
657
+
658
+ # @param name [String] a name
659
+ # @return [void]
660
+ def foo(name); end
661
+ ----
662
+
663
+ [#order_-___return__-_param___-yardoctagorder]
664
+ ==== Order: `['return', 'param']`
665
+
666
+ [source,ruby]
667
+ ----
668
+ # bad
669
+
670
+ # @param name [String] a name
671
+ # @return [void]
672
+ def foo(name); end
673
+
674
+ # good
675
+
676
+ # @return [void]
677
+ # @param name [String] a name
678
+ def foo(name); end
679
+ ----
680
+
681
+ [#configurable-attributes-yardoctagorder]
682
+ === Configurable attributes
683
+
684
+ |===
685
+ | Name | Default value | Configurable values
686
+
687
+ | Order
688
+ | `deprecated`, `param`, `return`, `yieldparam`, `yieldreturn`, `option`, `raise`, `see`, `since`, `note`, `example`
689
+ | Array
690
+ |===
691
+
692
+ [#yardoctypesformat]
693
+ == Yardoc/TypesFormat
694
+
695
+ |===
696
+ | Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
697
+
698
+ | Enabled
699
+ | Yes
700
+ | Always
701
+ | -
702
+ | -
703
+ |===
704
+
705
+ Ensures all types are separated by a space
706
+
707
+ [#examples-yardoctypesformat]
708
+ === Examples
709
+
710
+ [source,ruby]
711
+ ----
712
+ # bad
713
+
714
+ # @param [String,nil]
715
+ def greet(name); end
716
+
717
+ # good
718
+
719
+ # @param name [String, nil]
720
+ def greet(name); end
721
+ ----
722
+
723
+ [#yardocvalidtypes]
724
+ == Yardoc/ValidTypes
725
+
726
+ |===
727
+ | Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
728
+
729
+ | Enabled
730
+ | Yes
731
+ | Always
732
+ | -
733
+ | -
734
+ |===
735
+
736
+ Ensures all types are parseable by YARD.
737
+
738
+ [#examples-yardocvalidtypes]
739
+ === Examples
740
+
741
+ [source,ruby]
742
+ ----
743
+ # bad
744
+
745
+ # @param name [.method, Array[String]] the name to greet
746
+ def greet(name); end
747
+
748
+ # good
749
+
750
+ # @param [String, List(item, item2), Array<String>, Hash{String, Integer}, ClassName, #method, nil, true]
751
+ def greet(name); end
752
+ ----
753
+
754
+ [#yardocyielddocumentation]
755
+ == Yardoc/YieldDocumentation
756
+
757
+ |===
758
+ | Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
759
+
760
+ | Enabled
761
+ | Yes
762
+ | No
763
+ | -
764
+ | -
765
+ |===
766
+
767
+ Ensures methods that yield a block document it with @yield.
768
+
769
+ Also checks for @yieldparam when the yield passes arguments,
770
+ and @yieldreturn when the yield's return value is used.
771
+
772
+ [#examples-yardocyielddocumentation]
773
+ === Examples
774
+
775
+ [#requireparamdocumentation_-_true_-_default_-yardocyielddocumentation]
776
+ ==== RequireParamDocumentation: `true` (default)
777
+
778
+ [source,ruby]
779
+ ----
780
+ # bad
781
+
782
+ def each
783
+ yield item
784
+ end
785
+
786
+ # good
787
+
788
+ # @yield [item] iterates over items
789
+ # @yieldparam item [Object] the current item
790
+ def each
791
+ yield item
792
+ end
793
+ ----
794
+
795
+ [#requireparamdocumentation_-_false_-yardocyielddocumentation]
796
+ ==== RequireParamDocumentation: `false`
797
+
798
+ [source,ruby]
799
+ ----
800
+ # bad (no yield documentation)
801
+
802
+ def each
803
+ yield item
804
+ end
805
+
806
+ # good (ignored)
807
+
808
+ # @yield [item] iterates over items
809
+ def each
810
+ yield item
811
+ end
812
+ ----
813
+
814
+ [#configurable-attributes-yardocyielddocumentation]
815
+ === Configurable attributes
816
+
817
+ |===
818
+ | Name | Default value | Configurable values
819
+
820
+ | RequireParamDocumentation
821
+ | `true`
822
+ | Boolean
823
+ |===