Extract and reformat snippets of POD so as to use them in a unit test (or other Perl code)
Version: 0.14Pod::Snippets is a Perl module that extract and reformat snippets of POD so as to use them in a unit test (or other Perl code).
License: Perl Artistic License
Operating System: Linux
my $snips = load Pod::Snippets($file_or_handle,
-markup => "test");
my $code_snippet = $snips->named("synopsis")->as_code;
# ... Maybe borg $code_snippet with regexes or something...
my $result = eval $code_snippet; die $@ if $@;
The Perl code that we want to extract snippets from might look like this:
Zero::Wing - For great justice!
=for test "synopsis" begin
my $capitain = Zero::Wing->capitain;
=for test "synopsis" end
This class is a very simple extension of Pod::Parser that extracts POD snippets from Perl code, and pretty-prints it so as to make it useable from other Perl code. As demonstrated above, Pod::Snipets is immediately useful to test-driven-development nutcases who want to put every single line of Perl code under test, including code that is in the POD (typically a SYNOPSIS section). There are other uses, such as storing a piece of information that is both human- and machine-readable (eg an XML schema) simultaneously as documentation and code.