Permalink
Browse files

add rake tasks to pull sinatra-contrib docs

  • Loading branch information...
1 parent c9829d0 commit 504a76ca545e84a96200e9a06b2758da09aab608 @gnandretta gnandretta committed Sep 11, 2011
Showing with 54 additions and 3 deletions.
  1. +1 −0 .gitignore
  2. +53 −3 Rakefile
View
@@ -1,3 +1,4 @@
_site
_book
+_contrib
_sinatra
View
@@ -9,6 +9,27 @@ def readme(pattern = "%s", &block)
end
end
+def contrib(pattern = "%s", &block)
+ return contrib(pattern).each(&block) if block_given?
+
+ %w[
+ sinatra-config-file
+ sinatra-multi-route
+ sinatra-content-for
+ sinatra-namespace
+ sinatra-cookies
+ sinatra-reloader
+ sinatra-decompile
+ sinatra-respond-with
+ sinatra-extension
+ sinatra-streaming
+ sinatra-json
+ sinatra-link-header
+ ].map do |extension|
+ pattern % extension
+ end
+end
+
# generates Table of Contents
def with_toc(src)
toc = "<div class='toc'>\n"
@@ -32,7 +53,7 @@ desc "Build outdated static files and API docs"
task :build => ['build:static']
desc "Build outdated static files"
-task 'build:static' => readme("_includes/%s.html")
+task 'build:static' => readme("_includes/%s.html") + contrib("_includes/%s.html")
desc "Build anything that's outdated and stage changes for next commit"
task :regen => [:build] do
@@ -41,8 +62,8 @@ task :regen => [:build] do
puts " git commit -m 'Regen prebuilt files'"
end
-desc 'Pull in the latest from the sinatra and sinatra-book repos'
-task :pull => ['pull:sinatra']
+desc 'Pull in the latest from the sinatra and sinatra-contrib repos'
+task :pull => ['pull:sinatra', 'pull:contrib']
desc 'Pull in the latest from the sinatra repo'
task 'pull:sinatra' do
@@ -72,6 +93,35 @@ readme do |fn|
CLEAN.include "_includes/#{fn}.html"
end
+desc 'Pull in the latest from the sinatra-contrib repo'
+task 'pull:contrib' do
+ if File.directory?("_contrib")
+ puts 'Pulling sinatra-contrib.git'
+ sh "cd _contrib && git pull &>/dev/null"
+ touch '_contrib', :verbose => false
+ else
+ puts 'Cloning sinatra-contrib repo'
+ sh "git clone git://github.com/sinatra/sinatra-contrib.git _contrib"
+ end
+ puts 'Building sinatra-contrib docs'
+ sh "cd _contrib && rake doc &>/dev/null"
+end
+
+file('_contrib') { Rake::Task['pull:contrib'].invoke }
+CLOBBER.include '_contrib'
+
+contrib("_contrib/doc/%s.rdoc") { |fn| file fn => '_contrib' }
+
+contrib do |fn|
+ file "_includes/#{fn}.html" => ["_contrib/doc/#{fn}.rdoc", "Rakefile"] do |f|
+ html =
+ RDoc::Markup::ToHtml.new.
+ convert(File.read("_contrib/doc/#{fn}.rdoc"))
+ File.open(f.name, 'wb') { |io| io.write html }
+ end
+ CLEAN.include "_includes/#{fn}.html"
+end
+
desc 'Rebuild site under _site with Jekyll'
task :jekyll do
rm_rf '_site'

0 comments on commit 504a76c

Please sign in to comment.