#!/usr/bin/env ruby require 'fileutils' ['yard', 'redcarpet', 'github-markup'].each do |item| begin require item rescue LoadError $stderr.puts "Failed to load required library `#{item}`. To fix: `gem install #{item}` or include within bundle" exit -1 end end doc_path = File.join(Dir.pwd, 'doc') FileUtils.mkdir_p(doc_path) Dir.chdir(File.dirname(File.dirname(__FILE__))) do unless(system("yardoc -o #{doc_path}")) $stderr.puts 'Failed to successfully run `yardoc`. Unable to generate documentation!' exit -1 end end user_docs_path = File.join(Dir.pwd, 'doc', 'UserDocs') FileUtils.mkdir_p(user_docs_path) Dir.glob(File.join(File.dirname(File.dirname(__FILE__)), 'docs', '**', '*')) do |path| next unless File.file?(path) content = File.read(path) rel_path = path.sub(/.*?docs\//, '') new_path = File.join(user_docs_path, rel_path) user_doc_root = (['..'] * rel_path.scan('/').size).join('/') unless(user_doc_root.to_s.empty?) user_doc_root << '/' end FileUtils.mkdir_p(File.dirname(new_path)) File.open(new_path, 'w') do |file| file.puts content end if(new_path.end_with?('.md')) File.open(new_path.sub('.md', '.html'), 'w') do |file| file.print "