Permalink
Browse files

Added rake tasks for publishing docs to GitHub pages.

  • Loading branch information...
jdantonio committed Feb 25, 2015
1 parent 9959e5d commit ae0557f5c38b23060e0bb38ef1d5f87bd04e544a
Showing with 45 additions and 0 deletions.
  1. +45 −0 tasks/update_doc.rake
View
@@ -0,0 +1,45 @@
require 'yard'
YARD::Rake::YardocTask.new
root = File.expand_path File.join(File.dirname(__FILE__), '..')
namespace :yard do
cmd = lambda do |command|
puts ">> executing: #{command}"
system command or raise "#{command} failed"
end
desc 'Pushes generated documentation to github pages: http://jdantonio.github.io/functional-ruby/'
task :push => [:setup, :yard] do
message = Dir.chdir(root) do
`git log -n 1 --oneline`.strip
end
puts "Generating commit: #{message}"
Dir.chdir "#{root}/yardoc" do
cmd.call "git add -A"
cmd.call "git commit -m '#{message}'"
cmd.call 'git push origin gh-pages'
end
end
desc 'Setups second clone in ./yardoc dir for pushing doc to github'
task :setup do
unless File.exist? "#{root}/yardoc/.git"
cmd.call "rm -rf #{root}/yardoc" if File.exist?("#{root}/yardoc")
Dir.chdir "#{root}" do
cmd.call 'git clone --single-branch --branch gh-pages git@github.com:jdantonio/functional-ruby.git ./yardoc'
end
end
Dir.chdir "#{root}/yardoc" do
cmd.call 'git fetch origin'
cmd.call 'git reset --hard origin/gh-pages'
end
end
end

0 comments on commit ae0557f

Please sign in to comment.