Class: Yard::Lint::Validators::Documentation::UndocumentedOptions::Parser

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

Overview

Parses YARD output for undocumented options violations

Instance Method Summary collapse

Methods inherited from Parsers::Base

#match

Instance Method Details

#call(output) ⇒ Array<Hash>

Parse YARD output into structured violations

Parameters:

  • output (String)

    raw YARD output

Returns:

  • (Array<Hash>)

    array of violation hashes



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/yard/lint/validators/documentation/undocumented_options/parser.rb', line 13

def call(output)
  return [] if output.nil? || output.empty?

  violations = []
  lines = output.lines.map(&:chomp)

  i = 0
  while i < lines.size
    line = lines[i]

    # Match location line: "file:line: object_name"
    if (location_match = line.match(/^(.+):(\d+): (.+)$/))
      file_path = location_match[1]
      line_number = location_match[2].to_i
      object_name = location_match[3]

      # Next line contains parameter list
      i += 1
      next unless i < lines.size

      params = lines[i]

      violations << {
        location: file_path,
        line: line_number,
        object_name: object_name,
        params: params
      }
    end

    i += 1
  end

  violations
end