Class: YARD::Handlers::Ruby::MacroHandler

Inherits:
Base
  • Object
show all
Includes:
CodeObjects, MacroHandlerMethods
Defined in:
lib/yard/handlers/ruby/macro_handler.rb

Overview

Handles a macro (dsl-style method)

Constant Summary collapse

IGNORE_METHODS =
Hash[*%w(alias alias_method autoload attr attr_accessor 
attr_reader attr_writer extend include public private protected 
private_constant).map {|n| [n, true]

Constants included from CodeObjects

CodeObjects::BUILTIN_ALL, CodeObjects::BUILTIN_CLASSES, CodeObjects::BUILTIN_EXCEPTIONS, CodeObjects::BUILTIN_EXCEPTIONS_HASH, CodeObjects::BUILTIN_MODULES, CodeObjects::CONSTANTMATCH, CodeObjects::CSEP, CodeObjects::CSEPQ, CodeObjects::ISEP, CodeObjects::ISEPQ, CodeObjects::METHODMATCH, CodeObjects::METHODNAMEMATCH, CodeObjects::NAMESPACEMATCH, CodeObjects::NSEP, CodeObjects::NSEPQ

Instance Attribute Summary

Attributes inherited from Base

#extra_state, #globals, #namespace, #owner, #parser, #scope, #statement, #visibility

Instance Method Summary collapse

Methods included from MacroHandlerMethods

#create_attribute_data, #expand_macro, #expanded_macro_or_docstring, #find_or_create_macro, #method_name, #method_signature, #sanitize_scope, #sanitize_visibility

Methods inherited from Base

#call_params, #caller_method, handles?, meta_type, method_call, #parse_block

Methods included from Parser::Ruby

#s

Methods inherited from Base

#call_params, #caller_method, clear_subclasses, #ensure_loaded!, #expand_macro, #find_or_create_macro, handlers, handles, handles?, in_file, #initialize, matches_file?, namespace_only, namespace_only?, #parse_block, process, #push_state, #register, subclasses

Constructor Details

This class inherits a constructor from YARD::Handlers::Base

Instance Method Details

#processvoid

This method returns an undefined value.

Main processing callback



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/yard/handlers/ruby/macro_handler.rb', line 15

process do
  globals.__attached_macros ||= {}
  if !globals.__attached_macros[caller_method]
    return if IGNORE_METHODS[caller_method]
    return if !statement.comments || statement.comments.empty?
  end
  
  @macro, @docstring = nil, Docstring.new(statement.comments)
  find_or_create_macro(@docstring)
  return if !@macro && !statement.comments_hash_flag && @docstring.tags.size == 0
  @docstring = expanded_macro_or_docstring
  name = method_name
  raise UndocumentableError, "method, missing name" if name.nil? || name.empty?
  tmp_scope = sanitize_scope
  tmp_vis = sanitize_visibility
  object = MethodObject.new(namespace, name, tmp_scope)
  register(object)
  object.visibility = tmp_vis
  object.dynamic = true
  object.signature = method_signature
  create_attribute_data(object)
end