Sha256: 0863f22cc4eae2c1f307018d5c4a3d70677e9feb0fd4a8c5574a1b719ef04175

Contents?: true

Size: 961 Bytes

Versions: 2

Compression:

Stored size: 961 Bytes

Contents

# frozen_string_literal: true

require 'puppet-strings/yard/handlers/json/base'
require 'puppet-strings/yard/parsers'
require 'puppet-strings/yard/parsers/json/parser'

# Implements the handler for JSON task metadata.
class PuppetStrings::Yard::Handlers::JSON::TaskHandler < PuppetStrings::Yard::Handlers::JSON::Base
  handles PuppetStrings::Yard::Parsers::JSON::TaskStatement
  namespace_only

  process do
    object = PuppetStrings::Yard::CodeObjects::Task.new(statement)
    register object

    @kind = "Puppet Task #{object.name}."
    @statement = statement

    validate_description
    validate_params
  end

  def validate_description
    log.warn "Missing a description for #{@kind}." if @statement.docstring.empty?
  end

  def validate_params
    return if @statement.parameters.empty?
    @statement.parameters.each do |param, val|
      log.warn "Missing description for param '#{param}' in #{@kind}" if val['description'].nil?
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
puppet-strings-3.0.1 lib/puppet-strings/yard/handlers/json/task_handler.rb
puppet-strings-3.0.0 lib/puppet-strings/yard/handlers/json/task_handler.rb