Sha256: 1bd22c5a8ade430ff947da61ec6bb4845f7d4a93d87d05175c5659bd34da2472

Contents?: true

Size: 793 Bytes

Versions: 4

Compression:

Stored size: 793 Bytes

Contents

# frozen_string_literal: true

require 'puppet-strings/yard/code_objects'

# Implements a parameter directive (e.g. #@!puppet.type.param) for documenting Puppet resource types.
class PuppetStrings::Yard::Tags::ParameterDirective < YARD::Tags::Directive
  # Called to invoke the directive.
  # @return [void]
  def call
    return unless object&.respond_to?(:add_parameter)

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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
puppet-strings-2.9.0 lib/puppet-strings/yard/tags/parameter_directive.rb
puppet-strings-2.8.0 lib/puppet-strings/yard/tags/parameter_directive.rb
puppet-strings-2.7.0 lib/puppet-strings/yard/tags/parameter_directive.rb
puppet-strings-2.6.0 lib/puppet-strings/yard/tags/parameter_directive.rb