123456789_123456789_123456789_123456789_123456789_

Class: YARD::Tags::ScopeDirective

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Directive
Instance Chain:
self, Directive
Inherits: YARD::Tags::Directive
Defined in: lib/yard/tags/directives.rb

Overview

Modifies the current parsing scope (class or instance). If this directive is defined on a docstring attached to an object definition, it is applied only to that object. Otherwise, it applies the scope to all future objects in the namespace.

Examples:

Modifying the scope of a DSL method

# @!scope class
cattr_accessor :subclasses

Modifying the scope of a set of methods

# @!scope class

# Documentation for method1
def method1; end

# Documentation for method2
def method2; end

Since:

  • 0.7.0

Parser callbacks

Class Method Summary

Directive - Inherited

Instance Attribute Summary

Directive - Inherited

#expanded_text

Set this field to replace the directive definition inside of a docstring with arbitrary text.

#handler, #object, #tag

Instance Method Summary

Directive - Inherited

#after_parse

Called after parsing all directives and tags in the docstring.

#call

Called when processing the directive.

Constructor Details

This class inherits a constructor from YARD::Tags::Directive

Instance Method Details

#call

Since:

  • 0.7.0

[ GitHub ]

  
# File 'lib/yard/tags/directives.rb', line 580

def call
  if %w(class instance module).include?(tag.text)
    if object.is_a?(CodeObjects::MethodObject)
      object.scope = tag.text.to_sym
    elsif handler && !inside_directive?
      handler.scope = tag.text.to_sym
    else
      parser.state.scope = tag.text.to_sym
    end
  end
end