Sha256: db5d301ff8a4fcd482088b468eee79c93c5cf2f9e124173446f6b2ce2932961c

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

require_relative 'documentation/markdown_template'

module PlatformosCheck
  module PlatformosLiquid
    class Documentation
      class << self
        def filter_doc(filter_name)
          render_doc(SourceIndex.filters.find { |entry| entry.name == filter_name })
        end

        def object_doc(object_name)
          render_doc(SourceIndex.objects.find { |entry| entry.name == object_name })
        end

        def tag_doc(tag_name)
          render_doc(SourceIndex.tags.find { |entry| entry.name == tag_name })
        end

        def object_property_doc(object_name, property_name)
          property_entry = SourceIndex
                           .objects
                           .find { |entry| entry.name == object_name }
                           &.properties
                           &.find { |prop| prop.name == property_name }

          render_doc(property_entry)
        end

        def render_doc(entry)
          return nil unless entry

          markdown_template.render(entry)
        end

        private

        def markdown_template
          @markdown_template ||= MarkdownTemplate.new
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
platformos-check-0.4.14 lib/platformos_check/platformos_liquid/documentation.rb
platformos-check-0.4.13 lib/platformos_check/platformos_liquid/documentation.rb