module Asciidoctor::Extensions

def build_registry name = nil, &block

def build_registry name = nil, &block
  if block_given?
    name ||= generate_name
    Registry.new({ name => block })
  else
    Registry.new
  end
end

def class_for_name qualified_name

Returns Class

Public: Resolves the Class object for the qualified name.
def class_for_name qualified_name
  resolved_class = ::Object
  qualified_name.split('::').each do |name|
    if name.empty?
      # do nothing
    elsif resolved_class.const_defined? name
      resolved_class = resolved_class.const_get name
    else
      raise %(Could not resolve class for name: #{qualified_name})
    end
  end
  resolved_class
end

def generate_name

def generate_name
  %(extgrp#{next_auto_id})
end

def groups

def groups
  @groups ||= {}
end

def next_auto_id

def next_auto_id
  @auto_id ||= -1
  @auto_id += 1
end

def register *args, &block

Returns the [Proc, Class or Object] instance, matching the type passed to this method.

end
block_processor :plantuml, PlantUmlBlock
Asciidoctor::Extensions.register :uml do

end
block_processor :plantuml, PlantUmlBlock
Asciidoctor::Extensions.register do

Asciidoctor::Extensions.register :uml, UmlExtensions

Asciidoctor::Extensions.register UmlExtensions

Examples

an Object instance of a Class.
group - A block (Proc), a Class, a String or Symbol name of a Class or
name - The name under which this extension group is registered (optional, default: nil)

to a Class before being registered.
If the extension group argument is a String or a Symbol, it gets resolved

extensions in the future.
The names are not yet used, but are intended for selectively activating

specified.
group to be registered is assigned the name "extgrp0" if a name is not
index to the string "extgrp". For instance, the first unnamed extension
not given, one is calculated by appending the next value in a 0-based
Registers the extension Group specified under the given name. If a name is

collection of extensions.
Public: Registers an extension Group that subsequently registers a
def register *args, &block
  argc = args.length
  resolved_group = if block_given?
    block
  elsif !(group = args.pop)
    raise ::ArgumentError.new %(Extension group to register not specified)
  else
    # QUESTION should we instantiate the group class here or defer until
    # activation??
    case group
    when ::Class
      group
    when ::String
      class_for_name group
    when ::Symbol
      class_for_name group.to_s
    else
      group
    end
  end
  name = args.pop || generate_name
  unless args.empty?
    raise ::ArgumentError.new %(Wrong number of arguments (#{argc} for 1..2))
  end
  groups[name] = resolved_group
end

def resolve_class object

unused atm, but tested
def resolve_class object
  (object.is_a? ::Class) ? object : (class_for_name object.to_s)
end

def unregister_all

def unregister_all
  @groups = {}
end