Class: YARDSorbet::Handlers::EnumsHandler

Inherits:
YARD::Handlers::Ruby::Base
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/yard-sorbet/handlers/enums_handler.rb

Overview

Handle enums calls, registering enum values as constants

Instance Method Summary collapse

Instance Method Details

#const_assign_node?(node) ⇒ Boolean (private)

Parameters:

  • node (YARD::Parser::Ruby::AstNode)

Returns:

  • (Boolean)


29
# File 'lib/yard-sorbet/handlers/enums_handler.rb', line 29

def const_assign_node?(node) = node.type == :assign && node[0][0].type == :const

#processvoid

This method returns an undefined value.



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/yard-sorbet/handlers/enums_handler.rb', line 14

def process
  statement.traverse do |node|
    if const_assign_node?(node)
      register YARD::CodeObjects::ConstantObject.new(namespace, node.first.source) do |obj|
        obj.docstring = node.docstring
        obj.source = node
        obj.value = node.last.source
      end
    end
  end
end