Class: YARD::Tags::VisibilityDirective

Inherits:
Directive
  • Object
show all
Defined in:
lib/yard/tags/directives.rb

Overview

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

Examples:

Modifying the visibility of a DSL method

# @!visibility private
cattr_accessor :subclasses

Modifying the visibility of a set of methods

# Note that Ruby's "protected" is recommended over this directive
# @!visibility protected

# Documentation for method1
def method1; end

# Documentation for method2
def method2; end

Since:

  • 0.7.0

Instance Attribute Summary

Attributes inherited from Directive

#expanded_text, #handler, #object, #tag

Parser callbacks collapse

Methods inherited from Directive

#after_parse, #initialize

Constructor Details

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

Instance Method Details

#callObject

Since:

  • 0.7.0



612
613
614
615
616
617
618
619
620
621
622
# File 'lib/yard/tags/directives.rb', line 612

def call
  if %w(public protected private).include?(tag.text)
    if object.is_a?(CodeObjects::Base)
      object.visibility = tag.text.to_sym
    elsif handler && !inside_directive?
      handler.visibility = tag.text.to_sym
    else
      parser.state.visibility = tag.text.to_sym
    end
  end
end