Sha256: f4f86521fb226b30603686d4862f05fd52cde914822de1bda8d46a791c53c9ae

Contents?: true

Size: 908 Bytes

Versions: 1

Compression:

Stored size: 908 Bytes

Contents

require 'erb'
require 'redcarpet'
require 'active_support/core_ext/string/inflections'
require 'active_support/core_ext/array'

module JSONAPIonify
  class Documentation
    using JSONAPIonify::IndentedString
    RENDERER = Redcarpet::Markdown.new(
      Redcarpet::Render::HTML,
      autolink: true,
      tables: true,
      fenced_code_blocks: true,
      strikethrough: true,
      disable_indented_code_blocks: true,
      no_intra_emphasis: true,
      space_after_headers: true,
      underline: true,
      highlight: true,
      quote: true
    )

    def self.render_markdown(string)
      RENDERER.render(string.deindent)
    end

    attr_reader :api

    def initialize(api, template: nil)
      template ||= File.join(__dir__, 'documentation/template.erb')
      @api     = api
      @erb     = ERB.new File.read(template)
    end

    def result
      @erb.result(binding)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jsonapionify-0.0.1.pre lib/jsonapionify/documentation.rb