Devel-ModInfo
view release on metacpan or search on metacpan
modinfo2embpod.PL view on Meta::CPAN
# create Template object
my $template = Template->new($config);
# define template variables for replacement
my $vars = {
modinfo => $modinfo,
};
# process input template, substituting variables
while(my $line = <$pm_file_in>) {
print $pm_file_out $line;
last if $line =~ /^=head1 INTERFACE/;
}
print STDERR "Processing template\n";
$template->process(INPUT, $vars, $pm_file_out) || die "An error occurred: $! - " . $template->error();
my $end_found = 0;
while(my $line = <$pm_file_in>) {
$end_found = 1 if $line =~ /^=head1/;
print $pm_file_out $line if $end_found;
}
$pm_file_in->close();
$pm_file_out->close();
print STDERR "Renaming ${pm_path} to ${pm_path}.bak\n";
rename($pm_path, "${pm_path}.bak");
rename("${pm_path}.out", $pm_path);
unlink("${pm_path}.out");
}
sub findINC {
my $file = join('/',@_);
my $dir;
$file =~ s,::,/,g;
foreach $dir (@INC) {
my $path;
return $path if (-e ($path = "$dir/$file"));
}
return undef;
}
__END__
=head1 modinfo2embperl.pl
modinfo2embperl.pl: convert modinfo directives into POD and embed it in a specially
marked location in the pm file.
=head2 SYNOPSIS
perl modinfo2embperl.pl -m MyModule
or
perl modinfo2html.pl -d /home/jtillman/html-docs/ -m MyModule
=head2 EMBEDDING DIRECTIVE
See the documentation for ModInfo to learn how to document your module with ModInfo
directives. In order to tell modinfo2embperl where to embed the POD it creates,
simply put this in your POD:
=head1 INTERFACE
And then make sure that the next thing in your pod is another =head1
modinfo2embperl will insert the generated POD between these two markers in your code.
Make sure that the = sign is the first character on the line, just as in true POD.
Subsequent runs of the processor will overwrite anything inside these two markers, so
don't bother editing the POD by hand.
=head2 OPTIONS
=over 4
=item -h Display help
=item -m package Name of the Perl module package to convert
(If this is the only option provided, output will
go to STDOUT)
=item -r Recurse through the entire directory structure,
looking for .pm files, and process each one
=back
=head1 AUTHOR
jtillman@bigfoot.com
tcushard@bigfoot.com
=head1 SEE ALSO
ModInfo
Devel::ModInfo::Tutorial
pl2modinfo.pl
modinfo2xml.pl
perl(1)
!NO!SUBS!
( run in 0.799 second using v1.01-cache-2.11-cpan-71847e10f99 )