Sha256: a73e689cea8bb71045c7268874be3c53a2f1b002df16438175b047a084aaef8a

Contents?: true

Size: 1.03 KB

Versions: 8

Compression:

Stored size: 1.03 KB

Contents

require 'json'

module RoboPigeon
  module Documentarian
    @@documents = {}

    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

    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

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

    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
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
robopigeon-0.5.1 lib/robopigeon/documentarian.rb
robopigeon-0.5.0 lib/robopigeon/documentarian.rb
robopigeon-0.4.0 lib/robopigeon/documentarian.rb
robopigeon-0.3.2 lib/robopigeon/documentarian.rb
robopigeon-0.3.1 lib/robopigeon/documentarian.rb
robopigeon-0.3.0 lib/robopigeon/documentarian.rb
robopigeon-0.2.0 lib/robopigeon/documentarian.rb
robopigeon-0.1.0 lib/robopigeon/documentarian.rb