require 'coderay' require 'json' module Docs class ERBEnvironment attr_writer :examples attr_accessor :content attr_accessor :config # <%= config.api_endpoint %> # <%= example :source, "curl/users/getting.sh" %> def example(source_or_output, name) raise ArgumentError, "Must specify :source or :output as first argument" unless [:source, :output].include?(source_or_output) @examples[source_or_output]["examples/#{name}"] end def pretty_print_json(json) begin JSON.pretty_generate(JSON.parse(json)) rescue JSON::ParserError => e e.inspect end end def syntax_highlight(str, language) CodeRay.scan(str, language).div end def get_binding binding end end end