#!/usr/bin/env perl #-*- perl -*- # # Copyright (C) 2001 Ken'ichi Fukamachi # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # # $FML: dir2url.pl,v 1.3 2002/04/01 23:41:23 fukachan Exp $ # use strict; use Carp; use vars qw($WarningMessage); use File::Basename; my $Module; my $ModulePrefix; my $TableMode = 1; my $Prefix = dirname($0); Init(); HEADER(); Prepend(); Show(); FOOTER(); if ($WarningMessage) { print "*** warning ***\n"; print $WarningMessage; } exit 0; sub Init { my $pwd = `pwd`; chop($pwd); $pwd =~ s@^.*fml/lib@@; $pwd =~ s@^.*cpan/dist@@; $pwd =~ s@^.*cpan/lib@@; $pwd =~ s@^/@@; $ModulePrefix = $pwd; $ModulePrefix =~ s@/@::@g; $Module = $pwd . "::*"; } sub update_cvs_ignore { if ( -f ".cvsignore" ) { use FileHandle; my $fh = new FileHandle "> .cvsignore"; print $fh '@@doc', "\n"; close($fh); } } sub generate_manual { my ($pathname) = @_; my ($doc, $manual); if (-f $pathname) { -d '@@doc' || mkdir('@@doc', 0755); $manual = '@@doc/'.$pathname; $manual =~ s/pm$/txt/; $manual =~ s/$/.txt/ unless $manual =~ /txt$/; print STDERR "\tpod2text $pathname > $manual\n"; system "pod2text $pathname > $manual"; $manual = $pathname; $manual =~ s/pm$/ja.txt/; $doc = '@@doc/'.$pathname; $doc =~ s/pm$/ja.html/; if (-f $manual) { system "$Prefix/text2html.pl $manual > $doc"; } } } sub Prepend { my $found = 0; print "
$ModulePrefix class modules
\n"; print "
\n"; my $pointer = "pointer.ja.html"; if (-f $pointer) { use FileHandle; my $fh = new FileHandle $pointer; while (<$fh>) { print $_;} close($fh); $found++; } foreach (<*.txt>) { my $japanese = 0; /ja.txt/ && $japanese++; my $name = $_; $name =~ s/^00_//; $name =~ s/.txt$//; $name =~ s/.ja$//; print STDERR "\t*** include $_\n"; if (-f $_) { print "$name"; print "(Japanese)" if $japanese; print "\n"; $found++; } } print "
\n" if $found; } sub Show { my ($pathname, $manual); print ($TableMode ? "\n" : "\n" : "
  • \n"); print "
  • \n" : "
  • \n"); print "
  • \n" if $TableMode; if (-f "$pathname/index.ja.html") { print " "; if ($ModulePrefix) { print "${ModulePrefix}::${module}::* class\n"; } else { print "${module}::*\n"; } } else { if (-f "$pathname/README") { print " README\n"; } if ( -f "$pathname/INSTALL") { print " INSTALL\n"; } _warn("Error: *** fail to convert $pathname ***"); print "${pathname}/\n"; } } elsif ($pathname =~ /\.pm$/ || $pathname eq 'loader') { print ($TableMode ? "
    \n" if $TableMode; print " $module "; print "\n" if $TableMode; print "[source]\n"; print "\n" if $TableMode; print "[manual]\n" if -f $manual; my $doc = $manual; $doc =~ s/txt/ja.html/; print "\n" if $TableMode; print "[Japanese MEMO]\n" if -f $doc; } elsif ($pathname =~ /\.ja\.txt$/) { ; # see above } else { _warn("unknown file type $pathname"); } } print ($TableMode ? "
    \n" : "\n"); } sub HEADER { print <<"_EOF"; $Module classes _EOF } sub FOOTER { print <<'_EOF'; _EOF } sub _warn { my ($mesg) = @_; $WarningMessage .= $mesg . "\n"; } 1;