Class: Yard::Lint::Validators::Documentation::OrphanedDocComment::Validator
- Inherits:
-
Base
- Object
- Base
- Yard::Lint::Validators::Documentation::OrphanedDocComment::Validator
- Defined in:
- lib/yard/lint/validators/documentation/orphaned_doc_comment/validator.rb
Overview
Scans source files for YARD-tagged comment blocks that YARD will silently drop. A comment block is orphaned when it has YARD tags but is immediately followed by a non-documentable statement or sits at end-of-file.
Constant Summary collapse
- YARD_TAG_PATTERN =
Derive known tag names from YARD’s own registry so we stay in sync with any tags added by YARD plugins. This avoids false positives from instance variable mentions in comments (e.g. ‘# @body.each` or `# @result is nil`).
begin = ::YARD::Tags::Library.labels.keys.map(&:to_s).sort_by(&:length).reverse.join('|') /\A\s*#\s*@(#{})\b/ end.freeze
- YARD_DIRECTIVE_PATTERN =
Returns matches YARD directive lines (@!macro, @!method, etc.).
/\A\s*#\s*@!/.freeze
- DEFINITION_PATTERN =
Matches method/class/module/attribute/alias definitions (with optional visibility prefix) and constant assignments (uppercase-leading identifier followed by =), both of which YARD tracks and attaches preceding doc comments to. Also matches define_method which YARD handles via a built-in dynamic handler.
/ \A\s*(private\s+|protected\s+|public\s+)? (def |class |module |attr_reader|attr_writer|attr_accessor|attr_internal|alias_method\b|alias\b|define_method\b) | \A\s*[A-Z][A-Za-z0-9_:]*\s*= /x.freeze
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
in_process, in_process?, in_process_visibility, #initialize, validator_name
Constructor Details
This class inherits a constructor from Yard::Lint::Validators::Base
Instance Method Details
#in_process_query(object, collector) ⇒ void
This method returns an undefined value.
37 38 39 40 41 42 43 44 45 |
# File 'lib/yard/lint/validators/documentation/orphaned_doc_comment/validator.rb', line 37 def in_process_query(object, collector) return unless object.file && File.exist?(object.file) @scanned_files ||= {} return if @scanned_files[object.file] @scanned_files[object.file] = true scan_file(object.file, collector) end |