Class: YARD::Handlers::Ruby::Base Abstract
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
AliasHandler, AttributeHandler, ClassConditionHandler, ClassHandler, ClassVariableHandler, CommentHandler, ConstantHandler, DSLHandler, ExceptionHandler, ExtendHandler, MethodConditionHandler, MethodHandler, MixinHandler, ModuleFunctionHandler, ModuleHandler, PrivateClassMethodHandler, PrivateConstantHandler, PublicClassMethodHandler, VisibilityHandler, YieldHandler
|
|
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
|
|
Instance Chain:
|
|
Inherits: |
YARD::Handlers::Base
|
Defined in: | lib/yard/handlers/ruby/base.rb |
Overview
See ::YARD::Handlers::Base
for subclassing information.
This is the base handler class for the new-style (1.9) ::YARD::Handlers::Ruby
parser.
All handlers that subclass this base class will be used when the
new-style parser is used. For implementing legacy handlers, see
Legacy::Base
.
Constant Summary
::YARD::CodeObjects
- Included
BUILTIN_ALL, BUILTIN_CLASSES, BUILTIN_EXCEPTIONS, BUILTIN_EXCEPTIONS_HASH, BUILTIN_MODULES, CONSTANTMATCH, CONSTANTSTART, CSEP, CSEPQ, ISEP, ISEPQ, METHODMATCH, METHODNAMEMATCH, NAMESPACEMATCH, NSEP, NSEPQ, PROXY_MATCH
Statement Matcher Extensions
-
.meta_type(type) ⇒ void
Matcher for handling a node with a specific meta-type.
-
.method_call(name = nil) ⇒ void
Matcher for handling any type of method call.
Testing for a Handler
Parsing an Inner Block
Macro Handling
Class Attribute Summary
::YARD::Handlers::Base
- Inherited
.namespace_only | Declares that the handler should only be called when inside a |
.namespace_only? |
Class Method Summary
::YARD::Parser::Ruby
- Extended
s | Builds and s-expression by creating |
::YARD::Handlers::Base
- Inherited
.clear_subclasses | Clear all registered subclasses. |
.handlers, | |
.handles | Declares the statement type which will be processed by this handler. |
.handles? | This class is implemented by |
.in_file | Declares that a handler should only be called when inside a filename by its basename or a regex match for the full path. |
.inherited, .matches_file?, .new, | |
.process | Generates a |
.subclasses | Returns all registered handler subclasses. |
Instance Attribute Summary
::YARD::Handlers::Base
- Inherited
#extra_state | Share state across different handlers inside of a file. |
#globals |
|
#namespace, #namespace=, #owner, #owner=, #parser, #scope, #scope=, #statement, #visibility, #visibility= |
Instance Method Summary
::YARD::Parser::Ruby
- Included
#s | Builds and s-expression by creating |
::YARD::Handlers::Base
- Inherited
#abort! | Aborts a handler by raising |
#call_params, #caller_method, | |
#ensure_loaded! | Ensures that a specific |
#parse_block | Parses the semantic "block" contained in the statement node. |
#process | The main handler method called by the parser on a statement that matches the |
#push_state | Executes a given block with specific state values for |
#register | Do some post processing on a list of code objects. |
#register_docstring | Registers any docstring found for the object and expands macros. |
#register_dynamic | Registers the object as dynamic if the object is defined inside a method or block (owner != namespace). |
#register_ensure_loaded | Ensures that the object's namespace is loaded before attaching it to the namespace. |
#register_file_info | Registers the file/line of the declaration with the object. |
#register_group | Registers the object as being inside a specific group. |
#register_module_function | Registers the same method information on the module function, if the object was defined as a module function. |
#register_source, | |
#register_transitive_tags | Registers any transitive tags from the namespace on the object. |
#register_visibility | Registers visibility on a method object. |
Constructor Details
This class inherits a constructor from YARD::Handlers::Base
Class Method Details
.handles?(node) ⇒ Boolean
# File 'lib/yard/handlers/ruby/base.rb', line 113
def handles?(node) handlers.any? do |a_handler| case a_handler when Symbol a_handler == node.type when String node.source == a_handler when Regexp node.source =~ a_handler when Parser::Ruby::AstNode a_handler == node when HandlesExtension a_handler.matches?(node) end end end
.meta_type(type) ⇒ void
This method returns an undefined value.
Matcher for handling a node with a specific meta-type. An AstNode
has a AstNode#type
to define its type but can also be associated
with a set of types. For instance, :if
and :unless
are both
of the meta-type :condition
.
A meta-type is any method on the AstNode
class ending in "?",
though you should not include the "?" suffix in your declaration.
Some examples are: "condition", "call", "literal", "kw", "token",
"ref".
# File 'lib/yard/handlers/ruby/base.rb', line 105
def (type) TestNodeWrapper.new(type.to_s + "?") end
.method_call(name = nil) ⇒ void
This method returns an undefined value.
Matcher for handling any type of method call. Method calls can
be expressed by many AstNode
types depending on the syntax
with which it is called, so ::YARD
allows you to use this matcher
to simplify matching a method call.
# File 'lib/yard/handlers/ruby/base.rb', line 86
def method_call(name = nil) MethodCallWrapper.new(name ? name.to_s : nil) end
Instance Method Details
#call_params
[ GitHub ]# File 'lib/yard/handlers/ruby/base.rb', line 144
def call_params return [] unless statement.respond_to?(:parameters) statement.parameters(false).compact.map do |param| if param.type == :list param.map {|n| n.jump(:ident, :kw, :tstring_content).source } else param.jump(:ident, :kw, :tstring_content).source end end.flatten end
#caller_method
[ GitHub ]# File 'lib/yard/handlers/ruby/base.rb', line 155
def caller_method if statement.call? || statement.def? statement.method_name(true).to_s elsif statement.type == :var_ref || statement.type == :vcall statement[0].jump(:ident, :kw).source end end
#parse_block(inner_node, opts = {})
[ GitHub ]# File 'lib/yard/handlers/ruby/base.rb', line 135
def parse_block(inner_node, opts = {}) push_state(opts) do nodes = inner_node.type == :list ? inner_node.children : [inner_node] parser.process(nodes) end end