public
Fork of apache/buildr
Description: Apache Buildr
Homepage: http://buildr.apache.org
Clone URL: git://github.com/buildr/buildr.git
assaf (author)
Fri Mar 13 20:23:35 -0700 2009
commit  0087c24e532f37dab696bf202cd39b643ea10cef
tree    1b0e3d11d121ee8f9cb02402ae6ee30327ae9574
parent  0eee27f062a00425e21e066ddd9ebc699fdebb86
buildr / rakelib / doc.rake
100644 91 lines (77 sloc) 3.305 kb
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
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with this
# work for additional information regarding copyright ownership. The ASF
# licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
 
 
begin # For the Web site, we use the mislav-hanna RDoc theme (http://github.com/mislav/hanna/)
  require 'hanna/rdoctask'
 
  desc "Generate RDoc documentation in rdoc/"
  Rake::RDocTask.new :rdoc do |rdoc|
    rdoc.rdoc_dir = 'rdoc'
    rdoc.title = spec.name
    rdoc.options = spec.rdoc_options.clone
    rdoc.rdoc_files.include('lib/**/*.rb')
    rdoc.rdoc_files.include spec.extra_rdoc_files
  end
 
rescue LoadError
  puts "Buildr uses the mislav-hanna RDoc theme. You can install it by running rake setup"
  task(:setup) { install_gem 'mislav-hanna', :source=>'http://gems.github.com' }
end
 
 
begin
  require 'rakelib/jekylltask'
 
  desc "Generate Buildr documentation in _site/"
  JekyllTask.new :jekyll do |task|
    task.source = 'doc'
    task.target = '_site'
    task.pygments = true
  end
 
rescue LoadError
  puts "Buildr uses the mojombo-jekyll to generate the Web site. You can install it by running rake setup"
  task :setup do
    install_gem 'mojombo-jekyll', :source=>'http://gems.github.com', :version=>'0.4.1'
    if `pygmentize -V`.empty?
      args = %w{easy_install Pygments}
      args.unshift 'sudo' unless Config::CONFIG['host_os'] =~ /windows/
      sh *args
    end
  end
end
 
 
desc "Generate Buildr documentation as buildr.pdf"
file 'buildr.pdf'=>'_site' do |task|
  pages = File.read('doc/preface.textile').scan(/^#.*":(\S*)$/).flatten.map { |f| "_site/#{f}" }
  sh 'prince', '--input=html', '--no-network', '--log=prince_errors.log', "--output=#{task.name}", '_site/preface.html', *pages
end
 
desc "Build a copy of the Web site in the ./_site"
task :site=>['_site', :rdoc, '_reports/specs.html', '_reports/coverage', 'buildr.pdf'] do
  cp_r 'rdoc', '_site'
  fail 'No RDocs in site directory' unless File.exist?('_site/rdoc/files/lib/buildr_rb.html')
  cp '_reports/specs.html', '_site'
  cp_r '_reports/coverage', '_site'
  fail 'No coverage report in site directory' unless File.exist?('_site/coverage/index.html')
  cp 'CHANGELOG', '_site'
  cp 'buildr.pdf', '_site'
  fail 'No PDF in site directory' unless File.exist?('_site/buildr.pdf')
  puts 'OK'
end
 
# Publish prerequisites to Web site.
task 'publish'=>:site do
  target = "people.apache.org:/www/#{spec.name}.apache.org/"
  puts "Uploading new site to #{target} ..."
  sh 'rsync', '--progress', '--recursive', '--delete', '_site/', target
  sh 'ssh', 'people.apache.org', 'chmod', '-R', 'g+w', "/www/#{spec.name}.apache.org/*"
  puts "Done"
end
 
task :clobber do
  rm_rf '_site'
  rm 'buildr.pdf'
  rm 'prince_errors.log'
end