Sha256: 5e45ac48daf863f12456cfa996ded6916607198ca45bb7539bdd92c7a547500d

Contents?: true

Size: 1.6 KB

Versions: 21

Compression:

Stored size: 1.6 KB

Contents

# frozen_string_literal: true

module PlatformosCheck
  module PlatformosLiquid
    class SourceIndex
      class TagEntry < BaseEntry
        def parameters
          (hash['parameters'] || [])
            .map { |hash| ParameterEntry.new(hash) }
        end

        def return_type_hash
          {
            'type' => "tag<#{name}>"
          }
        end

        def description
          @descritpion = begin
            desc = hash['description']&.strip || ''
            desc = '' if desc == 'returns'
            if parameters.any?
              desc += "\n\n---\n\nParameters:"
              parameters.each { |p| desc += "\n- #{p.full_summary}" }
            end
            if hash['return_type']&.any?
              rt = hash['return_type'].first
              rt['description'] = nil if rt['description']&.strip == ''
              desc += "\n\nReturns:"
              desc += "\n- #{[rt['type'], rt['description']].compact.join(': ')}\n"
            end
            if hash['examples']
              desc += "\n\n---\n\n"
              hash['examples'].each_with_index do |e, i|
                example = e['raw_liquid'].gsub(/[\n]+/, "\n").strip.split('=>')
                input = example[0]&.strip
                output = example[1]&.strip
                desc += "\n  - Example #{i}:\n\n```liquid\n#{input}\n```"
                desc += "\n##\nOutput: #{output}" if output
              end
            end
          end
          desc
        end

        def platformos_documentation_url
          "#{PLATFORMOS_DOCUMENTATION_URL}/api-reference/liquid/tags/#{hash['name']}"
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
platformos-check-0.4.14 lib/platformos_check/platformos_liquid/source_index/tag_entry.rb
platformos-check-0.4.13 lib/platformos_check/platformos_liquid/source_index/tag_entry.rb
platformos-check-0.4.12 lib/platformos_check/platformos_liquid/source_index/tag_entry.rb
platformos-check-0.4.11 lib/platformos_check/platformos_liquid/source_index/tag_entry.rb
platformos-check-0.4.10 lib/platformos_check/platformos_liquid/source_index/tag_entry.rb
platformos-check-0.4.9 lib/platformos_check/platformos_liquid/source_index/tag_entry.rb
platformos-check-0.4.8 lib/platformos_check/platformos_liquid/source_index/tag_entry.rb
platformos-check-0.4.7 lib/platformos_check/platformos_liquid/source_index/tag_entry.rb
platformos-check-0.4.6 lib/platformos_check/platformos_liquid/source_index/tag_entry.rb
platformos-check-0.4.5 lib/platformos_check/platformos_liquid/source_index/tag_entry.rb
platformos-check-0.4.4 lib/platformos_check/platformos_liquid/source_index/tag_entry.rb
platformos-check-0.4.3 lib/platformos_check/platformos_liquid/source_index/tag_entry.rb
platformos-check-0.4.2 lib/platformos_check/platformos_liquid/source_index/tag_entry.rb
platformos-check-0.4.1 lib/platformos_check/platformos_liquid/source_index/tag_entry.rb
platformos-check-0.4.0 lib/platformos_check/platformos_liquid/source_index/tag_entry.rb
platformos-check-0.3.3 lib/platformos_check/platformos_liquid/source_index/tag_entry.rb
platformos-check-0.3.1 lib/platformos_check/platformos_liquid/source_index/tag_entry.rb
platformos-check-0.3.0 lib/platformos_check/platformos_liquid/source_index/tag_entry.rb
platformos-check-0.2.2 lib/platformos_check/platformos_liquid/source_index/tag_entry.rb
platformos-check-0.2.1 lib/platformos_check/platformos_liquid/source_index/tag_entry.rb