Sha256: 83f7c2f70863fa02845148346125c8f3be07c51864dcb7f3609c316a90bf47bc

Contents?: true

Size: 786 Bytes

Versions: 6

Compression:

Stored size: 786 Bytes

Contents

# frozen_string_literal: true

require 'puppet-strings/yard/code_objects'

# Implements a parameter directive (e.g. #@!puppet.type.property) for documenting Puppet resource types.
class PuppetStrings::Yard::Tags::PropertyDirective < YARD::Tags::Directive
  # Called to invoke the directive.
  # @return [void]
  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

  # Registers the directive with YARD.
  # @return [void]
  def self.register!
    YARD::Tags::Library.define_directive('puppet.type.property', :with_types_and_name, self)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
puppet-strings-4.1.3 lib/puppet-strings/yard/tags/property_directive.rb
puppet-strings-4.1.2 lib/puppet-strings/yard/tags/property_directive.rb
puppet-strings-4.1.1 lib/puppet-strings/yard/tags/property_directive.rb
puppet-strings-4.1.0 lib/puppet-strings/yard/tags/property_directive.rb
puppet-strings-4.0.0 lib/puppet-strings/yard/tags/property_directive.rb
puppet-strings-4.0.0.rc.1 lib/puppet-strings/yard/tags/property_directive.rb