Class: YardSig::Sig

Inherits:
Object
  • Object
show all
Defined in:
lib/yard-sig/sig.rb

Constant Summary collapse

TAG_ORDER =
%w[param yieldparam yieldreturn return].freeze

Instance Method Summary collapse

Constructor Details

#initialize(source, parameters = [], namespace = "") ⇒ self

Parameters:

  • source (String)
  • parameters (Array<Array<String>>) (defaults to: [])
  • namespace (String) (defaults to: "")


8
9
10
11
12
# File 'lib/yard-sig/sig.rb', line 8

def initialize(source, parameters = [], namespace = "")
  @source = source
  @parameters = parameters
  @namespace = namespace
end

Instance Method Details

#to_tagsArray<YARD::Tags::Tag>

Returns:

  • (Array<YARD::Tags::Tag>)


15
16
17
18
19
20
# File 'lib/yard-sig/sig.rb', line 15

def to_tags
  tags = rbs_type_to_tags(rbs_method_type.type)
  tags += rbs_type_to_tags(rbs_method_type.block.type, within_block: true) if rbs_method_type.block

  tags.compact.sort_by { |tag| TAG_ORDER.index(tag.tag_name) }
end