Skip to content
Newer
Older
100644 139 lines (120 sloc) 3.87 KB
40f0abf @rkh fix encoding issue
rkh authored Mar 29, 2012
1 # encoding: binary
9c27513 @rtomayko Thor is a sucky build tool; use Rake instead
rtomayko authored Jan 29, 2009
2 require 'rake/clean'
3 require 'rdoc/markup/to_html'
2535b16 @rkh add ToC to READMEs
rkh authored Jan 10, 2011
4 require 'uri'
9c27513 @rtomayko Thor is a sucky build tool; use Rake instead
rtomayko authored Jan 29, 2009
5
4b2600d @rkh Add all README translations to website.
rkh authored Oct 12, 2010
6 def readme(pattern = "%s", &block)
7 return readme(pattern).each(&block) if block_given?
016c3e7 @rkh add PT-PT readme
rkh authored Apr 11, 2011
8 %w[en de es fr hu jp zh ru pt-br pt-pt].map do |lang|
4b2600d @rkh Add all README translations to website.
rkh authored Oct 12, 2010
9 pattern % "README#{lang == "en" ? "" : ".#{lang}"}"
10 end
11 end
12
504a76c @gnandretta add rake tasks to pull sinatra-contrib docs
gnandretta authored Sep 10, 2011
13 def contrib(pattern = "%s", &block)
14 return contrib(pattern).each(&block) if block_given?
15
16 %w[
17 sinatra-config-file
18 sinatra-multi-route
19 sinatra-content-for
20 sinatra-namespace
21 sinatra-cookies
22 sinatra-reloader
23 sinatra-decompile
24 sinatra-respond-with
25 sinatra-extension
26 sinatra-streaming
27 sinatra-json
28 sinatra-link-header
29 ].map do |extension|
30 pattern % extension
31 end
32 end
33
2535b16 @rkh add ToC to READMEs
rkh authored Jan 10, 2011
34 # generates Table of Contents
345ccb2 @rkh update READMEs
rkh authored Jan 10, 2011
35 def with_toc(src)
2535b16 @rkh add ToC to READMEs
rkh authored Jan 10, 2011
36 toc = "<div class='toc'>\n"
37 last_level = 1
38 src = src.gsub(/<h(\d)>(.*)<\/h\d>/) do |line|
39 level, heading = $1.to_i, $2.strip
40 aname = URI.escape(heading)
41 toc << "\t"*last_level << "<ol class='level-#{level-1}'>\n" if level > last_level
42 toc << "\t"*level << "</ol>"*(last_level - level) << "\n" if level < last_level
43 toc << "\t"*level << "<li><a href='##{aname}'>#{heading}</a></li>\n"
44 last_level = level
45 "<a name='#{aname}'></a>\n" << line
46 end
47 toc << "\t" << "</ol>"*(last_level-1) << "\n</div>\n"
48 toc + src
49 end
50
1492c22 @rtomayko remove API, CHANGES, and book generation (external links now)
rtomayko authored Mar 7, 2010
51 task :default => ['_sinatra', :build]
9c27513 @rtomayko Thor is a sucky build tool; use Rake instead
rtomayko authored Jan 29, 2009
52
53 desc "Build outdated static files and API docs"
1492c22 @rtomayko remove API, CHANGES, and book generation (external links now)
rtomayko authored Mar 7, 2010
54 task :build => ['build:static']
9c27513 @rtomayko Thor is a sucky build tool; use Rake instead
rtomayko authored Jan 29, 2009
55
56 desc "Build outdated static files"
504a76c @gnandretta add rake tasks to pull sinatra-contrib docs
gnandretta authored Sep 11, 2011
57 task 'build:static' => readme("_includes/%s.html") + contrib("_includes/%s.html")
9c27513 @rtomayko Thor is a sucky build tool; use Rake instead
rtomayko authored Jan 29, 2009
58
59 desc "Build anything that's outdated and stage changes for next commit"
60 task :regen => [:build] do
61 sh 'git add api _includes'
62 puts "\nPrebuilt files regenerated and staged in your index. Commit with:"
63 puts " git commit -m 'Regen prebuilt files'"
64 end
65
504a76c @gnandretta add rake tasks to pull sinatra-contrib docs
gnandretta authored Sep 11, 2011
66 desc 'Pull in the latest from the sinatra and sinatra-contrib repos'
67 task :pull => ['pull:sinatra', 'pull:contrib']
9c27513 @rtomayko Thor is a sucky build tool; use Rake instead
rtomayko authored Jan 29, 2009
68
69 desc 'Pull in the latest from the sinatra repo'
70 task 'pull:sinatra' do
71 if File.directory?("_sinatra")
72 puts 'Pulling sinatra.git'
73 sh "cd _sinatra && git pull &>/dev/null"
74 touch '_sinatra', :verbose => false
75 else
76 puts 'Cloning sinatra repo'
77 sh "git clone git://github.com/sinatra/sinatra.git _sinatra"
78 end
79 end
80 file('_sinatra') { Rake::Task['pull:sinatra'].invoke }
81 CLOBBER.include '_sinatra'
82
4b2600d @rkh Add all README translations to website.
rkh authored Oct 12, 2010
83 readme("_sinatra/%s.rdoc") { |fn| file fn => '_sinatra' }
84 file 'AUTHORS' => '_sinatra'
9c27513 @rtomayko Thor is a sucky build tool; use Rake instead
rtomayko authored Jan 29, 2009
85
4b2600d @rkh Add all README translations to website.
rkh authored Oct 12, 2010
86 readme do |fn|
87 file "_includes/#{fn}.html" => ["_sinatra/#{fn}.rdoc", "Rakefile"] do |f|
88 html =
89 RDoc::Markup::ToHtml.new.
40f0abf @rkh fix encoding issue
rkh authored Mar 29, 2012
90 convert(File.binread("_sinatra/#{fn}.rdoc")).
4b2600d @rkh Add all README translations to website.
rkh authored Oct 12, 2010
91 sub("<h1>Sinatra</h1>", "")
2535b16 @rkh add ToC to READMEs
rkh authored Jan 10, 2011
92 File.open(f.name, 'wb') { |io| io.write with_toc(html) }
4b2600d @rkh Add all README translations to website.
rkh authored Oct 12, 2010
93 end
94 CLEAN.include "_includes/#{fn}.html"
02e9601 @sr hidden japanese translation of intro.html
sr authored Aug 12, 2009
95 end
96
504a76c @gnandretta add rake tasks to pull sinatra-contrib docs
gnandretta authored Sep 11, 2011
97 desc 'Pull in the latest from the sinatra-contrib repo'
98 task 'pull:contrib' do
99 if File.directory?("_contrib")
100 puts 'Pulling sinatra-contrib.git'
101 sh "cd _contrib && git pull &>/dev/null"
102 touch '_contrib', :verbose => false
103 else
104 puts 'Cloning sinatra-contrib repo'
105 sh "git clone git://github.com/sinatra/sinatra-contrib.git _contrib"
106 end
107 puts 'Building sinatra-contrib docs'
108 sh "cd _contrib && rake doc &>/dev/null"
109 end
110
111 file('_contrib') { Rake::Task['pull:contrib'].invoke }
112 CLOBBER.include '_contrib'
113
114 contrib("_contrib/doc/%s.rdoc") { |fn| file fn => '_contrib' }
115
116 contrib do |fn|
117 file "_includes/#{fn}.html" => ["_contrib/doc/#{fn}.rdoc", "Rakefile"] do |f|
118 html =
119 RDoc::Markup::ToHtml.new.
120 convert(File.read("_contrib/doc/#{fn}.rdoc"))
121 File.open(f.name, 'wb') { |io| io.write html }
122 end
123 CLEAN.include "_includes/#{fn}.html"
124 end
125
9c27513 @rtomayko Thor is a sucky build tool; use Rake instead
rtomayko authored Jan 29, 2009
126 desc 'Rebuild site under _site with Jekyll'
127 task :jekyll do
128 rm_rf '_site'
129 sh 'jekyll --pygments'
130 end
131
132 desc 'Start the Jekyll server on http://localhost:4000/'
133 task :server do
134 rm_rf '_site'
135 puts 'jekyll --pygments --auto --server'
136 exec 'jekyll --pygments --auto --server'
137 end
138 CLEAN.include '_site'
Something went wrong with that request. Please try again.