Class: YARD::Handlers::Ruby::AliasHandler
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
|
|
Instance Chain:
|
|
Inherits: |
YARD::Handlers::Ruby::Base
|
Defined in: | lib/yard/handlers/ruby/alias_handler.rb |
Overview
Handles alias and alias_method calls
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 |
.namespace_only? |
Class Method Summary
Base
- Inherited
.handles?, | |
.meta_type | Matcher for handling a node with a specific meta-type. |
.method_call | Matcher for handling any type of method call. |
::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 #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 |
|
#namespace, #namespace=, #owner, #owner=, #parser, #scope, #scope=, #statement, #visibility, #visibility= |
Instance Method Summary
-
#process ⇒ void
Main processing callback.
Base
- Inherited
::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
Instance Method Details
#process ⇒ void
This method returns an undefined value.
Main processing callback
# File 'lib/yard/handlers/ruby/alias_handler.rb', line 7
process do names = [] if statement.type == :alias nodes = [:ident, :op, :kw, :const, :tstring_content, :string_content] names = statement.map {|o| o.jump(*nodes).source } elsif statement.call? statement.parameters(false).each do |obj| case obj.type when :symbol_literal names << obj.jump(:ident, :op, :kw, :const).source when :string_literal, :dyna_symbol names << obj.jump(:string_content, :tstring_content).source end end end raise YARD::Parser::UndocumentableError, "alias/alias_method" if names.size != 2 new_meth = names[0].to_sym old_meth = names[1].to_sym old_obj = namespace.child(:name => old_meth, :scope => scope) new_obj = register MethodObject.new(namespace, new_meth, scope) do |o| o.add_file(parser.file, statement.line) end namespace.aliases[new_obj] = old_meth if old_obj new_obj.signature = old_obj.signature new_obj.source = old_obj.source comments = [old_obj.docstring.to_raw, statement.comments].join("\n") doc = YARD::Docstring.parser.parse(comments, new_obj, self) new_obj.docstring = doc.to_docstring new_obj.docstring.line_range = statement.comments_range new_obj.docstring.hash_flag = statement.comments_hash_flag new_obj.docstring.object = new_obj else new_obj.signature = "def #{new_meth}" # this is all we know. end end