Module: RoboPigeon::Documentarian

Defined in:
lib/robopigeon/documentarian.rb

Constant Summary collapse

@@documents =
{}

Class Method Summary collapse

Class Method Details

.add_block(name, **options) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/robopigeon/documentarian.rb', line 7

def self.add_block(name, **options)
  block_desc = options[:desc]
  helpers = options[:helpers] || false
  document = get_document(block: options[:block], document: @@documents)
  document[name] = {
    block_desc: block_desc,
    includes_helpers: helpers
  }
  document[name][:params] = options[:params] if options[:params]
end

.add_command(name, **options) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/robopigeon/documentarian.rb', line 18

def self.add_command(name, **options)
  command_desc = options[:desc]
  document = get_document(block: options[:block], document: @@documents)
  document[name] = {
    command_desc: command_desc
  }
  document[name][:params] = options[:params] if options[:params]
end

.generate_docsObject



27
28
29
# File 'lib/robopigeon/documentarian.rb', line 27

def self.generate_docs
  JSON.pretty_generate(@@documents)
end

.get_document(**options) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/robopigeon/documentarian.rb', line 31

def self.get_document(**options)
  block = options[:block]
  document = options[:document]
  return get_document(document: document[block.shift], block: block) unless block.empty?

  document
end