#!/usr/bin/env perl
use lib 'libs/cpan';
use lib 'libs/ext';
use Getopt::Long;
use Pod::Text;
use Pod::Autopod;
use strict;
my $options={};
GetOptions( $options,
"help|h" => \&help,
"readfile|r=s",
"writefile|w=s",
"version|v" => \&version,
"print|p",
"readdir|d=s",
"update|u",
"verbose",
"pod",
"poddir=s",
);
if ($options->{'readfile'} && !$options->{'writefile'} && !$options->{'print'}){
$options->{'writefile'} = $options->{'readfile'};
};
if (!$options->{'readfile'} && !$options->{'writefile'} && !$options->{'readdir'}){&help};
my $ap = new Pod::Autopod();
if ($options->{'readfile'}){ ## single files
$ap->readFile($options->{'readfile'});
$ap->writeFile($options->{'writefile'});
}
if ($options->{'readdir'}){ ## multiple files
my $work = { updateonly => $options->{'update'},
pod => $options->{'pod'},
poddir => $options->{'poddir'},
verbose => $options->{'verbose'},
};
$ap->readDirectory($options->{'readdir'},%$work);
}
if (($ap) && ($options->{'print'})){ ## for multiple files, it will print the last
print $ap->getPod();
}
sub help{
my $parser=new Pod::Text;
$parser->parse_from_file($0);
exit;
}
sub version{
print $Pod::Autopod::VERSION;
print "\n";
exit;
}
__END__
=pod
=head1 NAME
autopod - using the Perl library Pod::Autopod to generate javadoc like documentation with pod syntax. It is designed to understand perl code in class style, so typically PM files.
=head1 SYNOPSIS
autopod [F<OPTIONS>]
=head1 OPTIONS
The following options may be used:
=over 18
=item B<--help>
Prints this help.
=item B<--readfile | -r>
Perl module to be parsed for building a pod.
=item B<--writefile | -w>
Output file to write the pod.
If this filename has a "pm" extension, it also writes the perl code which was read from the origin.
If this filename has a "pod" extension or any other, it only writes the pod content.
If there is no --writefile used and no --print, it overwrites the file set via --readfile.
My personal warning: as long this is a new software, better backup your pm file before overwriting it directly.
=item B<--print | -p>
Instead of writing to a file, you can print to STDOUT the generated pod file.
e.g.: autopod -r Foo/Bar.pm -p
You may combine this line to pipe to further applications.
e.g.: autopod -r Foo/Bar.pm -p | pod2text
Do not use it in combination with readdir.
=item B<--readdir | -d>
Scans a directory recursiv for pm files and generates the pod for them.
=item B<--update | -u>
In combination with --readdir it updates only files which have been pod'ed with autopod in the past.
An alternative is to write somewhere in the pm file the magic word "AUTOPODME".
=item B<--pod>
In combination with --readdir it writes separat pod files instead of updating the original pm files.
They will be parallel to the pm file.
=item B<--poddir>
It writes the pod files to a separate directory. --pod is automatically enabled when using --poddir.
=item B<--verbose>
In combination with --readdir it prints the filenames which are written.
autopod.pl -d mylibs -u -verbose
=item B<--version | -v>
Prints the version of Pod::Autopod.
licence is LGPL
by Andreas Hernitscheck ahernit(AT)cpan.org
=back