Class: Yard::Lint::Validators::Documentation::UndocumentedObjects::Parser

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

Overview

Class used to extract details about undocumented objects from raw yard list output

Examples:

/path/to/file.rb:3: UndocumentedClass
/path/to/file.rb:4: UndocumentedClass#method_one

Constant Summary collapse

LINE_REGEX =

Regex used to parse yard list output format: file.rb:LINE: ObjectName

/^(.+):(\d+): (.+)$/

Instance Method Summary collapse

Methods inherited from Parsers::Base

#match

Instance Method Details

#call(yard_list_output) ⇒ Array<Hash>

Returns Array with undocumented objects details.

Parameters:

  • yard_list_output (String)

    raw yard list results string

Returns:

  • (Array<Hash>)

    Array with undocumented objects details



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

def call(yard_list_output)
  yard_list_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,
        element: match[3]
      }
    end
end