diff options
| author | fukachan <fukachan> | 2001-04-30 11:43:32 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2001-04-30 11:43:32 +0000 |
| commit | dbf92646ceba464133b227419d81d6288aa82129 (patch) | |
| tree | 211819e0a7cfa4a4d131da32532a7e2a41e4fbfb /fml/utils | |
| parent | 0d57b10f72bf3ab6e1e984e15d759e973ce3d891 (diff) | |
| download | fml8-dbf92646ceba464133b227419d81d6288aa82129.tar.gz fml8-dbf92646ceba464133b227419d81d6288aa82129.tar.bz2 fml8-dbf92646ceba464133b227419d81d6288aa82129.zip | |
move doc/bin/ to fml/utils/bin/
Diffstat (limited to 'fml/utils')
| -rwxr-xr-x | fml/utils/bin/dir2url.pl | 248 | ||||
| -rwxr-xr-x | fml/utils/bin/distdir2url.pl | 85 | ||||
| -rwxr-xr-x | fml/utils/bin/html2sgml.pl | 140 | ||||
| -rwxr-xr-x | fml/utils/bin/text2html.pl | 56 |
4 files changed, 529 insertions, 0 deletions
diff --git a/fml/utils/bin/dir2url.pl b/fml/utils/bin/dir2url.pl new file mode 100755 index 00000000..e08d6093 --- /dev/null +++ b/fml/utils/bin/dir2url.pl @@ -0,0 +1,248 @@ +#!/usr/local/bin/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. +# +# $Id$ +# $FML$ +# + +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 "<CENTER><EM>$ModulePrefix class modules</EM></CENTER>\n"; + print "<HR>\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 "<A HREF=\"$_\">$name"; + print "(Japanese)" if $japanese; + print "</A>\n"; + $found++; + } + } + + print "<HR>\n" if $found; +} + + +sub Show +{ + my ($pathname, $manual); + + print ($TableMode ? "<TABLE>\n" : "<UL>\n"); + + update_cvs_ignore(); + + foreach $pathname (<*>) { + next if $pathname =~ /^\__template/; + next if $pathname =~ /^\@/; + next if $pathname =~ /\~$/; + next if $pathname =~ /txt$/; + next if $pathname =~ /html$/; + next if $pathname =~ /pod$/; + next if $pathname eq 'CVS'; + next if $pathname eq 't'; # test directory + next if $pathname =~ /^index/; + next if $pathname eq 'Makefile'; + + my $module = $pathname; + if ($module =~ /\.pm$/ || $module eq 'loader') { + generate_manual($pathname); + } + + $manual = '@@doc/'.$pathname; + $manual =~ s/pm$/txt/; + $manual =~ s/$/.txt/ unless $manual =~ /txt$/; + + if (-d $pathname) { + print ($TableMode ? "<TR>\n" : "<LI>\n"); + print "<TD>\n" if $TableMode; + + if (-f "$pathname/index.ja.html") { + print " <A HREF=$pathname/index.ja.html>"; + + if ($ModulePrefix) { + print "${ModulePrefix}::${module}::* class</A>\n"; + } + else { + print "${module}::*</A>\n"; + } + } + else { + if (-f "$pathname/README") { + print " <A HREF=$pathname/README>README</A>\n"; + } + + if ( -f "$pathname/INSTALL") { + print " <A HREF=$pathname/INSTALL>INSTALL</A>\n"; + } + + _warn("Error: *** fail to convert $pathname ***"); + print "${pathname}/\n"; + } + } + elsif ($pathname =~ /\.pm$/ || $pathname eq 'loader') { + print ($TableMode ? "<TR>\n" : "<LI>\n"); + print "<TD>\n" if $TableMode; + print " $module "; + + print "<TD>\n" if $TableMode; + print "<A HREF=\"$pathname\">[source]</A>\n"; + + print "<TD>\n" if $TableMode; + print "<A HREF=\"$manual\">[manual]</A>\n" if -f $manual; + + my $doc = $manual; + $doc =~ s/txt/ja.html/; + print "<TD>\n" if $TableMode; + print "<A HREF=\"$doc\">[Japanese MEMO]</A>\n" if -f $doc; + } + elsif ($pathname =~ /\.ja\.txt$/) { + ; # see above + } + else { + _warn("unknown file type $pathname"); + } + } + + print ($TableMode ? "</TABLE>\n" : "</UL>\n"); +} + + +sub HEADER +{ + +print <<"_EOF"; +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> +<TITLE> +$Module classes +</TITLE> +<META http-equiv="Content-Type" + content="text/html; charset=EUC-JP"> +</HEAD> + +<BODY BGCOLOR="#E6E6FA"> +_EOF + +} + + +sub FOOTER +{ + +print <<'_EOF'; +</BODY> +</HTML> +_EOF + +} + + +sub _warn +{ + my ($mesg) = @_; + $WarningMessage .= $mesg . "\n"; +} + + +1; diff --git a/fml/utils/bin/distdir2url.pl b/fml/utils/bin/distdir2url.pl new file mode 100755 index 00000000..69aee409 --- /dev/null +++ b/fml/utils/bin/distdir2url.pl @@ -0,0 +1,85 @@ +#!/usr/local/bin/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. +# +# $Id$ +# $FML$ +# + +use strict; +use Carp; + +my $Module; + +HEADER(); +Show(); +FOOTER(); + + +exit 0; + + +sub Show +{ + print "<CENTER>\n"; + print "<TABLE>\n"; + + foreach my $pathname (<*>) { + next if $pathname =~ /^\__template/; + next if $pathname =~ /^\@/; + next if $pathname =~ /\~$/; + next if $pathname =~ /pod$/; + next if $pathname eq 'CVS'; + next if $pathname =~ /^index/; + next if $pathname =~ /^00_/; + next if $pathname eq 'Makefile'; + + print "<TR>\n"; + print "<TD> $pathname \n"; + + for my $fn ("README", "INSTALL", "MANIFEST") { + print "<TD>"; + if (-f "$pathname/$fn") { + print "<A HREF=\"$pathname/$fn\">$fn</A>\n"; + } + print "\n"; + } + } + + print "</TABLE>\n"; + print "</CENTER>\n"; +} + + +sub HEADER +{ + +print <<"_EOF"; +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> +<TITLE> +$Module classes +</TITLE> +<META http-equiv="Content-Type" + content="text/html; charset=EUC-JP"> +</HEAD> + +<BODY BGCOLOR="#E6E6FA"> +_EOF + +} + + +sub FOOTER +{ + +print <<'_EOF'; +</BODY> +</HTML> +_EOF + +} diff --git a/fml/utils/bin/html2sgml.pl b/fml/utils/bin/html2sgml.pl new file mode 100755 index 00000000..bf14d0f2 --- /dev/null +++ b/fml/utils/bin/html2sgml.pl @@ -0,0 +1,140 @@ +#!/usr/local/bin/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: html2sgml.pl,v 1.3 2001/04/24 13:46:31 fukachan Exp $ +# + +use strict; +use Carp; +use vars qw($TR); +use FileHandle; + +my $para = ''; +my $hr = 0; +my $tr = 0; +my $listitem = 0; + +for my $file (@ARGV) { + my $rh; + + my $tmpf = "/tmp/html2sgml.$$"; + my $wh = new FileHandle "> $tmpf"; + convert($file, $rh, $wh); + $wh->close; + + my $rh = new FileHandle $tmpf; + fix_output($rh); + + unlink $tmpf; +} + +exit 0; + + +sub convert +{ + my ($file, $rh, $wh) = @_; + + my $fh = new FileHandle $file; + + while (<$fh>) { + # <P> + if (m@<P>@i) { + print $wh "<para>\n"; + $para = 1; + next; + } + + if (/^\s*$/ && $para) { + print $wh "\t" if $para eq 'tab'; + print $wh "</para>\n\n"; + $para = 0; + } + + # HR + if (m@<HR>@i) { + print $wh "</sect1>\n" if $hr; + s@<HR>@<sect1>@gi; + $hr = 1; + } + + # A + s@<A\s*HREF=@\n<ulink url=@gi; + s@</A>@\n</ulink>\n@gi; + + # PRE + s@<PRE>@<programlisting>@gi; + s@</PRE>@</programlisting>@gi; + + # UL + s@<UL>@<itemizedlist>@gi; + s@</UL>@</itemizedlist>@gi; + + if (m@<LI>@i) { + print $wh "\t" if $para eq 'tab' && $listitem; + print $wh "\t</listitem>\n\n" if $listitem; + s@<LI>@<listitem>\n\t<para>\n\t@gi; + $para = "tab"; + $listitem = 1; + } + + if (m@</itemizedlist>@) { + print $wh "\t" if $para eq 'tab' && $listitem;; + print $wh "\t</listitem>\n\n" if $listitem; + $listitem = 0; + } + + + # BR + s@<HR>@@gi; + s@<BR>@@gi; + s@<EM>@@gi; + s@</EM>@@gi; + s@<B>@@gi; + s@</B>@@gi; + s@<I>@@gi; + s@</I>@@gi; + + + # TABLE + s@<TABLE.*>@<table>\n <tgroup cols=2>\n@gi; + s@</TABLE>@\n </tgroup>\n</table>@gi; + if (m@<TR>@) { + $TR = $TR ? 'tbody' : 'thead'; + $tr++; + s@<TR>@<$TR>\n\t<row>@gi; + } + + if (m@<TD>@) { + s@<TD>@<entry>@; + s@$@\n\t</entry>@; + } + + if ($tr && /^\s*$/) { + print $wh "\t</row>\n"; + print $wh " </${TR}>\n"; + $tr = 0; + } + + print $wh $_; + } +} + + +sub fix_output +{ + my ($rh) = @_; + my $buf; + + while (<$rh>) { + $buf .= $_; + } + + $buf =~ s@</tbody>[\s\n]*<tbody>@\n@g; + + print $buf; +} diff --git a/fml/utils/bin/text2html.pl b/fml/utils/bin/text2html.pl new file mode 100755 index 00000000..321ff8b2 --- /dev/null +++ b/fml/utils/bin/text2html.pl @@ -0,0 +1,56 @@ +#!/usr/local/bin/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. +# +# $Id$ +# $FML$ +# + +use strict; +use Carp; + + +&HEADER; +print "<PRE>\n"; +while (<>) { print $_;} +print "</PRE>\n"; +&FOOTER; + +1; + + +sub HEADER +{ + +print <<"_EOF"; +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> +<TITLE> +$ARGV[0] +</TITLE> +<META http-equiv="Content-Type" + content="text/html; charset=EUC-JP"> +</HEAD> + +<BODY BGCOLOR="#E6E6FA"> +_EOF + +} + + +sub FOOTER +{ + +print <<'_EOF'; +</BODY> +</HTML> +_EOF + +} + + +1; |
