1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00

doc/website cleanup

This commit is contained in:
Ryan Tomayko 2008-11-02 04:51:09 -08:00
parent fe1ed270d0
commit 69293f6ced
7 changed files with 60 additions and 81 deletions

4
.gitignore vendored
View file

@ -1,6 +1,6 @@
*.log
.DS_Store
/dist
/doc/website
/doc/book
/book
/doc/api
/doc/*.html

View file

@ -1,7 +1,6 @@
require 'rubygems'
require 'rake/clean'
require 'fileutils'
require 'hpricot'
task :default => :test
@ -70,6 +69,29 @@ task 'publish:gem' => [package('.gem'), package('.tar.gz')] do |t|
end
# Website ============================================================
# Building docs requires HAML and the hanna gem:
# gem install mislav-hanna --source=http://gems.github.com
task 'doc' => ['doc:api','doc:site']
desc 'Generate Hanna RDoc under doc/api'
task 'doc:api' => ['doc/api/index.html']
file 'doc/api/index.html' => FileList['lib/**/*.rb','README.rdoc'] do |f|
rb_files = f.prerequisites
sh((<<-end).gsub(/\s+/, ' '))
hanna --charset utf8 \
--fmt html \
--inline-source \
--line-numbers \
--main README.rdoc \
--op doc/api \
--title 'Sinatra API Documentation' \
#{rb_files.join(' ')}
end
end
CLEAN.include 'doc/api'
def rdoc_to_html(file_name)
require 'rdoc/markup/to_html'
rdoc = RDoc::Markup::ToHtml.new
@ -83,31 +105,39 @@ def haml(locals={})
haml.render(Object.new, locals)
end
directory 'doc/website'
desc 'Build website HTML and stuff'
task 'doc:site' => ['doc/index.html', 'doc/book.html']
desc 'Build website'
task :website => ['doc/website/book.html', 'doc/website/index.html', :doc]
file 'doc/website/index.html' => 'doc/website' do |file|
file 'doc/index.html' => %w[README.rdoc doc/template.haml] do |file|
File.open(file.name, 'w') do |file|
file << haml(:title => 'Sinatra', :content => rdoc_to_html('README.rdoc'))
end
end
CLEAN.include 'doc/index.html'
file 'doc/website/book.html' => ['doc/website', :build_book] do |file|
file 'doc/book.html' => ['book/output/sinatra-book.html'] do |file|
File.open(file.name, 'w') do |file|
book_content = File.read('doc/book/output/sinatra-book.html')
book_content = File.read('book/output/sinatra-book.html')
file << haml(:title => 'Sinatra Book', :content => book_content)
end
end
CLEAN.include 'doc/book.html'
task :build_book do
unless File.directory?('doc/book')
sh 'git clone git://github.com/cschneid/sinatra-book.git doc/book'
file 'book/output/sinatra-book.html' => FileList['book/**'] do |f|
unless File.directory?('book')
sh 'git clone git://github.com/cschneid/sinatra-book.git book'
end
sh 'cd doc/book && git fetch origin && git rebase origin/master'
sh 'cd doc/book && thor book:build'
sh((<<-SH).strip.gsub(/\s+/, ' '))
cd book &&
git fetch origin &&
git rebase origin/master &&
thor book:build
SH
end
CLEAN.include 'book/output/sinatra-book.html'
desc 'Build the Sinatra book'
task 'doc:book' => ['book/output/sinatra-book.html']
# Gemspec Helpers ====================================================
@ -130,27 +160,3 @@ file 'sinatra.gemspec' => FileList['{lib,test,images}/**','Rakefile'] do |f|
File.open(f.name, 'w') { |io| io.write(spec) }
puts "updated #{f.name}"
end
# Hanna RDoc =========================================================
#
# Building docs requires the hanna gem:
# gem install mislav-hanna --source=http://gems.github.com
desc 'Generate Hanna RDoc under doc/api'
task :doc => ['doc/website/api/index.html']
file 'doc/website/api/index.html' => FileList['lib/**/*.rb','README.rdoc'] do |f|
rb_files = f.prerequisites
sh((<<-end).gsub(/\s+/, ' '))
rdoc --charset utf8 \
--fmt html \
--inline-source \
--line-numbers \
--main README.rdoc \
--op doc/website/api \
--title 'Sinatra API Documentation' \
#{rb_files.join(' ')}
end
end
CLEAN.include 'doc/website'

View file

@ -2,18 +2,19 @@
%html
%head
%title= title
%link{ :media => 'screen', :type => 'text/css', :href => '/sinatra.css', :rel => 'stylesheet' }
%link{ :media => 'screen', :type => 'text/css', :href => 'sinatra.css', :rel => 'stylesheet' }
%body
#page
%h1
%a{ :href => '/'}= 'Sinatra'
%ul#navigation
%li
%a{ :href => '/' } The Hat
%li
%a{ :href => '/book' } The Book
%li
%a{ :href => '/api' } The API
%li
%a{ :href => 'http://github.com/bmizerany/sinatra' } The Source
#content= content
#content
%a{ :href => './'}
%img{ :src => "sinatra-logo.gif", :width => 156, :height => 108, :alt => 'Hat' }
%div#navigation
%ul
%li
%a{ :href => './' } The Hat
%li
%a{ :href => './book' } The Book
%li
%a{ :href => './api' } The API
%li
%a{ :href => 'http://github.com/bmizerany/sinatra' } The Source
%div.inner~ content

View file

@ -1,28 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Sinatra.rb</title>
<link rel="stylesheet" href="/master.css" type="text/css" media="screen" />
</head>
<body>
<div id="content">
<a href="/"><img src="/sinatra-logo.gif" width="156" height="108" alt="Sinatra Logo" title=""></a>
<div id="navigation">
<ul>
<li><a href="/">The Hat</a></li>
<li><a href="http://sinatra-book.gittr.com/">The Book</a></li>
<li><a href="/api">The API</a></li>
<li><a href="http://github.com/bmizerany/sinatra">The Source</a></li>
</ul>
</div><!-- /navigation -->
<div class="inner">
{{REPLACE}}
</div><!-- /inner -->
</div><!-- /content -->
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB