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

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

Overview

Handles a macro (dsl-style method)

Constant Summary

Constant Summary

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

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

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?, #parse_block

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



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

process do
  globals.__attached_macros ||= {}
  if !globals.__attached_macros[caller_method]
    return if Ruby::MacroHandler::IGNORE_METHODS[caller_method]
    return if !statement.comments || statement.comments.empty?
  end

  comments = statement.comments ? statement.comments.join("\n") : ""
  @macro, @docstring = nil, Docstring.new(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