From f08fa8485200817ae9b7642264c409130d017f67 Mon Sep 17 00:00:00 2001 From: tdreyno Date: Sat, 12 Feb 2011 21:02:00 -0800 Subject: [PATCH] Add docs task and setup gh pages --- .gitignore | 1 + Rakefile | 44 ++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 62c23c1b..97732078 100755 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ pkg .sassc .tmp Gemfile.lock +docs diff --git a/Rakefile b/Rakefile index 26fdde37..c545dd3a 100644 --- a/Rakefile +++ b/Rakefile @@ -7,10 +7,46 @@ Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t| t.cucumber_opts = "--color --tags ~@wip --strict --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}" end +#$LOAD_PATH.unshift 'lib' + +require 'rake/testtask' +require 'rake/clean' + task :test => :cucumber -namespace :build do - task :docs do - `rocco lib/*.rb --output=docs` +# Bring in Rocco tasks +require 'rocco/tasks' +Rocco::make 'docs/' + +desc 'Build rocco docs' +task :docs => :rocco +directory 'docs/' + + +# Make index.html a copy of rocco.html +file 'docs/index.html' => 'docs/lib/middleman.html' do |f| + cp 'docs/lib/middleman.html', 'docs/index.html', :preserve => true +end +task :docs => 'docs/index.html' +CLEAN.include 'docs/index.html' + +desc 'Update gh-pages branch' +task :pages => ['docs/.git', :docs] do + rev = `git rev-parse --short HEAD`.strip + Dir.chdir 'docs' do + sh "git add *.html" + sh "git commit -m 'rebuild pages from #{rev}'" do |ok,res| + if ok + verbose { puts "gh-pages updated" } + sh "git push -q o HEAD:gh-pages" + end + end end -end \ No newline at end of file +end + +# Update the pages/ directory clone +file 'docs/.git' => ['docs/', '.git/refs/heads/gh-pages'] do |f| + sh "cd docs && git init -q && git remote add o ../.git" if !File.exist?(f.name) + sh "cd docs && git fetch -q o && git reset -q --hard o/gh-pages && touch ." +end +CLOBBER.include 'docs/.git' \ No newline at end of file