Sha256: 9d864b89bacf61d71d803631873fd949d8ce6221b7a7df18285284167f80b306

Contents?: true

Size: 962 Bytes

Versions: 6

Compression:

Stored size: 962 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

6 entries across 6 versions & 1 rubygems

Version Path
puppet-strings-4.1.3 lib/puppet-strings/yard/handlers/json/task_handler.rb
puppet-strings-4.1.2 lib/puppet-strings/yard/handlers/json/task_handler.rb
puppet-strings-4.1.1 lib/puppet-strings/yard/handlers/json/task_handler.rb
puppet-strings-4.1.0 lib/puppet-strings/yard/handlers/json/task_handler.rb
puppet-strings-4.0.0 lib/puppet-strings/yard/handlers/json/task_handler.rb
puppet-strings-4.0.0.rc.1 lib/puppet-strings/yard/handlers/json/task_handler.rb