NAME

Pod::Loom::Parser - Subclass Pod::Eventual for Pod::Loom

VERSION

This document describes version 0.05 of Pod::Loom::Parser, released March 23, 2014 as part of Pod-Loom version 0.08.

SYNOPSIS

use Pod::Loom::Parser;

my $parser = Pod::Loom::Parser->new( ['head1'] );
$parser->read_file('lib/Foo/Bar.pm');
my $collectedHash = $parser->collected;

foreach my $block (@{ $collectedHash->{head1} }) {
  printf "---\n%s\n", $block;
}

DESCRIPTION

Pod::Loom::Parser is a subclass of Pod::Eventual intended for use by Pod::Loom::Template. It breaks the POD into chunks based on a list of POD commands. Each chunk begins with one of the commands, and contains all the POD up until the next selected command.

The commands do not need to be valid POD commands. You can invent commands like =attr or =method.

METHODS

See Pod::Eventual for the read_handle, read_file, and read_string methods, which you use to feed POD into the parser.

new

$parser = Pod::Loom::Parser->new(\@collect_commands);

Constructs a new Pod::Loom::Parser. You pass it an arrayref of the POD commands at which the POD should be chopped.

collected

$hashRef = $parser->collected;

This returns the POD chunks that the document was chopped into. There is one entry for each of the @collect_commands that were passed to the constructor. The value is an arrayref of strings, one for each time that command appeared in the document. Each chunk contains all the text from the command up to (but not including) the command that started the next chunk. Chunks appear in document order.

If one of the commands did not appear in the document, its value will be an empty arrayref.

In addition, any POD targeted to a format matching /^Pod::Loom\b/ will be collected under the format name.

encoding

$encoding = $parser->encoding;

This returns the encoding that was used for the document as an Encode object. If no encoding was explicitly defined, then the default Latin-1 encoding is returned.

groups

$hashRef = $parser->groups;

This returns a hashref with one entry for each of the @collect_commands. Each value is a hashref whose keys are the categories used with that command. For example, if attr was a collected command, and the document contained these entries:

=attr-foo attr1
=attr-bar attr2
=attr-foo attr3
=attr attr4

then keys %{ $parser->groups->{attr} } would return bar and foo. (The =attr without a category does not get an entry in this hash.)

CONFIGURATION AND ENVIRONMENT

Pod::Loom::Parser requires no configuration files or environment variables.

DEPENDENCIES

Pod::Loom::Parser requires Pod::Eventual, which can be found on CPAN.

INCOMPATIBILITIES

None reported.

BUGS AND LIMITATIONS

No bugs have been reported.

AUTHOR

Christopher J. Madsen <perl AT cjmweb.net>

Please report any bugs or feature requests to <bug-Pod-Loom AT rt.cpan.org> or through the web interface at http://rt.cpan.org/Public/Bug/Report.html?Queue=Pod-Loom.

You can follow or contribute to Pod-Loom's development at https://github.com/madsen/pod-loom.

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Christopher J. Madsen.

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

DISCLAIMER OF WARRANTY

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENSE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.