diff options
| author | fukachan <fukachan> | 2001-04-27 04:42:13 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2001-04-27 04:42:13 +0000 |
| commit | 65be5005615e748aa987537ca89f8b22e9bad849 (patch) | |
| tree | 7deacfa583dde64068f24edda84aaace586fa269 /fml/utils | |
| parent | 38d1a13ab9e4e9a0f18d32e50a9533794b9292fe (diff) | |
| download | fml8-65be5005615e748aa987537ca89f8b22e9bad849.tar.gz fml8-65be5005615e748aa987537ca89f8b22e9bad849.tar.bz2 fml8-65be5005615e748aa987537ca89f8b22e9bad849.zip | |
prototype of new documentation hierarchy
recursive conversion from .pm to .txt
to convert from sgml to html, run "make clean, make and make clean"
Diffstat (limited to 'fml/utils')
| -rwxr-xr-x | fml/utils/bin/pm2txt.pl | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/fml/utils/bin/pm2txt.pl b/fml/utils/bin/pm2txt.pl new file mode 100755 index 00000000..02f01e94 --- /dev/null +++ b/fml/utils/bin/pm2txt.pl @@ -0,0 +1,100 @@ +#!/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$ +# + +use strict; +use Carp; +use vars qw($debug); +use FileHandle; +use File::stat; + +convert(@ARGV); + +exit 0; + + +sub convert +{ + my ($src_dir, $dst_dir) = @_; + + print STDERR "convert $src_dir/ => $dst_dir/\n\n"; + + _mkdir(@_); + _convert(@_); +} + + +sub _mkdir +{ + my ($src_dir, $dst_dir) = @_; + + print STDERR "\nchecking directory under $dst_dir\n" if $debug; + my $fh = new FileHandle; + open($fh, "find $src_dir -type d -print|"); + while (<$fh>) { + next if /CVS/; + + chop; + s/$src_dir//; + s@^/@@; + + my $dir = "$dst_dir/$_"; + unless (-d $dir) { + print STDERR " mkdir $dir\n"; + mkdir($dir, 0755); + } + } + close($fh); +} + + +sub _convert +{ + my ($src_dir, $dst_dir) = @_; + my ($src, $dst); + my ($sstat, $dstat, $go); + + my $fh = new FileHandle; + open($fh, "find $src_dir -type f -print|"); + while (<$fh>) { + next if /__template.pm/; + next unless /\.pm$/; + chop; + + $dst = $src = $_; + $dst =~ s/$src_dir/$dst_dir/; + $dst =~ s@^/@@; + $dst =~ s@//@/@g; + $dst =~ s/.pm/.txt/; + + $go = 0; + $sstat = stat($src) || croak("cannot stat $src"); + + if (-f $dst) { + $dstat = stat($dst) || croak("cannot stat $dst"); + $go = 1 if ( $sstat->mtime > $dstat->mtime ); + } + else { + $go = 1; + } + + if ( $go ) { + print STDERR " pod2text $src > $dst.new\n"; + system "pod2text $src > $dst.new"; + print STDERR " rename $dst.new $dst\n"; + unless (rename("$dst.new", $dst)) { + print STDERR "\t*** conversion error ***\n"; + } + } + } + close($fh); +} + + +1; |
