Class: YARDGo::Handlers::Base

Inherits:
YARD::Handlers::Base
  • Object
show all
Includes:
CodeObjects
Defined in:
lib/yard-go/handlers.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.handles?(node) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
10
11
# File 'lib/yard-go/handlers.rb', line 6

def self.handles?(node)
  handlers.any? do |h|
    (node.name.nil? || node.name[0] == node.name[0].upcase) &&
    node.type == h
  end
end

Instance Method Details

#call_paramsObject



17
# File 'lib/yard-go/handlers.rb', line 17

def call_params; [] end

#caller_methodObject



18
# File 'lib/yard-go/handlers.rb', line 18

def caller_method; nil end

#parse_block(inner_node, opts = {}) ⇒ Object



13
14
15
# File 'lib/yard-go/handlers.rb', line 13

def parse_block(inner_node, opts = {})
  push_state(opts) { parser.process([inner_node].flatten) }
end

#pkgObject



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/yard-go/handlers.rb', line 20

def pkg
  return @pkg if @pkg
  pkg = :root
  path = File.dirname(File.relative_path(Dir.pwd, parser.file))
  parts = path.split('/')
  while parts.size > 0
    pkg = PackageObject.new(pkg, parts.shift)
    pkg.add_file(path) unless pkg.file
  end

  @pkg = pkg
end

#test_file?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/yard-go/handlers.rb', line 33

def test_file?
  parser.file =~ /_test\.go$/
end