This repository has been archived by the owner on Jun 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Rakefile
112 lines (84 loc) · 2.88 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# -*- ruby encoding: utf-8 -*-
require 'rubygems'
require 'hoe'
Hoe.plugin :doofus
Hoe.plugin :gemspec
Hoe.plugin :rubyforge
Hoe.plugin :git
Hoe.plugin :hg
Hoe.spec 'rubypython' do
self.rubyforge_name = self.name
developer('Steeve Morin', 'swiuzzz+rubypython@gmail.com')
developer('Austin Ziegler', 'austin@rubyforge.org')
developer('Zach Raines', 'raineszm+rubypython@gmail.com')
self.remote_rdoc_dir = 'rdoc'
self.rsync_args << ' --exclude=statsvn/'
self.history_file = 'History.rdoc'
self.readme_file = 'README.rdoc'
self.extra_rdoc_files = FileList["*.rdoc"].to_a
self.extra_deps << ['ffi', '>= 1.0.7']
self.extra_deps << ['blankslate', '>= 2.1.2.3']
self.extra_dev_deps << ['rspec', '~> 2.0']
self.extra_dev_deps << ['tilt', '~> 1.0']
self.spec_extras[:requirements] = [ "Python, ~> 2.4" ]
end
unless Rake::Task.task_defined? :test
task :test => :spec
end
namespace :website do
desc "Build the website files."
task :build => [ "website/index.html" ]
deps = FileList["website/**/*"].exclude { |f| File.directory? f }
deps.include(*%w(Rakefile))
deps.include(*FileList["*.rdoc"].to_a)
deps.exclude(*%w(website/index.html website/images/*))
file "website/index.html" => deps do |t|
require 'tilt'
require 'rubypython'
puts "Generating #{t.name}…"
# Let's modify the rdoc for presenation purposes.
body_rdoc = File.read("README.rdoc")
contrib = File.read("Contributors.rdoc")
body_rdoc.gsub!(/^:include: Contributors.rdoc/, contrib)
license = File.read("License.rdoc")
body_rdoc.sub!(/^:include: License.rdoc/, license)
toc_elements = body_rdoc.scan(/^(=+) (.*)$/)
toc_elements.map! { |e| [ e[0].count('='), e[1] ] }
body_rdoc.gsub!(/^(=.*)/) { "#{$1.downcase}" }
body = Tilt::RDocTemplate.new(nil) { body_rdoc }.render
title = nil
body.gsub!(%r{<h1>(.*)</h1>}) { title = $1; "" }
toc_elements = toc_elements.select { |e| e[0].between?(2, 3) }
last_level = 0
toc = ""
toc_elements.each do |element|
level, text = *element
ltext = text.downcase
id = text.downcase.gsub(/[^a-z]+/, '-')
body.gsub!(%r{<h#{level}>#{ltext}</h#{level}>}) {
%Q(<h#{level} id="#{id}">#{ltext}</h#{level}>)
}
if last_level != level
if level > last_level
toc << "<ol>"
else
toc << "</li></ol></li>"
end
last_level = level
end
toc << %Q(<li><a href="##{id}">#{text}</a>)
end
toc << "</li></ol>"
template = Tilt.new("website/index.rhtml", :trim => "<>%")
context = {
:title => title,
:toc => toc,
:body => body,
:download => "http://rubyforge.org/frs/?group_id=6737",
:version => RubyPython::VERSION,
:modified => Time.now
}
File.open(t.name, "w") { |f| f.write template.render(self, context) } end
end
task "docs" => "website:build"
# vim: syntax=ruby