Sha256: f5e582277a9d1c3a19c6d3d0bc4860b7614eb580c62af34e51994e5729a4bbec

Contents?: true

Size: 1.19 KB

Versions: 2

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

require 'puppet-strings/markdown/base'

module PuppetStrings::Markdown
  # Generates Markdown for a Puppet Function.
  class Function < Base
    attr_reader :signatures

    group_name 'Functions'
    yard_types [:puppet_function]

    def initialize(registry)
      @template = 'function.erb'
      super(registry, 'function')
      @signatures = []
      registry[:signatures].each do |sig|
        @signatures.push(Signature.new(sig))
      end
    end

    def render
      super(@template)
    end

    def type
      t = @registry[:type]
      if %r{ruby4x}.match?(t)
        'Ruby 4.x API'
      elsif %r{ruby3}.match?(t)
        'Ruby 3.x API'
      elsif %r{ruby}.match?(t)
        'Ruby'
      else
        'Puppet Language'
      end
    end

    def error_type(type)
      "`#{type.split(' ')[0]}`"
    end

    def error_text(text)
      text.split(' ').drop(1).join(' ').to_s
    end
  end

  # Implements methods to retrieve information about a function signature.
  class Function::Signature < Base
    def initialize(registry)
      @registry = registry
      super(@registry, 'function signature')
    end

    def signature
      @registry[:signature]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
puppet-strings-3.0.1 lib/puppet-strings/markdown/function.rb
puppet-strings-3.0.0 lib/puppet-strings/markdown/function.rb