Class: PuppetStrings::Yard::Tags::PropertyDirective

Inherits:
YARD::Tags::Directive
  • Object
show all
Defined in:
lib/puppet-strings/yard/tags/property_directive.rb

Overview

Implements a parameter directive (e.g. #@!puppet.type.property) for documenting Puppet resource types.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.register! ⇒ void

This method returns an undefined value.

Registers the directive with YARD.



22
23
24
# File 'lib/puppet-strings/yard/tags/property_directive.rb', line 22

def self.register!
  YARD::Tags::Library.define_directive('puppet.type.property', :with_types_and_name, self)
end

Instance Method Details

#call ⇒ void

This method returns an undefined value.

Called to invoke the directive.



9
10
11
12
13
14
15
16
17
18
# File 'lib/puppet-strings/yard/tags/property_directive.rb', line 9

def call
  return unless object.respond_to?(:add_property)

  # Add a property to the resource
  property = PuppetStrings::Yard::CodeObjects::Type::Property.new(tag.name, tag.text)
  tag.types&.each do |value|
    property.add(value)
  end
  object.add_property property
end