Module: YARD::Handlers::Ruby::DSLHandlerMethods
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
|
|
Defined in: | lib/yard/handlers/ruby/dsl_handler_methods.rb |
Constant Summary
-
IGNORE_METHODS =
# File 'lib/yard/handlers/ruby/dsl_handler_methods.rb', line 9Hash[*%w(alias alias_method autoload attr attr_accessor attr_reader attr_writer extend include module_function public private protected private_constant private_class_method public_class_method). map {|n| [n, true]
::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
Instance Attribute Summary
- #implicit_docstring? ⇒ Boolean readonly private
Instance Method Summary
Instance Attribute Details
#implicit_docstring? ⇒ Boolean
(readonly, private)
[ GitHub ]
# File 'lib/yard/handlers/ruby/dsl_handler_methods.rb', line 54
def implicit_docstring? = %w(method attribute overload visibility scope return) .any? {|tag| @docstring =~ /^@!?#{tag}\b/ } end
Instance Method Details
#find_attached_macro (private)
[ GitHub ]# File 'lib/yard/handlers/ruby/dsl_handler_methods.rb', line 72
def find_attached_macro Registry.all(:macro).each do |macro| next unless macro.method_object next unless macro_name_matches(macro) (namespace.inheritance_tree(true) + [P('Object')]).each do |obj| return macro if obj == macro.method_object.namespace end end nil end
#handle_comments
[ GitHub ]# File 'lib/yard/handlers/ruby/dsl_handler_methods.rb', line 14
def handle_comments return if IGNORE_METHODS[caller_method] @docstring = statement.comments || "" @docstring = @docstring.join("\n") if @docstring.is_a?(Array) attaching = false if @docstring =~ /^@!?macro\s+\[[^\]]*attach/ register_docstring(nil) @docstring = "" attaching = true end macro = find_attached_macro if macro txt = macro. ([caller_method, *call_params], statement.source) @docstring += "\n" + txt # macro may have a directive return register_docstring(nil) if !attaching && txt.match(/^\s*@!/) 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 register MethodObject.new(namespace, method_name, scope) do |o| o.signature = method_signature end end
#macro_name_matches(macro) ⇒ Boolean
(private)
# File 'lib/yard/handlers/ruby/dsl_handler_methods.rb', line 85
def macro_name_matches(macro) objs = [macro.method_object] if objs.first.type != :proxy && objs.first.respond_to?(:aliases) objs.concat(objs.first.aliases) end objs.any? {|obj| obj.name.to_s == caller_method.to_s } end
#method_name (private)
[ GitHub ]# File 'lib/yard/handlers/ruby/dsl_handler_methods.rb', line 59
def method_name name = call_params.first || "" if name =~ /^#{CodeObjects::METHODNAMEMATCH}$/ name else raise UndocumentableError, "method, missing name" end end
#method_signature (private)
[ GitHub ]# File 'lib/yard/handlers/ruby/dsl_handler_methods.rb', line 68
def method_signature "def #{method_name}" end
#register_docstring(object, docstring = @docstring, stmt = statement)
[ GitHub ]# File 'lib/yard/handlers/ruby/dsl_handler_methods.rb', line 48
def register_docstring(object, docstring = @docstring, stmt = statement) super end