Class: Yard::Lint::Validators::Documentation::UndocumentedMethodArguments::Parser

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

Overview

Class used to extract details about methods with undocumented arguments

Examples:

Output format (skip-lint)

/path/to/file.rb:10: Platform::Analysis::Authors#initialize

Constant Summary collapse

LOCATION_REGEX =

Regex to extract file, line, and method name from yard list output Format: /path/to/file.rb:10: ClassName#method_name

/^(.+):(\d+):\s+(.+)[#.](.+)$/

Instance Method Summary collapse

Methods inherited from Parsers::Base

#match

Instance Method Details

#call(yard_list) ⇒ Array<Hash>

Returns Array with undocumented method arguments details.

Parameters:

  • yard_list (String)

    raw yard list results string

Returns:

  • (Array<Hash>)

    Array with undocumented method arguments details



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/yard/lint/validators/documentation/undocumented_method_arguments/parser.rb', line 18

def call(yard_list)
  yard_list
    .split("\n")
    .reject(&:empty?)
    .filter_map do |line|
      match_data = line.match(LOCATION_REGEX)
      next unless match_data

      # Extract: file path, line number, class name, method name
      file_path = match_data[1]
      line_number = match_data[2].to_i
      class_name = match_data[3]
      method_name = match_data[4]

      {
        location: file_path,
        method_name: method_name,
        line: line_number,
        class_name: class_name
      }
    end
end