Class: YARD::Tags::ScopeDirective

Inherits:
Directive
  • Object
show all
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:

Instance Attribute Summary (collapse)

Parser callbacks (collapse)

Constructor Details

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

Instance Attribute Details

- (String?) expanded_text Originally defined in class Directive

Set this field to replace the directive definition inside of a docstring with arbitrary text. For instance, the MacroDirective uses this field to expand its macro data in place of the call to a @!macro.

Returns:

  • (String)

    the text to expand in the original docstring in place of this directive definition.

  • (nil)

    if no expansion should take place for this directive

Since:

  • 0.8.0

- (Handlers::Base?) handler (readonly) Originally defined in class Directive

Returns the handler object the docstring parser might be attached to. May be nil. Only available when parsing through Parser::SourceParser.

Returns:

Since:

  • 0.8.0

- (CodeObjects::Base?) object (readonly) Originally defined in class Directive

Returns the object the parent docstring is attached to. May be nil.

Returns:

  • (CodeObjects::Base, nil)

    the object the parent docstring is attached to. May be nil.

Since:

  • 0.8.0

- (DocstringParser) parser (protected) Originally defined in class Directive

Returns the parser that is parsing all tag information out of the docstring

Returns:

  • (DocstringParser)

    the parser that is parsing all tag information out of the docstring

Since:

  • 0.8.0

- (Tag) tag Originally defined in class Directive

Returns the meta-data tag containing data input to the directive

Returns:

  • (Tag)

    the meta-data tag containing data input to the directive

Since:

  • 0.8.0

Instance Method Details

- (Object) call

Since:

  • 0.7.0



556
557
558
559
560
561
562
563
564
# File 'lib/yard/tags/directives.rb', line 556

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