Sha256: 5a0585a15d64c578f469181597068eda21d582184ccbddca4c9a8c0d8773c08c

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

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.9.0 lib/jsonapionify/documentation.rb