Class: Yard::Lint::Validators::Documentation::OrphanedDocComment::Parser

Inherits:
Parsers::Base
  • Object
show all
Defined in:
lib/yard/lint/validators/documentation/orphaned_doc_comment/parser.rb

Overview

Parses validator output into structured offense hashes.

Examples:

Output format (one line per orphaned block)

# "path/to/file.rb:10: @param,@return"

Constant Summary collapse

LINE_REGEX =

Returns parses “file:line: @tag1,@tag2” collector output lines.

Returns:

  • (Regexp)

    parses “file:line: @tag1,@tag2” collector output lines

/^(.+):(\d+): ([@a-z,_]+)$/.freeze

Instance Method Summary collapse

Methods inherited from Parsers::Base

#match

Instance Method Details

#call(validator_output) ⇒ Array<Hash>

Returns array of orphaned comment offense hashes.

Parameters:

  • validator_output (String)

    raw validator results string

Returns:

  • (Array<Hash>)

    array of orphaned comment offense hashes



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/yard/lint/validators/documentation/orphaned_doc_comment/parser.rb', line 17

def call(validator_output)
  validator_output
    .split("\n")
    .map(&:strip)
    .reject(&:empty?)
    .filter_map do |line|
      match = line.match(LINE_REGEX)
      next unless match

      {
        location: match[1],
        line: match[2].to_i,
        tags: match[3].split(',')
      }
    end
end