require 'strings2conf/version' require 'json' require 'erb' include ERB::Util module Strings2conf class Util DEFAULT_CODE_BLOCK_PARAMETERS = { linenumbers: true, theme: 'RDark', }.freeze def self.code_block(code, params = {}) ac_params = DEFAULT_CODE_BLOCK_PARAMETERS .merge(params) .map { |name, value| " #{value}" } .join("\n") <<~HTML #{ac_params} HTML end def self.parse_param(instance, param) name = param['name'] types = if param['types'] " [ #{param['types'].map { |t| "#{t}" }.join(',')} ] " else '' end defaults = if instance.key?('defaults') and instance['defaults'].key?(name) " (defaults to: #{h instance['defaults'][name]}) " else '' end <<~HTML
  • #{name}#{types}#{defaults}#{h param['text']}
  • HTML end end def self.convert(json) @data = JSON.parse json template_path = File.dirname(File.expand_path(__FILE__)) + '/templates/confluence.html.erb' ERB.new(File.read(template_path), nil, '-').result(binding) end end