Add missing syms to global.sym; update magic doc
[p5sagit/p5-mst-13.2.git] / pod / perlpod.pod
CommitLineData
a0d0e21e 1=head1 NAME
2
cb1a09d0 3perlpod - plain old documentation
a0d0e21e 4
5=head1 DESCRIPTION
6
7A pod-to-whatever translator reads a pod file paragraph by paragraph,
8and translates it to the appropriate output format. There are
9three kinds of paragraphs:
10
11=over 4
12
13=item *
14
15A verbatim paragraph, distinguished by being indented (that is,
16it starts with space or tab). It should be reproduced exactly,
17with tabs assumed to be on 8-column boundaries. There are no
18special formatting escapes, so you can't italicize or anything
19like that. A \ means \, and nothing else.
20
21=item *
22
23A command. All command paragraphs start with "=", followed by an
24identifier, followed by arbitrary text that the command can
25use however it pleases. Currently recognized commands are
26
27 =head1 heading
28 =head2 heading
29 =item text
30 =over N
31 =back
4633a7c4 32 =cut
cb1a09d0 33 =pod
c7c9f956 34 =for X
35 =begin X
36 =end X
cb1a09d0 37
38The "=pod" directive does nothing beyond telling the compiler to lay
39off of through the next "=cut". It's useful for adding another
40paragraph to the doc if you're mixing up code and pod a lot.
41
42Head1 and head2 produce first and second level headings, with the text on
43the same paragraph as "=headn" forming the heading description.
44
45Item, over, and back require a little more explanation: Over starts a
46section specifically for the generation of a list using =item commands. At
47the end of your list, use =back to end it. You will probably want to give
184e9718 48"4" as the number to =over, as some formatters will use this for indentation.
cb1a09d0 49This should probably be a default. Note also that there are some basic rules
50to using =item: don't use them outside of an =over/=back block, use at least
51one inside an =over/=back block, you don't _have_ to include the =back if
52the list just runs off the document, and perhaps most importantly, keep the
53items consistent: either use "=item *" for all of them, to produce bullets,
54or use "=item 1.", "=item 2.", etc., to produce numbered lists, or use
55"=item foo", "=item bar", etc., i.e., things that looks nothing like bullets
56or numbers. If you start with bullets or numbers, stick with them, as many
184e9718 57formatters use the first =item type to decide how to format the list.
cb1a09d0 58
c7c9f956 59For and begin/end let you include sections that are not interpreted as pod
60text, but in a format that a particular formatter is looking for. A
61formatter that can utilize that format will use the section, otherwise it
62will be completely ignored. "=for" specifies that the entire paragraph
63should is in the format indicated by the first word after "=for", like this:
64
65 =for html <br>
66 <p> This is a raw HTML paragraph </p>
67
68The paired commands "=begin" and "=end" work very similarly to =for, but
69instead of only accepting a single paragraph, all text from =begin to a
70paragraph with a matching =end are treated as a particular format.
71
72Here are some examples of how to use these:
73
74 =begin html
75
76 <br>Figure 1.<IMG SRC="figure1.png"><br>
77
78 =end html
79
80 =begin text
81
82 ---------------
83 | foo |
84 | bar |
85 ---------------
86
87 ^^^^ Figure 1. ^^^^
88
89 =end text
90
91Some format names that formatters currently are known to accept include
92"roff", "man", "latex", "tex", "text", and "html". (Some formatters will
93treat some of these as synonyms.)
94
cb1a09d0 95And don't forget, when using any command, that that command lasts up until
96the end of the B<paragraph>, not the line. Hence in the examples below, you
184e9718 97can see the blank lines after each command to end its paragraph.
cb1a09d0 98
99Some examples of lists include:
100
101 =over 4
102
103 =item *
104
105 First item
106
107 =item *
108
109 Second item
110
111 =back
112
113 =over 4
114
115 =item Foo()
116
117 Description of Foo function
118
119 =item Bar()
120
121 Description of Bar function
122
123 =back
a0d0e21e 124
125=item *
126
127An ordinary block of text. It will be filled, and maybe even
128justified. Certain interior sequences are recognized both
129here and in commands:
130
131 I<text> italicize text, used for emphasis or variables
132 B<text> embolden text, used for switches and programs
133 S<text> text contains non-breaking spaces
134 C<code> literal code
135 L<name> A link (cross reference) to name
5f05dabc 136 L<name> manual page
137 L<name/ident> item in manual page
138 L<name/"sec"> section in other manual page
139 L<"sec"> section in this manual page
a0d0e21e 140 (the quotes are optional)
cb1a09d0 141 L</"sec"> ditto
a0d0e21e 142 F<file> Used for filenames
cb1a09d0 143 X<index> An index entry
a0d0e21e 144 Z<> A zero-width character
c7c9f956 145 E<escape> A named character (very similar to HTML escapes)
1294c5d8 146 E<lt> A literal <
147 E<gt> A literal >
148 (these are optional except in other interior
149 sequences and when preceded by a capital letter)
c7c9f956 150 E<n> Character number n (probably in ASCII)
7f3dfc00 151 E<html> Some non-numeric HTML entity, such
152 as E<Agrave>
a0d0e21e 153
3141265f 154=back
155
a0d0e21e 156That's it. The intent is simplicity, not power. I wanted paragraphs
157to look like paragraphs (block format), so that they stand out
158visually, and so that I could run them through fmt easily to reformat
159them (that's F7 in my version of B<vi>). I wanted the translator (and not
160me) to worry about whether " or ' is a left quote or a right quote
5f05dabc 161within filled text, and I wanted it to leave the quotes alone, dammit, in
a0d0e21e 162verbatim mode, so I could slurp in a working program, shift it over 4
163spaces, and have it print out, er, verbatim. And presumably in a
164constant width font.
165
166In particular, you can leave things like this verbatim in your text:
167
168 Perl
169 FILEHANDLE
170 $variable
171 function()
172 manpage(3r)
173
174Doubtless a few other commands or sequences will need to be added along
175the way, but I've gotten along surprisingly well with just these.
176
177Note that I'm not at all claiming this to be sufficient for producing a
178book. I'm just trying to make an idiot-proof common source for nroff,
179TeX, and other markup languages, as used for online documentation.
cb1a09d0 180Translators exist for B<pod2man> (that's for nroff(1) and troff(1)),
181B<pod2html>, B<pod2latex>, and B<pod2fm>.
a0d0e21e 182
4633a7c4 183=head1 Embedding Pods in Perl Modules
184
185You can embed pod documentation in your Perl scripts. Start your
186documentation with a =head1 command at the beg, and end it with
187an =cut command. Perl will ignore the pod text. See any of the
cb1a09d0 188supplied library modules for examples. If you're going to put
189your pods at the end of the file, and you're using an __END__
190or __DATA__ cut mark, make sure to put a blank line there before
191the first pod directive.
192
193 __END__
194
195 =head1 NAME
196
197 modern - I am a modern module
198
199If you had not had that blank line there, then the translators wouldn't
200have seen it.
201
1294c5d8 202=head1 Common Pod Pitfalls
203
204=over 4
205
206=item *
207
208Pod translators usually will require paragraphs to be separated by
209completely empty lines. If you have an apparently blank line with
210some spaces on it, this can cause odd formatting.
211
212=item *
213
214Translators will mostly add wording around a LE<lt>E<gt> link, so that
215C<LE<lt>foo(1)E<gt>> becomes "the I<foo>(1) manpage", for example (see
216B<pod2man> for details). Thus, you shouldn't write things like C<the
217LE<lt>fooE<gt> manpage>, if you want the translated document to read
218sensibly.
219
220=item *
221
222The script F<pod/checkpods.PL> in the Perl source distribution
223provides skeletal checking for lines that look blank but aren't
224B<only>, but is there as a placeholder until someone writes
225Pod::Checker. The best way to check your pod is to pass it through
226one or more translators and proofread the result, or print out the
227result and proofread that. Some of the problems found may be bugs in
228the translators, which you may or may not wish to work around.
229
230=back
231
cb1a09d0 232=head1 SEE ALSO
233
234L<pod2man> and L<perlsyn/"PODs: Embedded Documentation">
4633a7c4 235
cb1a09d0 236=head1 AUTHOR
a0d0e21e 237
238Larry Wall
239