#!perl -w
my
$DEBUG
= 0;
my
$srcdir
=
"blib/lib"
;
my
$srcbindir
=
"blib/script"
;
my
$destrootdir
=
"blib/html"
;
my
$destsubdir
=
"site/lib"
;
my
$destbinsubdir
=
"bin"
;
my
$imgsrcdir
=
"docs"
;
print
BuildTools::macro_subst(
"Converting POD documentation to HTML for Win32::GUI v__W32G_VERSION__ on __W32G_DATE__\n"
);
doHtml(
$srcdir
,
$destrootdir
,
$destsubdir
);
doHtml(
$srcbindir
,
$destrootdir
,
$destbinsubdir
);
unlink
(
"pod2htmd.$_"
,
"pod2htmi.$_"
)
for
qw(x~~ tmp)
;
doGIF(
$imgsrcdir
, File::Spec->catfile(
$destrootdir
,
$destsubdir
,
"Win32"
));
exit
(0);
sub
doHtml
{
my
(
$srcdir
,
$htmlrootdir
,
$htmlsubdir
) =
@_
;
$srcdir
= File::Spec->canonpath(
$srcdir
);
$htmlrootdir
= File::Spec->canonpath(
$htmlrootdir
);
$htmlsubdir
= File::Spec->canonpath(
$htmlsubdir
);
my
%pods
= pod_find( {
-perl
=> 1},
$srcdir
);
for
my
$srcfile
(
keys
%pods
) {
next
if
$srcfile
=~ /demos[\/\\]/;
$srcfile
= File::Spec->abs2rel(
$srcfile
);
$srcfile
= File::Spec->canonpath(
$srcfile
);
my
$tmp
=
$srcfile
;
$tmp
=~ s/^\Q
$srcdir
\E//;
$tmp
= File::Spec->catfile(
$htmlrootdir
,
$htmlsubdir
,
$tmp
);
$tmp
= File::Spec->canonpath(
$tmp
);
(
my
$htmlfile
=
$tmp
) =~ s/\.[^.]*$/.html/;
print
STDERR
"Converting $srcfile to $htmlfile\n"
if
$DEBUG
;
my
(
undef
,
$dstdir
,
undef
) = File::Spec->splitpath(
$htmlfile
);
print
STDERR
"Creating directory $dstdir\n"
if
$DEBUG
;
mkpath(
$dstdir
);
my
$path2root
= File::Spec->abs2rel(
$htmlrootdir
,
$dstdir
);
(
my
$u_srcfile
=
$srcfile
) =~ s|\\|/|g;
(
my
$u_htmlfile
=
$htmlfile
) =~ s|\\|/|g;
(
my
$u_dstdir
=
$dstdir
) =~ s|\\|/|g;
(
my
$u_htmlroot
= File::Spec->catdir(
$path2root
,
$htmlsubdir
)) =~ s|\\|/|g;
(
my
$u_css
= File::Spec->catfile(
$path2root
,
"Active.css"
)) =~ s|\\|/|g;
my
@options
= (
"--infile=$u_srcfile"
,
"--outfile=$u_htmlfile"
,
"--htmldir=$u_dstdir"
,
"--htmlroot=$u_htmlroot"
,
"--css=$u_css"
,
"--header"
,
);
print
STDERR
"pod2html @options\n"
if
$DEBUG
;
pod2html(
@options
);
}
return
1;
}
{
my
(
$srcrootdir
,
$dstrootdir
);
sub
doGIF
{
my
(
$src
,
$dst
) =
@_
;
$srcrootdir
= File::Spec->canonpath(
$src
);
$dstrootdir
= File::Spec->canonpath(
$dst
);
find({
wanted
=>\
&found
,
no_chdir
=> 1},
$srcrootdir
);
return
1;
}
sub
found {
my
$file
= File::Spec->canonpath(
$_
);
if
(
$file
=~ /\.gif$/) {
(
my
$dstfile
=
$file
) =~ s/^\Q
$srcrootdir
\E//;
$dstfile
= File::Spec->catfile(
$dstrootdir
,
$dstfile
);
print
STDERR
"Copying $file to $dstfile\n"
if
$DEBUG
;
copy(
$file
,
$dstfile
);
}
}
}