This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl 5.003_06: pod/perlguts.pod
[perl5.git] / pod / perlpod.pod
CommitLineData
a0d0e21e
LW
1=head1 NAME
2
cb1a09d0 3perlpod - plain old documentation
a0d0e21e
LW
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
AD
33 =pod
34
35The "=pod" directive does nothing beyond telling the compiler to lay
36off of through the next "=cut". It's useful for adding another
37paragraph to the doc if you're mixing up code and pod a lot.
38
39Head1 and head2 produce first and second level headings, with the text on
40the same paragraph as "=headn" forming the heading description.
41
42Item, over, and back require a little more explanation: Over starts a
43section specifically for the generation of a list using =item commands. At
44the end of your list, use =back to end it. You will probably want to give
184e9718 45"4" as the number to =over, as some formatters will use this for indentation.
cb1a09d0
AD
46This should probably be a default. Note also that there are some basic rules
47to using =item: don't use them outside of an =over/=back block, use at least
48one inside an =over/=back block, you don't _have_ to include the =back if
49the list just runs off the document, and perhaps most importantly, keep the
50items consistent: either use "=item *" for all of them, to produce bullets,
51or use "=item 1.", "=item 2.", etc., to produce numbered lists, or use
52"=item foo", "=item bar", etc., i.e., things that looks nothing like bullets
53or numbers. If you start with bullets or numbers, stick with them, as many
184e9718 54formatters use the first =item type to decide how to format the list.
cb1a09d0
AD
55
56And don't forget, when using any command, that that command lasts up until
57the end of the B<paragraph>, not the line. Hence in the examples below, you
184e9718 58can see the blank lines after each command to end its paragraph.
cb1a09d0
AD
59
60Some examples of lists include:
61
62 =over 4
63
64 =item *
65
66 First item
67
68 =item *
69
70 Second item
71
72 =back
73
74 =over 4
75
76 =item Foo()
77
78 Description of Foo function
79
80 =item Bar()
81
82 Description of Bar function
83
84 =back
a0d0e21e
LW
85
86=item *
87
88An ordinary block of text. It will be filled, and maybe even
89justified. Certain interior sequences are recognized both
90here and in commands:
91
92 I<text> italicize text, used for emphasis or variables
93 B<text> embolden text, used for switches and programs
94 S<text> text contains non-breaking spaces
95 C<code> literal code
96 L<name> A link (cross reference) to name
97 L<name> manpage
98 L<name/ident> item in manpage
99 L<name/"sec"> section in other manpage
100 L<"sec"> section in this manpage
101 (the quotes are optional)
cb1a09d0 102 L</"sec"> ditto
a0d0e21e 103 F<file> Used for filenames
cb1a09d0 104 X<index> An index entry
a0d0e21e
LW
105 Z<> A zero-width character
106
3141265f 107=back
108
a0d0e21e
LW
109That's it. The intent is simplicity, not power. I wanted paragraphs
110to look like paragraphs (block format), so that they stand out
111visually, and so that I could run them through fmt easily to reformat
112them (that's F7 in my version of B<vi>). I wanted the translator (and not
113me) to worry about whether " or ' is a left quote or a right quote
114within filled text, and I wanted it to leave the quotes alone dammit in
115verbatim mode, so I could slurp in a working program, shift it over 4
116spaces, and have it print out, er, verbatim. And presumably in a
117constant width font.
118
119In particular, you can leave things like this verbatim in your text:
120
121 Perl
122 FILEHANDLE
123 $variable
124 function()
125 manpage(3r)
126
127Doubtless a few other commands or sequences will need to be added along
128the way, but I've gotten along surprisingly well with just these.
129
130Note that I'm not at all claiming this to be sufficient for producing a
131book. I'm just trying to make an idiot-proof common source for nroff,
132TeX, and other markup languages, as used for online documentation.
cb1a09d0
AD
133Translators exist for B<pod2man> (that's for nroff(1) and troff(1)),
134B<pod2html>, B<pod2latex>, and B<pod2fm>.
a0d0e21e 135
4633a7c4
LW
136=head1 Embedding Pods in Perl Modules
137
138You can embed pod documentation in your Perl scripts. Start your
139documentation with a =head1 command at the beg, and end it with
140an =cut command. Perl will ignore the pod text. See any of the
cb1a09d0
AD
141supplied library modules for examples. If you're going to put
142your pods at the end of the file, and you're using an __END__
143or __DATA__ cut mark, make sure to put a blank line there before
144the first pod directive.
145
146 __END__
147
148 =head1 NAME
149
150 modern - I am a modern module
151
152If you had not had that blank line there, then the translators wouldn't
153have seen it.
154
155=head1 SEE ALSO
156
157L<pod2man> and L<perlsyn/"PODs: Embedded Documentation">
4633a7c4 158
cb1a09d0 159=head1 AUTHOR
a0d0e21e
LW
160
161Larry Wall
162