#!/usr/local/bin/perl
###############################################################################
#
# PerlモジュールからAPIリファレンスを作成するためのスクリプト
#
###############################################################################
my $file = $ARGV[0];
my $buf = "";
my $count = 0;
print "\n";
print "
\n";
print "Module Reference\n";
print "\n";
print "\n";
print "\n";
open(DATA,$file);
while(my $LINE = ){
if($LINE =~ /^sub (.+){/){
my $subname = $1;
unless($subname =~ /^_/){
print "".&escapeHTML($subname)."
\n";
print $buf;
}
$buf = "";
$count = 0;
} elsif($LINE =~ /package (.+);/){
print "".&escapeHTML($1)."
\n";
print $buf;
$buf = "";
$count = 0;
} elsif($LINE =~ /^\#\#/ || $LINE=~ /^\#==/ || $LINE =~ /^\#--/){
if($count!=0){
$buf = "";
}
$count++;
} elsif($LINE =~ /^\#(.+)/){
my $comment = $1;
if($comment =~ /^\s+){
$comment =~ s/^\s+//g;
}
$count = 0;
$buf .= $comment."\n";
}
}
close(DATA);
print "\n";
print "\n";
print "\n";
sub escapeHTML {
my($retstr) = shift;
my %table = (
'&' => '&',
'"' => '"',
'<' => '<',
'>' => '>',
);
$retstr =~ s/([&\"<>])/$table{$1}/go;
return $retstr;
}