Module: Asciidoctor::Extensions
- Defined in:
- lib/asciidoctor/extensions.rb
Overview
Asciidoctor processor.
Defined Under Namespace
Modules: BlockProcessorDsl, DocinfoProcessorDsl, DocumentProcessorDsl, IncludeProcessorDsl, InlineMacroProcessorDsl, MacroProcessorDsl, SyntaxProcessorDsl Classes: BlockMacroProcessor, BlockProcessor, DocinfoProcessor, Extension, Group, IncludeProcessor, InlineMacroProcessor, MacroProcessor, Postprocessor, Preprocessor, Processor, ProcessorExtension, Registry, TreeProcessor
Constant Summary collapse
- Treeprocessor =
Alias deprecated class name for backwards compatibility
TreeProcessor
Class Method Summary collapse
- .create(name = nil, &block) ⇒ Object
- .generate_name ⇒ Object
- .groups ⇒ Object
- .next_auto_id ⇒ Object
-
.register(*args, &block) ⇒ Proc, Class or Object
Registers an extension Group that subsequently registers a collection of extensions.
-
.unregister(*names) ⇒ void
Unregister statically-registered extension groups by name.
-
.unregister_all ⇒ void
Unregister all statically-registered extension groups.
Class Method Details
.create(name = nil, &block) ⇒ Object
1470 1471 1472 1473 1474 1475 1476 |
# File 'lib/asciidoctor/extensions.rb', line 1470 def create name = nil, &block if block_given? Registry.new (name || generate_name) => block else Registry.new end end |
.generate_name ⇒ Object
1457 1458 1459 |
# File 'lib/asciidoctor/extensions.rb', line 1457 def generate_name %(extgrp#{next_auto_id}) end |
.groups ⇒ Object
1466 1467 1468 |
# File 'lib/asciidoctor/extensions.rb', line 1466 def groups @groups ||= {} end |
.next_auto_id ⇒ Object
1461 1462 1463 1464 |
# File 'lib/asciidoctor/extensions.rb', line 1461 def next_auto_id @auto_id ||= -1 @auto_id += 1 end |
.register(*args, &block) ⇒ Proc, Class or Object
Registers an extension Group that subsequently registers a collection of extensions.
Registers the extension Group specified under the given name. If a name is not given, one is calculated by appending the next value in a 0-based index to the string “extgrp”. For instance, the first unnamed extension group to be registered is assigned the name “extgrp0” if a name is not specified.
The names are not yet used, but are intended for selectively activating extensions in the future.
If the extension group argument is a String or a Symbol, it gets resolved to a Class before being registered.
1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 |
# File 'lib/asciidoctor/extensions.rb', line 1512 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 |
.unregister(*names) ⇒ void
This method returns an undefined value.
Unregister statically-registered extension groups by name.
1542 1543 1544 1545 |
# File 'lib/asciidoctor/extensions.rb', line 1542 def unregister *names names.each_with_object(groups) {|group, catalog| catalog.delete group.to_sym } nil end |
.unregister_all ⇒ void
This method returns an undefined value.
Unregister all statically-registered extension groups.
1532 1533 1534 1535 |
# File 'lib/asciidoctor/extensions.rb', line 1532 def unregister_all @groups = {} nil end |