module Asciidoctor::Extensions

def create name = nil, &block

def create name = nil, &block
  if block_given?
    Registry.new (name || generate_name) => block
  else
    Registry.new
  end
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.size
  if block_given?
    resolved_group = block
  elsif (group = args.pop)
    # QUESTION should we instantiate the group class here or defer until activation??
    resolved_group = (Helpers.resolve_class group) || group
  else
    raise ::ArgumentError, %(Extension group to register not specified)
  end
  name = args.pop || generate_name
  unless args.empty?
    raise ::ArgumentError, %(Wrong number of arguments (#{argc} for 1..2))
  end
  groups[name.to_sym] = resolved_group
end

def unregister *names

Returns nothing

names - one or more Symbol or String group names to unregister

Public: Unregister statically-registered extension groups by name.
def unregister *names
  names.each {|group| @groups.delete group.to_sym }
  nil
end

def unregister_all

Returns nothing

Public: Unregister all statically-registered extension groups.
def unregister_all
  @groups = {}
  nil
end