Permalink
Browse files

better pages tasks

  • Loading branch information...
1 parent 7e2b0b0 commit 24fa481ee5addc57280811de680581a88e385be3 @defunkt committed Oct 7, 2009
Showing with 27 additions and 11 deletions.
  1. +27 −11 lib/sdoc_helpers/pages.rb
View
@@ -1,20 +1,36 @@
require 'rake/rdoctask'
+readme = Dir['*'].grep(/README/)[0]
+
Rake::RDocTask.new do |rdoc|
- rdoc.main = 'README.md'
- rdoc.rdoc_files = %w( README.md LICENSE lib )
+ rdoc.main = readme
+ rdoc.rdoc_files = [ readme, 'LICENSE', 'lib' ]
rdoc.rdoc_dir = 'docs'
end
-desc "Build and publish documentation using GitHub Pages."
-task :pages do
- if !`git status`.include?('nothing to commit')
- abort "dirty index - not publishing!"
+namespace :pages do
+ task :publish => [ :check_dirty, :rerdoc ] do
+ `git checkout gh-pages`
+ `ls -1 | grep -v docs | xargs rm -rf; mv docs/* .; rm -rf docs`
+ `git commit -a -m "update docs"; git push origin gh-pages`
+ `git checkout master`
+ end
+
+ desc "Initialize GitHub Pages with documentation"
+ task :init => [ :check_dirty, :rerdoc ] do
+ `git symbolic-ref HEAD refs/heads/gh-pages`
+ `rm .git/index`
+ `ls -1 | grep -v docs | xargs rm -rf; mv docs/* .; rm -rf docs`
+ `git add .;git commit -m "create docs"; git push origin gh-pages`
+ `git checkout master`
end
- Rake::Task[:rerdoc].invoke
- `git checkout gh-pages`
- `ls -1 | grep -v docs | xargs rm -rf; mv docs/* .; rm -rf docs`
- `git commit -a -m "update docs"; git push origin gh-pages`
- `git checkout master`
+ task :check_dirty do
+ if !`git status`.include?('nothing to commit')
+ abort "dirty index - not publishing!"
+ end
+ end
end
+
+desc "Build and publish documentation using GitHub Pages."
+task :pages => "pages:publish"

0 comments on commit 24fa481

Please sign in to comment.