Class: YARD::Tags::Directive Abstract
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
|
|
Inherits: | Object |
Defined in: | lib/yard/tags/directives.rb |
Overview
Subclasses should implement #call.
The base directive class. Subclass this class to create a custom
directive, registering it with Library.define_directive. Directive
classes are executed via the #call method, which perform all directive
processing on the object.
If processing occurs within a handler, the #handler attribute is
available to access more information about parsing context and state.
::YARD::Handlers
are only available when parsing from ::YARD::Parser::SourceParser
,
not when parsing directly from ::YARD::DocstringParser
. If the docstring is
attached to an object declaration, #object will be set and available
to modify the generated code object directly. Note that both of these
attributes may be nil, and directives should test their existence
before attempting to use them.
Parser callbacks
-
#after_parse ⇒ void
Called after parsing all directives and tags in the docstring.
-
#call ⇒ void
abstract
Called when processing the directive.
Class Method Summary
- .new(tag, parser) ⇒ Directive constructor
Instance Attribute Summary
-
#expanded_text ⇒ String?
rw
Set this field to replace the directive definition inside of a docstring with arbitrary text.
- #handler ⇒ Handlers::Base? readonly
- #object ⇒ CodeObjects::Base? readonly
- #tag ⇒ Tag rw
Constructor Details
.new(tag, parser) ⇒ Directive
Instance Attribute Details
#expanded_text ⇒ String? (rw)
Set this field to replace the directive definition inside of a docstring
with arbitrary text. For instance, the MacroDirective
uses this field
to expand its macro data in place of the call to a @!macro
.
# File 'lib/yard/tags/directives.rb', line 33
attr_accessor :
#handler ⇒ Handlers::Base? (readonly)
# File 'lib/yard/tags/directives.rb', line 48
def handler; parser.handler end
#object ⇒ CodeObjects::Base? (readonly)
# File 'lib/yard/tags/directives.rb', line 42
def object; parser.object end
#tag ⇒ Tag (rw)
# File 'lib/yard/tags/directives.rb', line 24
attr_accessor :tag
Instance Method Details
#after_parse ⇒ void
This method returns an undefined value.
Called after parsing all directives and tags in the docstring. Used to perform any cleanup after all directives perform their main task.
# File 'lib/yard/tags/directives.rb', line 73
def after_parse; end
#call ⇒ void
implement this method to perform all data processing for the directive.
This method returns an undefined value.
Called when processing the directive. Subclasses should implement this method to perform all functionality of the directive.
# File 'lib/yard/tags/directives.rb', line 68
def call; raise NotImplementedError end