Plain Old Documentation
This article may require cleanup to meet Wikipedia's quality standards. Please improve this article if you can. (October 2009) |
Plain Old Documentation, abbreviated pod, is a simple markup language used to document the Perl programming language.
Design
pod is designed to be a simple, clean language with just enough syntax to be useful. It purposefully does not include mechanisms for fonts, images, colors or tables. Some of its goals are:
- Easy to parse
- Easy to convert to other languages, such as HTML or TeX
- Easy to incorporate sample code
- Easy to read without a pod formatter (i.e. in its source-code form)
- Easy to write in—otherwise programmers won't write the documentation!
Although the author of perlpod notes that "The Pod format is not necessarily sufficient for writing a book", books have in fact been written in an extended version of pod; this special version included formatting codes for tables and footnotes, and is used by O'Reilly & Associates to produce several Perl books, most notably Programming Perl by Larry Wall, Tom Christiansen, and Jon Orwant. A slightly extended, modified version of pod, called mod, was used to write Higher-Order Perl, by Mark Jason Dominus.
Use
pod is the language used for most documentation in the Perl world. This includes Perl itself, nearly all publicly-released modules, many scripts, most design documents, many articles on Perl.com and other Perl-related web sites, and the Parrot virtual machine.
pod is rarely read in the raw, although it is designed to be readable without the assistance of a formatting tool. Instead, it is read with the perldoc tool, or converted into Unix man pages or Web-standard HTML pages.
Pure pod files usually have the extension .pod
, but pod is mostly used directly in Perl
code, which typically uses the .pl
and .pm
extensions. (The Perl
interpreter's parser is designed to ignore pod in Perl code.) In source code files, the documentation is generally placed after the __END__
marker (which also helps syntax highlighting in some editors to display it as comments).
Sample pod document
This document is syntactically correct pod, which attempts to follow the major conventions on section naming as well.
Source | HTML result |
---|---|
=head1 NAME podsample - A sample pod document =head1 SYNOPSIS $here->isa(Piece::Of::Code); print <<"END"; This indented block will not be scanned for formatting codes or directives, and spacing will be preserved. END =head1 DESCRIPTION Here's some normal text. It includes text that is B<bolded>, I<italicized>, U<underlined>, and C<$code>-formatted. =head2 An Example List =over 4 =item * This is a bulleted list. =item * Here's another item. =back =begin html <img src="Example.png" align="right" alt="Figure 1." /> <p> Here's some embedded HTML. In this block I can include images, apply <span style="color: green"> styles</span>, or do anything else I can do with HTML. pod parsers that aren't outputting HTML will completely ignore it. </p> =end html =head1 SEE ALSO L<perlpod>, L<perldoc>, L<Pod::Parser>. =head1 COPYRIGHT Copyright 2005 J. Random Hacker <jrh@cpan.org>. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. =cut |
NAMEpodsample - A sample pod document SYNOPSIS$here->isa(Piece::Of::Code); print <<"END"; This indented block will not be scanned for formatting codes or directives, and spacing will be preserved. END DESCRIPTIONHere's some normal text. It includes text that is
bolded, italicized, underlined, and
An Example List
Here's some embedded HTML. In this block I can include images, apply styles, or do anything else I can do with HTML. pod parsers that aren't outputting HTML will completely ignore it. SEE ALSOperlpod, perldoc, the Pod::Parser manpage. COPYRIGHTCopyright 2005 J. Random Hacker <jrh@cpan.org>. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. |
pod formatting details
pod files are written in an ASCII-compatible encoding, such as Latin-1 or Unicode. A pod parser always assumes that the file it is parsing doesn't start with pod; it ignores all lines until it sees a pod directive. pod directives must come at the beginning of a line, and all begin with an equal sign. The pod parser will then assume that all following lines are pod, until it encounters a line consisting of the "=cut" directive. Any content following that is ignored until the parser encounters another pod directive. Thus, pod can be intermixed with executable source code if the language's parser knows how to recognize and ignore pod.
pod content is divided into paragraphs by empty lines. Paragraphs that begin with whitespace characters—tabs or spaces—are considered to be "verbatim paragraphs", and are left completely unformatted; these are used for sample code, ASCII art, etc. Paragraphs that begin with an equal sign are "command paragraphs"; the sequence of alphanumeric characters immediately following the equal sign is treated as a pod directive, and the rest of the paragraph is formatted according to that directive. Some directives also affect the following paragraphs. If a paragraph starts with something besides an equal sign or whitespace, it's considered an "ordinary paragraph".
Both ordinary paragraphs and the contents of command paragraphs are parsed for formatting codes. Formatting in pod is very plain; it's mainly limited to bold, italic, underlined, monospaced, and a few other formats. There is also a code for linking between pod documents or to another section within the same document. Formatting codes consist of either:
- A single uppercase letter, followed by a less-than sign (<), the content to be formatted, and a greater-than sign (>), e.g.
B<bolded text>
, or - A single uppercase letter, two or more less-than signs (<<), a space, the content to be formatted, another space, and the same number of greater-than signs as were used before, e.g.
B<< bolded text >>
. This form is often used for code snippets containing a greater-than sign, which would otherwise end the formatting code.
Commands in pod include four levels of headings, bulleted and numbered lists, and commands to mark sections as being in another language. The latter feature allows for special formatting to be given to parsers that support it.
See also
References
- Wall, Larry; Christiansen, Tom; & Orwant, Jon (2000). Programming Perl (3rd ed.). Sebastopol: O'Reilly & Associates. ISBN 0-596-00027-8.
External links
- perlpod (documentation on pod for people writing documents in it)
- perlpodspec (documentation on pod for people writing parsers for it)
- The Perl manpages in raw pod format can be viewed at [1].
- The directory [2] contains many modules with embedded pod formatting.
- The Getopt::Euclid module parses input to a Perl script automatically based on pod tags
de:Plain Old Documentation fr:Plain Old Documentation nl:Plain Old Documentation ja:Plain Old Documentation ru:Простая старая документация fi:Plain Old Documentation
If you like SEOmastering Site, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...