Class: YARD::Handlers::Ruby::Legacy::Base Abstract
- Includes:
- Parser::Ruby::Legacy::RubyToken
- Defined in:
- lib/yard/handlers/ruby/legacy/base.rb
Overview
See Base for subclassing information.
This is the base handler for the legacy parser. To implement a legacy handler, subclass this class.
Direct Known Subclasses
AliasHandler, AttributeHandler, ClassConditionHandler, ClassHandler, ClassVariableHandler, CommentHandler, ConstantHandler, DSLHandler, ExceptionHandler, MethodHandler, MixinHandler, ModuleFunctionHandler, ModuleHandler, PrivateClassMethodHandler, PrivateConstantHandler, VisibilityHandler, YieldHandler
Constant Summary
Constants included from Parser::Ruby::Legacy::RubyToken
Parser::Ruby::Legacy::RubyToken::EXPR_ARG, Parser::Ruby::Legacy::RubyToken::EXPR_BEG, Parser::Ruby::Legacy::RubyToken::EXPR_CLASS, Parser::Ruby::Legacy::RubyToken::EXPR_DOT, Parser::Ruby::Legacy::RubyToken::EXPR_END, Parser::Ruby::Legacy::RubyToken::EXPR_FNAME, Parser::Ruby::Legacy::RubyToken::EXPR_MID, Parser::Ruby::Legacy::RubyToken::NEWLINE_TOKEN, Parser::Ruby::Legacy::RubyToken::TkReading2Token, Parser::Ruby::Legacy::RubyToken::TkSymbol2Token
Constants included from CodeObjects
CodeObjects::BUILTIN_ALL, CodeObjects::BUILTIN_CLASSES, CodeObjects::BUILTIN_EXCEPTIONS, CodeObjects::BUILTIN_EXCEPTIONS_HASH, CodeObjects::BUILTIN_MODULES, CodeObjects::CONSTANTMATCH, CodeObjects::CONSTANTSTART, CodeObjects::CSEP, CodeObjects::CSEPQ, CodeObjects::ISEP, CodeObjects::ISEPQ, CodeObjects::METHODMATCH, CodeObjects::METHODNAMEMATCH, CodeObjects::NAMESPACEMATCH, CodeObjects::NSEP, CodeObjects::NSEPQ
Class Method Summary collapse
-
.handles?(stmt) ⇒ Boolean
Whether or not a Parser::Ruby::Legacy::Statement object should be handled by this handler.
Instance Method Summary collapse
- #call_params ⇒ Object
- #caller_method ⇒ Object
-
#parse_block(opts = {}) ⇒ Object
Parses a statement’s block with a set of state values.
Methods included from CodeObjects::NamespaceMapper
#clear_separators, #default_separator, on_invalidate, #register_separator, #separators, #separators_for_type, #separators_match, #types_for_separator, #unregister_separator_by_type
Constructor Details
This class inherits a constructor from YARD::Handlers::Base
Class Method Details
permalink .handles?(stmt) ⇒ Boolean
Returns whether or not a Parser::Ruby::Legacy::Statement object should be handled by this handler.
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/yard/handlers/ruby/legacy/base.rb', line 15 def self.handles?(stmt) handlers.any? do |a_handler| case a_handler when String stmt.tokens.first.text == a_handler when Regexp stmt.tokens.to_s =~ a_handler else a_handler == stmt.tokens.first.class end end end |
Instance Method Details
permalink #call_params ⇒ Object
[View source]
44 45 46 47 48 49 50 51 |
# File 'lib/yard/handlers/ruby/legacy/base.rb', line 44 def call_params if statement.tokens.first.is_a?(TkDEF) extract_method_details.last.map(&:first) else tokens = statement.tokens[1..-1] tokval_list(tokens, :attr, :identifier, TkId).map(&:to_s) end end |
permalink #caller_method ⇒ Object
[View source]
53 54 55 56 57 58 59 |
# File 'lib/yard/handlers/ruby/legacy/base.rb', line 53 def caller_method if statement.tokens.first.is_a?(TkIDENTIFIER) statement.tokens.first.text elsif statement.tokens.first.is_a?(TkDEF) extract_method_details.first end end |
permalink #parse_block(opts = {}) ⇒ Object
Parses a statement’s block with a set of state values. If the statement has no block, nothing happens. A description of state values can be found at Base#push_state
35 36 37 38 39 40 41 42 |
# File 'lib/yard/handlers/ruby/legacy/base.rb', line 35 def parse_block(opts = {}) push_state(opts) do if statement.block blk = Parser::Ruby::Legacy::StatementList.new(statement.block) parser.process(blk) end end end |