Class: RbsInlineData::Parser::Comments

Inherits:
Object
  • Object
show all
Defined in:
lib/rbs_inline_data/parser.rb

Constant Summary collapse

MARKER =
"#::"

Class Method Summary collapse

Class Method Details

.from_prism_comments(comments) ⇒ Object

(Array) -> RbsInlineData::Parser::Comments



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/rbs_inline_data/parser.rb', line 25

def self.from_prism_comments(comments)
  # @type var comment_lines: Hash[Integer, String]
  comment_lines = {}
  comments.each do |comment|
    sliced = comment.slice
    next unless sliced.start_with?(MARKER)

    comment_lines[comment.location.start_line] = sliced.sub(MARKER, "").strip
  end

  new(comment_lines:)
end