Sha256: 787428cc3ac6eb950e2861cdce73df61843b1701a324c4ff5b455cecfee9631f

Contents?: true

Size: 1.14 KB

Versions: 23

Compression:

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

23 entries across 23 versions & 1 rubygems

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