other versions
- wheezy 3.22-1
- wheezy-backports 3.26-1~bpo70+1
- jessie 3.28-1
- testing 3.35-1
- unstable 3.35-1
other sections
Pod::Simple(3pm) | User Contributed Perl Documentation | Pod::Simple(3pm) |
NAME¶
Pod::Simple - framework for parsing PodSYNOPSIS¶
TODO
DESCRIPTION¶
Pod::Simple is a Perl library for parsing text in the Pod ("plain old documentation") markup language that is typically used for writing documentation for Perl and for Perl modules. The Pod format is explained perlpod; the most common formatter is called "perldoc". Pod formatters can use Pod::Simple to parse Pod documents and render them into plain text, HTML, or any number of other formats. Typically, such formatters will be subclasses of Pod::Simple, and so they will inherit its methods, like "parse_file". If you're reading this document just because you have a Pod-processing subclass that you want to use, this document (plus the documentation for the subclass) is probably all you need to read. If you're reading this document because you want to write a formatter subclass, continue reading it and then read Pod::Simple::Subclassing, and then possibly even read perlpodspec (some of which is for parser-writers, but much of which is notes to formatter-writers).MAIN METHODS¶
- "$parser = SomeClass->new();"
- This returns a new parser object, where "SomeClass" is a subclass of Pod::Simple.
- "$parser->output_fh( *OUT );"
- This sets the filehandle that $parser's output will be
written to. You can pass *STDOUT, otherwise you should probably do
something like this:
my $outfile = "output.txt"; open TXTOUT, ">$outfile" or die "Can't write to $outfile: $!"; $parser->output_fh(*TXTOUT);
- "$parser->output_string( \$somestring );"
- This sets the string that $parser's output will be sent to, instead of any filehandle.
- "$parser->parse_file( $some_filename );"
- "$parser->parse_file( *INPUT_FH );"
- This reads the Pod content of the file (or filehandle) that you specify, and processes it with that $parser object, according to however $parser's class works, and according to whatever parser options you have set up for this $parser object.
- "$parser->parse_string_document( $all_content );"
- This works just like "parse_file" except that it reads the Pod content not from a file, but from a string that you have already in memory.
- "$parser->parse_lines( ...@lines..., undef );"
- This processes the lines in @lines (where each list item
must be a defined value, and must contain exactly one line of content --
so no items like "foo\nbar" are allowed). The final
"undef" is used to indicate the end of document being parsed.
- "$parser->content_seen"
- This returns true only if there has been any real content seen for this document. Returns false in cases where the document contains content, but does not make use of any Pod markup.
- "SomeClass->filter( $filename );"
- "SomeClass->filter( *INPUT_FH );"
- "SomeClass->filter( \$document_content );"
- This is a shortcut method for creating a new parser object,
setting the output handle to STDOUT, and then processing the specified
file (or filehandle, or in-memory document). This is handy for one-liners
like this:
perl -MPod::Simple::Text -e "Pod::Simple::Text->filter('thingy.pod')"
SECONDARY METHODS¶
Some of these methods might be of interest to general users, as well as of interest to formatter-writers. Note that the general pattern here is that the accessor-methods read the attribute's value with "$value = $parser-> attribute" and set the attribute's value with "$parser-> attribute(newvalue)". For each accessor, I typically only mention one syntax or another, based on which I think you are actually most likely to use.- "$parser->no_whining( SOMEVALUE )"
- If you set this attribute to a true value, you will
suppress the parser's complaints about irregularities in the Pod coding.
By default, this attribute's value is false, meaning that irregularities
will be reported.
- "$parser->no_errata_section( SOMEVALUE )"
- If you set this attribute to a true value, you will stop the parser from generating a "POD ERRORS" section at the end of the document. By default, this attribute's value is false, meaning that an errata section will be generated, as necessary.
- "$parser->complain_stderr( SOMEVALUE )"
- If you set this attribute to a true value, it will send
reports of parsing errors to STDERR. By default, this attribute's value is
false, meaning that no output is sent to STDERR.
- "$parser->source_filename"
- This returns the filename that this parser object was set to read from.
- "$parser->doc_has_started"
- This returns true if $parser has read from a source, and has seen Pod content in it.
- "$parser->source_dead"
- This returns true if $parser has read from a source, and come to the end of that source.
- "$parser->strip_verbatim_indent( SOMEVALUE )"
- The perlpod spec for a Verbatim paragraph is "It
should be reproduced exactly...", which means that the whitespace
you've used to indent your verbatim blocks will be preserved in the
output. This can be annoying for outputs such as HTML, where that
whitespace will remain in front of every line. It's an unfortunate case
where syntax is turned into semantics.
$parser->strip_verbatim_indent(' ');
$parser->strip_verbatim_indent("\t");
$new->strip_verbatim_indent(sub { my $lines = shift; (my $indent = $lines->[0]) =~ s/\S.*//; return $indent; });
$new->strip_verbatim_indent(sub { my $lines = shift; sub { s/^\s+// for @{ $lines }, return undef; });
TERTIARY METHODS¶
- "$parser->abandon_output_fh()"
- Cancel output to the file handle. Any POD read by the $parser is not effected.
- "$parser->abandon_output_string()"
- Cancel output to the output string. Any POD read by the $parser is not effected.
- "$parser->accept_code( @codes )"
- Alias for accept_codes.
- "$parser->accept_codes( @codes )"
- Allows $parser to accept a list of "Formatting Codes" in perlpod. This can be used to implement user-defined codes.
- "$parser->accept_directive_as_data( @directives )"
- Allows $parser to accept a list of directives for data paragraphs. A directive is the label of a "Command Paragraph" in perlpod. A data paragraph is one delimited by "=begin/=for/=end" directives. This can be used to implement user-defined directives.
- "$parser->accept_directive_as_processed( @directives )"
- Allows $parser to accept a list of directives for processed paragraphs. A directive is the label of a "Command Paragraph" in perlpod. A processed paragraph is also known as "Ordinary Paragraph" in perlpod. This can be used to implement user-defined directives.
- "$parser->accept_directive_as_verbatim( @directives )"
- Allows $parser to accept a list of directives for "Verbatim Paragraph" in perlpod. A directive is the label of a "Command Paragraph" in perlpod. This can be used to implement user-defined directives.
- "$parser->accept_target( @targets )"
- Alias for accept_targets.
- "$parser->accept_target_as_text( @targets )"
- Alias for accept_targets_as_text.
- "$parser->accept_targets( @targets )"
- Accepts targets for "=begin/=for/=end" sections of the POD.
- "$parser->accept_targets_as_text( @targets )"
- Accepts targets for "=begin/=for/=end" sections that should be parsed as POD. For details, see "About Data Paragraphs" in perlpodspec.
- "$parser->any_errata_seen()"
- Used to check if any errata was seen.
die "too many errors\n" if $parser->any_errata_seen();
- "$parser->parse_from_file( $source, $to )"
- Parses from $source file to $to file. Similar to "parse_from_file" in Pod::Parser.
- "$parser->scream( @error_messages )"
- Log an error that can't be ignored.
- "$parser->unaccept_code( @codes )"
- Alias for unaccept_codes.
- "$parser->unaccept_codes( @codes )"
- Removes @codes as valid codes for the parse.
- "$parser->unaccept_directive( @directives )"
- Alias for unaccept_directives.
- "$parser->unaccept_directives( @directives )"
- Removes @directives as valid directives for the parse.
- "$parser->unaccept_target( @targets )"
- Alias for unaccept_targets.
- "$parser->unaccept_targets( @targets )"
- Removes @targets as valid targets for the parse.
- "$parser->version_report()"
- Returns a string describing the version.
- "$parser->whine( @error_messages )"
- Log an error unless "$parser->no_whining( TRUE );".
CAVEATS¶
This is just a beta release -- there are a good number of things still left to do. Notably, support for EBCDIC platforms is still half-done, an untested.SEE ALSO¶
Pod::Simple::Subclassing perlpod perlpodspec Pod::Escapes perldocSUPPORT¶
Questions or discussion about POD and Pod::Simple should be sent to the pod-people@perl.org mail list. Send an empty email to pod-people-subscribe@perl.org to subscribe. This module is managed in an open GitHub repository, http://github.com/theory/pod-simple/ <http://github.com/theory/pod-simple/>. Feel free to fork and contribute, or to clone git://github.com/theory/pod-simple.git <git://github.com/theory/pod-simple.git> and send patches! Patches against Pod::Simple are welcome. Please send bug reports to <bug-pod-simple@rt.cpan.org>.COPYRIGHT AND DISCLAIMERS¶
Copyright (c) 2002 Sean M. Burke. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.AUTHOR¶
Pod::Simple was created by Sean M. Burke <sburke@cpan.org>. But don't bother him, he's retired. Pod::Simple is maintained by:- •
- Allison Randal "allison@perl.org"
- •
- Hans Dieter Pearcey "hdp@cpan.org"
- •
- David E. Wheeler "dwheeler@cpan.org"
- •
- Gabor Szabo "szabgab@gmail.com"
- •
- Shawn H Corey "SHCOREY at cpan.org"
2012-01-03 | perl v5.14.2 |