What is Pod? Using Pod Caveats Examples See Also To Pod or Not to Pod
Pod documentation can be ``sprinkled'' throughout a program file. Any of several pod translators can be used to extract the pod. Perl considers pod to be commentary; the pod translators consider code to be extraneous.
The Perl lexer skips over pod directives when parsing a program for execution, just as pod translators skip over Perl code when parsing pod. With several caveats (below), pod is fairly simple to use.
How pod is extracted and presented depends on the translator you use. Available translators bundled with Perl include
=head1 =item =over =for =cut
Several of the directives take argument text, usually (although not necessarily) placed on the same line as the directive. The argument text may be processed differently, depending on the directive and the translators.
=head1 Heading Text =item tag =over 4 =for html =cut
If you like using indentation as a way to organize your text, you will be very disappointed (and ofttimes frustrated) with pod.
If your results do not match your expectations, the most likely cause is whitespace out of place.
Verbatim text must be indented by at least one space. Pod will set the text as typed without wrapping.
^$
Lines containing spaces or tabs are not ``blank'' to pod.
The pod2man script specifically requires that your first pod directive be
=head1 NAME
(not ``NAME:'', not ``NAME -'').
pod2man also insists on a - in the NAME paragraph text line.
On the other hand, pod is a bit more powerful and expressive than plain text comments (and, given the various translators, it's a lot more flexible).
=back =cut
will not act as expected (=cut is considered part of the data, the text. It is not recognized as a pod directive in this position.) Add a blank line:
=back
=cut
This is two directives.
If your pod is
=item ConvertFromExternalAssetIDs Description: Convert a hash or array keyed on some external id Inputs: $equity - Date on which IDs are valid Returns: $rOut - Reference to converted hash or array
and you see
ConvertFromExternalAssetIDs Description: Convert a hash or array keyed on
some external id Inputs: $equity - Date on which IDs are valid
Returns: $rOut - Reference to converted hash or array
when you expected to see
ConvertFromExternalAssetIDs
Description: Convert a hash or array keyed on some external id
Inputs:
$equity - Date on which IDs are valid
Returns:
$rOut - Reference to converted hash or array
check for the blank line after
=item
You can use either
=head1 Heading 1
paragraph text
which produces
Heading 1
paragraph text
or
=head1 Heading 2
paragraph text
which produces
Heading 2
paragraph text
but not
=head1
Heading 3
paragraph text
which produces two indented paragraphs and no heading:
Heading 3
paragraph text
There are several possible directives. They include:
=head1
=item
=over
=for
=cut
This would be formatted as:
There are several possible directives. They include: =head1 =item =over =for =cut
=for comment this text will not be extracted or translated
this text will be translated
=begin comment this line will be skipped
as will this one
and this one
=end comment
but this line will be translated and printed.
Remember to precede the =end directive with a blank line!
Note that the argument to the =for, =begin, and =end directives is a translator type; the ``comment'' translator does not exist. Actually, any nonexistent translator type could be used (although clarity should be preferred over cuteness).
=for later we'll uncomment this part when it works
=begin unfinished documentation don't include this
=end unfinished documentation
=head1 DESCRIPTION
POD Overview for Global Platform
will be formatted by pod2text as
DESCRIPTION
POD Overview for Global Platform
/usr/local/bin/pod2man: bad option in paragraph 6 of gp-prog.pl: ``-d'' should be [CB]<-d>
you should ignore the [ ] in the error message.
The perlpod man page is a good place to start, as is chapter 26, ``Plain Old Documentation'' of the 3rd addition of ``Programming Perl'' by Wall et. al. (``The Camel'').
Most Perl modules are documented in pod. You can also look at the pod subdirectory of the installed Perl distribution (try /usr/local/lib/perl5/pod/).
Several of the pod2* translators are written in Perl with embedded pod documentation. Look in /usr/local/bin.
The script newasgp.pl generates a ``code template'' for GP Perl scripts. Note that newasgp.pl is a ``work in progress''; more functionality may be added to the template
in the future. See gp-prog.pl for an example of the output from newasgp.pl.
If you're not sure, think ``man page''. That is, what would you put into a man page for this program? Use pod for documentation a user of your program would care about (said user could be another developer). use comments for documentation a programmer / maintainer would care about.
Use pod for information that can stand alone, separate from the code. Use comments for information that requires the code (comments for contextual documentation).
Recommended guidelines: