Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Top-level class documentation

Tags:

ruby

rubocop

Rubycop outputs messages like:

app/controllers/welcome_controller.rb:1:1: C: Missing top-level class documentation comment.
class WelcomeController < ApplicationController
^^^^^

I wonder what does top-level class documentation look like. It's not just a comment, is it? It needs to have a special format, but which one?

like image 657
DreamWalker Avatar asked Apr 06 '16 17:04

DreamWalker


3 Answers

That said a simple comment like so will do nicely:

# This shiny device polishes bared foos
class FooBarPolisher
       ...
like image 56
lab419 Avatar answered Oct 12 '22 17:10

lab419


From the Rubocop documentation:

RuboCop is a Ruby static code analyzer. Out of the box it will enforce many of the guidelines outlined in the community Ruby Style Guide.

The Ruby Style Guide "comment" section doesn't use the phrase "Missing top-level class documentation comment" but from reading the guide section on comments, you can quickly infer from the examples that commenting classes and modules is recommended.

The reason is, when using rdoc, the comments for the classes/modules will be used to generate the reference to the code, something that is important whether you're writing code for yourself, for a team or for general release by others.

like image 24
the Tin Man Avatar answered Oct 12 '22 18:10

the Tin Man


I ended up here looking for a way to disable this check, if that's your case, put

Documentation:
  Enabled: false

in your .rubocop.yml file.

like image 43
Alvaro Rodriguez Scelza Avatar answered Oct 12 '22 17:10

Alvaro Rodriguez Scelza