123456789_123456789_123456789_123456789_123456789_

Class: YARD::Handlers::RBS::Base

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Subclasses:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: YARD::Handlers::Base
Defined in: lib/yard/handlers/rbs/base.rb

Overview

Base class for all ::YARD::Handlers::RBS handlers. ::YARD::Handlers match on the Parser::RBS::Statement#type symbol of the current statement and process it to create or annotate code objects.

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

Class Attribute Summary

::YARD::Handlers::Base - Inherited

.namespace_only

Declares that the handler should only be called when inside a ::YARD::CodeObjects::NamespaceObject, not a method body.

.namespace_only?

Class Method Summary

::YARD::Handlers::Base - Inherited

.clear_subclasses

Clear all registered subclasses.

.handlers,
.handles

Declares the statement type which will be processed by this handler.

.handles?
.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 process method, equivalent to +def process; ...

.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

::YARD::Handlers can share state for the entire post processing stage through this attribute.

#namespace, #namespace=, #owner, #owner=, #parser, #scope, #scope=, #statement, #visibility, #visibility=

Instance Method Summary

::YARD::Handlers::Base - Inherited

#abort!

Aborts a handler by raising ::YARD::Handlers::HandlerAborted.

#call_params, #caller_method,
#ensure_loaded!

Ensures that a specific object has been parsed and loaded into the registry.

#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 handles declaration.

#push_state

Executes a given block with specific state values for #owner, #namespace and #scope.

#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?(statement, _processor) ⇒ Boolean

Returns:

  • (Boolean)

    whether this handler matches the given statement

[ GitHub ]

  
# File 'lib/yard/handlers/rbs/base.rb', line 11

def self.handles?(statement, _processor)
  handlers.any? do |matcher|
    case matcher
    when Symbol
      statement.type == matcher
    when String
      statement.type.to_s == matcher
    when Regexp
      (statement.source || '') =~ matcher
    else
      false
    end
  end
end

Instance Method Details

#parse_block(opts = {})

Recurse into the body of a namespace statement.

Parameters:

  • opts (Hash) (defaults to: {})

    state overrides

See Also:

  • #push_state
[ GitHub ]

  
# File 'lib/yard/handlers/rbs/base.rb', line 29

def parse_block(opts = {})
  return if statement.block.nil? || statement.block.empty?
  push_state(opts) do
    parser.process(statement.block)
  end
end