Module: Docscribe::Plugin
- Defined in:
- lib/docscribe/plugin.rb,
lib/docscribe/plugin/tag.rb,
lib/docscribe/plugin/context.rb,
lib/docscribe/plugin/registry.rb,
lib/docscribe/plugin/base/tag_plugin.rb,
lib/docscribe/plugin/base/collector_plugin.rb
Overview
Plugin system entry point.
Provides two extension points:
-
TagPlugin — hooks into already-collected method insertions and appends additional YARD tags. Subclass Base::TagPlugin and override #call.
-
CollectorPlugin — receives the raw AST and walks it independently. Used for non-standard structures that Docscribe’s Collector does not recognize. Subclass Base::CollectorPlugin and override #collect.
Defined Under Namespace
Modules: Base, Registry Classes: Context, Tag
Class Method Summary collapse
- .debug? ⇒ Boolean
-
.run_collector_plugins(ast, buffer) ⇒ Array<Hash>
Run all registered CollectorPlugins for one file’s AST.
-
.run_tag_plugins(context) ⇒ Array<Docscribe::Plugin::Tag>
Run all registered TagPlugins for one method context.
Class Method Details
.debug? ⇒ Boolean
54 55 56 |
# File 'lib/docscribe/plugin.rb', line 54 def self.debug? ENV['DOCSCRIBE_DEBUG'] == '1' end |
.run_collector_plugins(ast, buffer) ⇒ Array<Hash>
Run all registered CollectorPlugins for one file’s AST.
44 45 46 47 48 49 50 51 |
# File 'lib/docscribe/plugin.rb', line 44 def self.run_collector_plugins(ast, buffer) Registry.collector_plugins.flat_map do |plugin| plugin.collect(ast, buffer) rescue StandardError => e warn "Docscribe: CollectorPlugin #{plugin.class} raised #{e.class}: #{e.}" if debug? [] end end |
.run_tag_plugins(context) ⇒ Array<Docscribe::Plugin::Tag>
Run all registered TagPlugins for one method context.
Errors in individual plugins are caught so one broken plugin does not abort the entire run.
29 30 31 32 33 34 35 36 |
# File 'lib/docscribe/plugin.rb', line 29 def self.run_tag_plugins(context) Registry.tag_plugins.flat_map do |plugin| plugin.call(context) rescue StandardError => e warn "Docscribe: TagPlugin #{plugin.class} raised #{e.class}: #{e.}" if debug? [] end end |