Module: Docable

Included in:
Object
Defined in:
lib/amp/support/docs.rb

Instance Method Summary collapse

Instance Method Details

#docs_for(method) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/amp/support/docs.rb', line 14

def docs_for(method)
  klass = YARD::Registry.all(:class).detect do |k|
    k.name == name.split("::").last.to_sym
  end
  
  meth = klass.meths.detect {|m| m.name == method }
  
  puts "=== Documentation for #{self}##{method}"
  puts meth.docstring
  puts "---"
  puts meth.signature
  puts
  
  tag_callbacks.to_a.sort.each do |(tag, block)|
    if meth.has_tag? tag
      puts
      tags = meth.tags.select {|t| t.tag_name == tag.to_s }
      block.call meth, tags
      puts
    end
  end
  
  puts "It can be found at #{meth.file}:#{meth.line}"
  puts "==="
end

#tag_callback(name, &block) ⇒ Object



10
11
12
# File 'lib/amp/support/docs.rb', line 10

def tag_callback(name, &block)
  tag_callbacks[name] = block
end

#tag_callbacksObject



8
# File 'lib/amp/support/docs.rb', line 8

def tag_callbacks; @tag_callbacks ||= {}; end