NAME

Getopt::Euclid::PodExtract - Perl::Tidy formatter to extract POD from source code

SYNOPSIS

use Perl::Tidy;
my $source = 'somefile.pl';
my $pod    = '';
Perl::Tidy::perltidy(
      argv      => [],
      source    => $source,
      formatter => Getopt::Euclid::PodExtract->new(\$pod),
);
print $pod;

DESCRIPTION

This is a formatter to plug into Perl::Tidy. This formatter simply takes source code and deletes everything except for POD, which it returns in its raw form in the specified variable. Do not use the destination option of perltidy as it is ignored when using a formatter.

Perl::Tidy seems to have a more robust POD parsing mechanisms than Pod::Parser or Pod::Simple, which makes it useful to correctly parse POD code, even when rogue POD hides inside Perl variables, as in this example:

use strict;
use warnings;

=head1 NAME

Tricky

=cut

print "Starting...\n--------\n";
my $var =<<EOS;

=head1 FAKE_POD_ENTRY_HERE

This should not be extracted as POD since it is the content of a variable

=cut

EOS

print $var;
print "--------\nDone!\n";
exit;

__END__

=head1 SYNOPSIS

Tricky file to test proper POD parsing

AUTHOR

Florent Angly <florent.angly@gmail.com>

LICENCE AND COPYRIGHT

Copyright (c) 2011, Florent Angly <florent.angly@gmail.com>

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.