Pod::Loom::Parser - Subclass Pod::Eventual for Pod::Loom
This document describes version 0.05 of Pod::Loom::Parser, released March 23, 2014 as part of Pod-Loom version 0.08.
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; }
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.
=attr
=method
See Pod::Eventual for the read_handle, read_file, and read_string methods, which you use to feed POD into the parser.
read_handle
read_file
read_string
$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.
$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.
@collect_commands
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.
/^Pod::Loom\b/
$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.
$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
=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.)
keys %{ $parser->groups->{attr} }
bar
foo
Pod::Loom::Parser requires no configuration files or environment variables.
Pod::Loom::Parser requires Pod::Eventual, which can be found on CPAN.
None reported.
No bugs have been reported.
Christopher J. Madsen <perl AT cjmweb.net>
<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.
<bug-Pod-Loom AT rt.cpan.org>
You can follow or contribute to Pod-Loom's development at https://github.com/madsen/pod-loom.
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.
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.
To install Pod::Loom, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Pod::Loom
CPAN shell
perl -MCPAN -e shell install Pod::Loom
For more information on module installation, please visit the detailed CPAN module installation guide.