source: trunk/essentials/dev-lang/perl/pod/perlpod.pod@ 3439

Last change on this file since 3439 was 3181, checked in by bird, 19 years ago

perl 5.8.8

File size: 21.1 KB
Line 
1
2=for comment
3This document is in Pod format. To read this, use a Pod formatter,
4like "perldoc perlpod".
5
6=head1 NAME
7X<POD> X<plain old documentation>
8
9perlpod - the Plain Old Documentation format
10
11=head1 DESCRIPTION
12
13Pod is a simple-to-use markup language used for writing documentation
14for Perl, Perl programs, and Perl modules.
15
16Translators are available for converting Pod to various formats
17like plain text, HTML, man pages, and more.
18
19Pod markup consists of three basic kinds of paragraphs:
20L<ordinary|/"Ordinary Paragraph">,
21L<verbatim|/"Verbatim Paragraph">, and
22L<command|/"Command Paragraph">.
23
24
25=head2 Ordinary Paragraph
26X<POD, ordinary paragraph>
27
28Most paragraphs in your documentation will be ordinary blocks
29of text, like this one. You can simply type in your text without
30any markup whatsoever, and with just a blank line before and
31after. When it gets formatted, it will undergo minimal formatting,
32like being rewrapped, probably put into a proportionally spaced
33font, and maybe even justified.
34
35You can use formatting codes in ordinary paragraphs, for B<bold>,
36I<italic>, C<code-style>, L<hyperlinks|perlfaq>, and more. Such
37codes are explained in the "L<Formatting Codes|/"Formatting Codes">"
38section, below.
39
40
41=head2 Verbatim Paragraph
42X<POD, verbatim paragraph> X<verbatim>
43
44Verbatim paragraphs are usually used for presenting a codeblock or
45other text which does not require any special parsing or formatting,
46and which shouldn't be wrapped.
47
48A verbatim paragraph is distinguished by having its first character
49be a space or a tab. (And commonly, all its lines begin with spaces
50and/or tabs.) It should be reproduced exactly, with tabs assumed to
51be on 8-column boundaries. There are no special formatting codes,
52so you can't italicize or anything like that. A \ means \, and
53nothing else.
54
55
56=head2 Command Paragraph
57X<POD, command>
58
59A command paragraph is used for special treatment of whole chunks
60of text, usually as headings or parts of lists.
61
62All command paragraphs (which are typically only one line long) start
63with "=", followed by an identifier, followed by arbitrary text that
64the command can use however it pleases. Currently recognized commands
65are
66
67 =pod
68 =head1 Heading Text
69 =head2 Heading Text
70 =head3 Heading Text
71 =head4 Heading Text
72 =over indentlevel
73 =item stuff
74 =back
75 =begin format
76 =end format
77 =for format text...
78 =encoding type
79 =cut
80
81To explain them each in detail:
82
83=over
84
85=item C<=head1 I<Heading Text>>
86X<=head1> X<=head2> X<=head3> X<=head4>
87X<head1> X<head2> X<head3> X<head4>
88
89=item C<=head2 I<Heading Text>>
90
91=item C<=head3 I<Heading Text>>
92
93=item C<=head4 I<Heading Text>>
94
95Head1 through head4 produce headings, head1 being the highest
96level. The text in the rest of this paragraph is the content of the
97heading. For example:
98
99 =head2 Object Attributes
100
101The text "Object Attributes" comprises the heading there. (Note that
102head3 and head4 are recent additions, not supported in older Pod
103translators.) The text in these heading commands can use
104formatting codes, as seen here:
105
106 =head2 Possible Values for C<$/>
107
108Such commands are explained in the
109"L<Formatting Codes|/"Formatting Codes">" section, below.
110
111=item C<=over I<indentlevel>>
112X<=over> X<=item> X<=back> X<over> X<item> X<back>
113
114=item C<=item I<stuff...>>
115
116=item C<=back>
117
118Item, over, and back require a little more explanation: "=over" starts
119a region specifically for the generation of a list using "=item"
120commands, or for indenting (groups of) normal paragraphs. At the end
121of your list, use "=back" to end it. The I<indentlevel> option to
122"=over" indicates how far over to indent, generally in ems (where
123one em is the width of an "M" in the document's base font) or roughly
124comparable units; if there is no I<indentlevel> option, it defaults
125to four. (And some formatters may just ignore whatever I<indentlevel>
126you provide.) In the I<stuff> in C<=item I<stuff...>>, you may
127use formatting codes, as seen here:
128
129 =item Using C<$|> to Control Buffering
130
131Such commands are explained in the
132"L<Formatting Codes|/"Formatting Codes">" section, below.
133
134Note also that there are some basic rules to using "=over" ...
135"=back" regions:
136
137=over
138
139=item *
140
141Don't use "=item"s outside of an "=over" ... "=back" region.
142
143=item *
144
145The first thing after the "=over" command should be an "=item", unless
146there aren't going to be any items at all in this "=over" ... "=back"
147region.
148
149=item *
150
151Don't put "=headI<n>" commands inside an "=over" ... "=back" region.
152
153=item *
154
155And perhaps most importantly, keep the items consistent: either use
156"=item *" for all of them, to produce bullets; or use "=item 1.",
157"=item 2.", etc., to produce numbered lists; or use "=item foo",
158"=item bar", etc. -- namely, things that look nothing like bullets or
159numbers.
160
161If you start with bullets or numbers, stick with them, as
162formatters use the first "=item" type to decide how to format the
163list.
164
165=back
166
167=item C<=cut>
168X<=cut> X<cut>
169
170To end a Pod block, use a blank line,
171then a line beginning with "=cut", and a blank
172line after it. This lets Perl (and the Pod formatter) know that
173this is where Perl code is resuming. (The blank line before the "=cut"
174is not technically necessary, but many older Pod processors require it.)
175
176=item C<=pod>
177X<=pod> X<pod>
178
179The "=pod" command by itself doesn't do much of anything, but it
180signals to Perl (and Pod formatters) that a Pod block starts here. A
181Pod block starts with I<any> command paragraph, so a "=pod" command is
182usually used just when you want to start a Pod block with an ordinary
183paragraph or a verbatim paragraph. For example:
184
185 =item stuff()
186
187 This function does stuff.
188
189 =cut
190
191 sub stuff {
192 ...
193 }
194
195 =pod
196
197 Remember to check its return value, as in:
198
199 stuff() || die "Couldn't do stuff!";
200
201 =cut
202
203=item C<=begin I<formatname>>
204X<=begin> X<=end> X<=for> X<begin> X<end> X<for>
205
206=item C<=end I<formatname>>
207
208=item C<=for I<formatname> I<text...>>
209
210For, begin, and end will let you have regions of text/code/data that
211are not generally interpreted as normal Pod text, but are passed
212directly to particular formatters, or are otherwise special. A
213formatter that can use that format will use the region, otherwise it
214will be completely ignored.
215
216A command "=begin I<formatname>", some paragraphs, and a
217command "=end I<formatname>", mean that the text/data inbetween
218is meant for formatters that understand the special format
219called I<formatname>. For example,
220
221 =begin html
222
223 <hr> <img src="thang.png">
224 <p> This is a raw HTML paragraph </p>
225
226 =end html
227
228The command "=for I<formatname> I<text...>"