Class: RuboCop::Cop::Style::Documentation
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Style::Documentation
- Includes:
- DocumentationComment, RangeHelp
- Defined in:
- lib/rubocop/cop/style/documentation.rb
Overview
Checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, constant definitions or constant visibility declarations.
The documentation requirement is annulled if the class or module has a ‘#:nodoc:` comment next to it. Likewise, `#:nodoc: all` does the same for all its children.
Constant Summary collapse
- MSG =
'Missing top-level documentation comment for `%<type>s %<identifier>s`.'
Instance Method Summary collapse
- #constant_definition?(node) ⇒ Object
- #constant_visibility_declaration?(node) ⇒ Object
- #include_statement?(node) ⇒ Object
- #on_class(node) ⇒ Object
- #on_module(node) ⇒ Object
- #outer_module(node) ⇒ Object
Instance Method Details
#constant_definition?(node) ⇒ Object
79 |
# File 'lib/rubocop/cop/style/documentation.rb', line 79 def_node_matcher :constant_definition?, '{class module casgn}' |
#constant_visibility_declaration?(node) ⇒ Object
85 86 87 |
# File 'lib/rubocop/cop/style/documentation.rb', line 85 def_node_matcher :constant_visibility_declaration?, <<~PATTERN (send nil? {:public_constant :private_constant} ({sym str} _)) PATTERN |
#include_statement?(node) ⇒ Object
90 91 92 |
# File 'lib/rubocop/cop/style/documentation.rb', line 90 def_node_matcher :include_statement?, <<~PATTERN (send nil? {:include :extend :prepend} const) PATTERN |
#on_class(node) ⇒ Object
94 95 96 97 98 |
# File 'lib/rubocop/cop/style/documentation.rb', line 94 def on_class(node) return unless node.body check(node, node.body) end |
#on_module(node) ⇒ Object
100 101 102 |
# File 'lib/rubocop/cop/style/documentation.rb', line 100 def on_module(node) check(node, node.body) end |
#outer_module(node) ⇒ Object
82 |
# File 'lib/rubocop/cop/style/documentation.rb', line 82 def_node_search :outer_module, '(const (const nil? _) _)' |