module YARD::Handlers::Ruby::DSLHandlerMethods
Constants
- IGNORE_METHODS
Public Instance Methods
handle_comments()
click to toggle source
# File lib/yard/handlers/ruby/dsl_handler_methods.rb, line 12 def handle_comments return if IGNORE_METHODS[caller_method] @docstring = statement.comments || "" @docstring = @docstring.join("\n") if @docstring.is_a?(Array) if @docstring =~ /^@!?macro\s+\[[^\]]*attach/ register_docstring(nil) @docstring = "" end if macro = find_attached_macro @docstring += "\n" + macro.expand([caller_method, *call_params], statement.source) elsif !statement.comments_hash_flag && !implicit_docstring? return register_docstring(nil) end # ignore DSL definitions if @method/@attribute directive is used if @docstring =~ /^@!?(method|attribute)\b/ return register_docstring(nil) end object = MethodObject.new(namespace, method_name, scope) object.signature = method_signature register(object) end
register_docstring(object, docstring = @docstring, stmt = statement)
click to toggle source
Calls superclass method
# File lib/yard/handlers/ruby/dsl_handler_methods.rb, line 40 def register_docstring(object, docstring = @docstring, stmt = statement) super end
Private Instance Methods
find_attached_macro()
click to toggle source
# File lib/yard/handlers/ruby/dsl_handler_methods.rb, line 64 def find_attached_macro Registry.all(:macro).each do |macro| next unless macro.method_object next unless macro.method_object.name.to_s == caller_method.to_s (namespace.inheritance_tree(true) + [P('Object')]).each do |obj| return macro if obj == macro.method_object.namespace end end nil end
implicit_docstring?()
click to toggle source
# File lib/yard/handlers/ruby/dsl_handler_methods.rb, line 46 def implicit_docstring? tags = %w(method attribute overload visibility scope return) tags.any? {|tag| @docstring =~ /^@!?#{tag}\b/ } end
method_name()
click to toggle source
# File lib/yard/handlers/ruby/dsl_handler_methods.rb, line 51 def method_name name = call_params.first || "" if name =~ /^#{CodeObjects::METHODNAMEMATCH}$/ name else raise UndocumentableError, "method, missing name" end end
method_signature()
click to toggle source
# File lib/yard/handlers/ruby/dsl_handler_methods.rb, line 60 def method_signature "def #{method_name}" end