Browse files

setup rocco

  • Loading branch information...
1 parent a2b9a68 commit fe82ceac351e9c5eb83691abdca505fb9a67cc57 @qrush committed Jan 11, 2012
Showing with 63 additions and 3 deletions.
  1. +1 −1 .gitignore
  2. +8 −0 Gemfile.lock
  3. +51 −1 Rakefile
  4. +3 −1 m.gemspec
View
2 .gitignore
@@ -7,11 +7,11 @@ Gemfile.lock
InstalledFiles
_yardoc
coverage
-doc/
lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp
+/docs
View
8 Gemfile.lock
@@ -12,7 +12,13 @@ GEM
method_source (0.6.7)
ruby_parser (>= 2.3.1)
multi_json (1.0.4)
+ mustache (0.99.4)
rake (0.9.2.2)
+ rdiscount (1.6.8)
+ redcarpet (2.0.1)
+ rocco (0.8.2)
+ mustache
+ redcarpet
ruby_parser (2.3.1)
sexp_processor (~> 3.0)
sexp_processor (3.0.9)
@@ -24,3 +30,5 @@ DEPENDENCIES
activesupport
m!
rake
+ rdiscount
+ rocco
View
52 Rakefile
@@ -1,10 +1,60 @@
#!/usr/bin/env rake
require "bundler/gem_tasks"
+require 'rake/clean'
require "rake/testtask"
-task :default => :test
+task :default => [:docs, :test]
Rake::TestTask.new do |t|
t.libs << 'test'
t.pattern = 'test/*_test.rb'
end
+
+# ROCCO ===============================================================
+
+require 'rdiscount'
+require 'rocco/tasks'
+Rocco::make 'docs/'
+
+desc 'Build rocco docs'
+task :docs => :rocco
+directory 'docs/'
+
+desc 'Build docs and open in browser for the reading'
+task :read => :docs do
+ sh 'open docs/lib/m.html'
+end
+
+# Make index.html a copy of rocco.html
+file 'docs/index.html' => 'docs/lib/m.html' do |f|
+ cp 'docs/lib/m.html', 'docs/index.html', :preserve => true
+end
+
+task :docs => 'docs/index.html'
+CLEAN.include 'docs/index.html'
+
+# Alias for docs task
+task :doc => :docs
+
+# GITHUB PAGES ===============================================================
+
+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
+
+# 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'
View
4 m.gemspec
@@ -11,8 +11,10 @@ Gem::Specification.new do |gem|
gem.version = "0.0.1"
gem.add_runtime_dependency "method_source", "~> 0.6.7"
- gem.add_development_dependency "rake"
gem.add_development_dependency "activesupport"
+ gem.add_development_dependency "rake"
+ gem.add_development_dependency "rdiscount"
+ gem.add_development_dependency "rocco"
gem.required_ruby_version = "~> 1.9"

0 comments on commit fe82cea

Please sign in to comment.