Class: YARD::Amp::ModernCommandHandler

Inherits:
Handlers::Ruby::Base
  • Object
show all
Includes:
ParsingHelpers, CodeObjects
Defined in:
lib/yard-amp/modern_handler.rb

Overview

This handler is used by the Ruby 1.9+ parser engine. Uses AST nodes.

All the interesting logic is actually all in SharedMethods. This class specifically defines the parsing logic to get the data ready for the Shared Methods.

Instance Method Summary collapse

Methods included from ParsingHelpers

#clean_string, #construct_docstring, #parse_hash, #split_by_comma_smart

Instance Method Details

#commands_moduleObject



36
37
38
39
# File 'lib/yard-amp/modern_handler.rb', line 36

def commands_module
  mod = register ModuleObject.new(:root, "Amp")
  com_mod = register ModuleObject.new(mod, "Commands")
end

#processObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/yard-amp/modern_handler.rb', line 13

def process
  if statement.parameters.size != 2
    raise YARD::Parser::UndocumentableError, 'command declaration with invalid parameters'
  end
  command_name = statement.parameters.first.source
  command_name = command_name[1..-1] if command_name[0,1] == ":"
  
  klass = ClassObject.new(commands_module, command_name.capitalize) do |o|
    o.superclass = P("Amp::Command")
    o.superclass.type = :class if o.superclass.is_a?(Proxy)
  end
  klass[:amp_data] ||= {}
  klass[:amp_data].merge!(:docstring => statement.comments)

  parse_block statement[2].children[1], owner: klass
  register klass
  construct_docstring(klass)
end

#workflow_module(workflow) ⇒ Object



32
33
34
# File 'lib/yard-amp/modern_handler.rb', line 32

def workflow_module(workflow)
  register ModuleObject.new(commands_module, workflow.to_s.capitalize)
end