| 1 |
#!/usr/bin/ruby |
| 2 |
# |
| 3 |
# gendoc.rb: A short program to generate class specifications of Edmaru. |
| 4 |
# |
| 5 |
# Copyright (C) 2007 Takashi Nakamoto |
| 6 |
# |
| 7 |
# This program is free software; you can redistribute it and/or modify |
| 8 |
# it under the terms of the GNU General Public License version 2 as |
| 9 |
# published by the Free Software Foundation. |
| 10 |
# |
| 11 |
# This program is distributed in the hope that it will be useful, but |
| 12 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 |
# General Public License for more details. |
| 15 |
# |
| 16 |
# You should have received a copy of the GNU General Public License |
| 17 |
# along with this program; if not, write to the Free Software |
| 18 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 19 |
# 02110-1301 USA. |
| 20 |
# |
| 21 |
|
| 22 |
args = Array.new |
| 23 |
|
| 24 |
# Set UTF-8 as HTML character sets. |
| 25 |
args.push "--charset" |
| 26 |
args.push "utf-8" |
| 27 |
|
| 28 |
# Include line numbers in source codes |
| 29 |
args.push "--line-numbers" |
| 30 |
|
| 31 |
# Generate diagrams showing modules and classes. |
| 32 |
if ARGV.include?("-d") |
| 33 |
args.push "--diagram" |
| 34 |
end |
| 35 |
|
| 36 |
# Png format will be used as image format for diagrams. |
| 37 |
if args.include?("--diagram") |
| 38 |
args.push "--image-format" |
| 39 |
args.push "png" |
| 40 |
end |
| 41 |
|
| 42 |
# Set "doc" as the output directory |
| 43 |
args.push "--op" |
| 44 |
args.push "doc/rdoc" |
| 45 |
|
| 46 |
# Update all documentation forcibly. |
| 47 |
args.push "--force-update" |
| 48 |
|
| 49 |
# Title of generated documents. |
| 50 |
args.push "--title" |
| 51 |
args.push "'Edmaru API reference'" |
| 52 |
|
| 53 |
# Link to WebCVS. |
| 54 |
args.push "--webcvs" |
| 55 |
args.push "http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi/%s?root=edmaru&view=log" |
| 56 |
|
| 57 |
# Use the original template. |
| 58 |
args.push "--template" |
| 59 |
args.push "./rdoc_template" |
| 60 |
|
| 61 |
# Don't generate the documents of unrelated files to Edmaru. |
| 62 |
#args.push "--exclude" |
| 63 |
#args.push "rdoc" |
| 64 |
|
| 65 |
# Set README as the top page of API reference. |
| 66 |
args.push "--main" |
| 67 |
args.push "README" |
| 68 |
|
| 69 |
# Files parsed by RDoc. |
| 70 |
require "find" |
| 71 |
search_dir = "./" |
| 72 |
Find.find(search_dir){ |f| |
| 73 |
f = f[(search_dir.size)..-1] |
| 74 |
case f |
| 75 |
when /\.rb\Z/, "AUTHORS", "COPYING", "ChangeLog", "README", |
| 76 |
/\Adoc\/[A-Z]*\Z/ |
| 77 |
args.push f |
| 78 |
end |
| 79 |
} |
| 80 |
|
| 81 |
# main procedure to generate class specification |
| 82 |
require "rdoc/rdoc" |
| 83 |
begin |
| 84 |
r = RDoc::RDoc.new |
| 85 |
r.document(args) |
| 86 |
rescue RDoc::RDocError => e |
| 87 |
$stderr.puts e.message |
| 88 |
exit(1) |
| 89 |
end |