home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 May / Chip_2000-05_cd1.bin / zkuste / Perl / ActivePerl-5.6.0.613.msi / 䆊䌷䈹䈙䏵-䞅䞆䞀㡆䞃䄦䠥 / _e78ebd0585c70d067e3be180c59ff75b < prev    next >
Text File  |  2000-03-23  |  14KB  |  332 lines

  1. <HTML>
  2. <HEAD>
  3. <TITLE>perlpod - plain old documentation</TITLE>
  4. <LINK REL="stylesheet" HREF="../../Active.css" TYPE="text/css">
  5. <LINK REV="made" HREF="mailto:">
  6. </HEAD>
  7.  
  8. <BODY>
  9. <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
  10. <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
  11. <STRONG><P CLASS=block> perlpod - plain old documentation</P></STRONG>
  12. </TD></TR>
  13. </TABLE>
  14.  
  15. <A NAME="__index__"></A>
  16. <!-- INDEX BEGIN -->
  17.  
  18. <UL>
  19.  
  20.     <LI><A HREF="#name">NAME</A></LI>
  21.     <LI><A HREF="#description">DESCRIPTION</A></LI>
  22.     <UL>
  23.  
  24.         <LI><A HREF="#verbatim paragraph">Verbatim Paragraph</A></LI>
  25.         <LI><A HREF="#command paragraph">Command Paragraph</A></LI>
  26.         <LI><A HREF="#ordinary block of text">Ordinary Block of Text</A></LI>
  27.         <LI><A HREF="#the intent">The Intent</A></LI>
  28.         <LI><A HREF="#embedding pods in perl modules">Embedding Pods in Perl Modules</A></LI>
  29.         <LI><A HREF="#common pod pitfalls">Common Pod Pitfalls</A></LI>
  30.     </UL>
  31.  
  32.     <LI><A HREF="#see also">SEE ALSO</A></LI>
  33.     <LI><A HREF="#author">AUTHOR</A></LI>
  34. </UL>
  35. <!-- INDEX END -->
  36.  
  37. <HR>
  38. <P>
  39. <H1><A NAME="name">NAME</A></H1>
  40. <P>perlpod - plain old documentation</P>
  41. <P>
  42. <HR>
  43. <H1><A NAME="description">DESCRIPTION</A></H1>
  44. <P>A pod-to-whatever translator reads a pod file paragraph by paragraph,
  45. and translates it to the appropriate output format.  There are
  46. three kinds of paragraphs:
  47. <A HREF="#verbatim paragraph">verbatim</A>,
  48. <A HREF="#command paragraph">command</A>, and
  49. <A HREF="#ordinary block of text">ordinary text</A>.</P>
  50. <P>
  51. <H2><A NAME="verbatim paragraph">Verbatim Paragraph</A></H2>
  52. <P>A verbatim paragraph, distinguished by being indented (that is,
  53. it starts with space or tab).  It should be reproduced exactly,
  54. with tabs assumed to be on 8-column boundaries.  There are no
  55. special formatting escapes, so you can't italicize or anything
  56. like that.  A \ means \, and nothing else.</P>
  57. <P>
  58. <H2><A NAME="command paragraph">Command Paragraph</A></H2>
  59. <P>All command paragraphs start with ``='', followed by an
  60. identifier, followed by arbitrary text that the command can
  61. use however it pleases.  Currently recognized commands are</P>
  62. <PRE>
  63.     =head1 heading
  64.     =head2 heading
  65.     =item text
  66.     =over N
  67.     =back
  68.     =cut
  69.     =pod
  70.     =for X
  71.     =begin X
  72.     =end X</PRE>
  73. <DL>
  74. <DT><STRONG><A NAME="item_%3Dpod">=pod</A></STRONG><BR>
  75. <DD>
  76. <DT><STRONG><A NAME="item_%3Dcut">=cut</A></STRONG><BR>
  77. <DD>
  78. The ``=pod'' directive does nothing beyond telling the compiler to lay
  79. off parsing code through the next ``=cut''.  It's useful for adding
  80. another paragraph to the doc if you're mixing up code and pod a lot.
  81. <P></P>
  82. <DT><STRONG><A NAME="item_%3Dhead1">=head1</A></STRONG><BR>
  83. <DD>
  84. <DT><STRONG><A NAME="item_%3Dhead2">=head2</A></STRONG><BR>
  85. <DD>
  86. Head1 and head2 produce first and second level headings, with the text in
  87. the same paragraph as the ``=headn'' directive forming the heading description.
  88. <P></P>
  89. <DT><STRONG><A NAME="item_%3Dover">=over</A></STRONG><BR>
  90. <DD>
  91. <DT><STRONG><A NAME="item_%3Dback">=back</A></STRONG><BR>
  92. <DD>
  93. <DT><STRONG><A NAME="item_%3Ditem">=item</A></STRONG><BR>
  94. <DD>
  95. Item, over, and back require a little more explanation: ``=over'' starts a
  96. section specifically for the generation of a list using ``=item'' commands. At
  97. the end of your list, use ``=back'' to end it. You will probably want to give
  98. ``4'' as the number to ``=over'', as some formatters will use this for indentation.
  99. This should probably be a default. Note also that there are some basic rules
  100. to using =item: don't use them outside of an =over/=back block, use at least
  101. one inside an =over/=back block, you don't _have_ to include the =back if
  102. the list just runs off the document, and perhaps most importantly, keep the
  103. items consistent: either use ``=item *'' for all of them, to produce bullets,
  104. or use ``=item 1.'', ``=item 2.'', etc., to produce numbered lists, or use
  105. ``=item foo'', ``=item bar'', etc., i.e., things that looks nothing like bullets
  106. or numbers. If you start with bullets or numbers, stick with them, as many
  107. formatters use the first ``=item'' type to decide how to format the list.
  108. <P></P>
  109. <DT><STRONG><A NAME="item_%3Dfor">=for</A></STRONG><BR>
  110. <DD>
  111. <DT><STRONG><A NAME="item_%3Dbegin">=begin</A></STRONG><BR>
  112. <DD>
  113. <DT><STRONG><A NAME="item_%3Dend">=end</A></STRONG><BR>
  114. <DD>
  115. For, begin, and end let you include sections that are not interpreted
  116. as pod text, but passed directly to particular formatters. A formatter
  117. that can utilize that format will use the section, otherwise it will be
  118. completely ignored.  The directive ``=for'' specifies that the entire next
  119. paragraph is in the format indicated by the first word after
  120. ``=for'', like this:
  121. <PRE>
  122.  =for html <br>
  123.   <p> This is a raw HTML paragraph </p></PRE>
  124. <P>The paired commands ``=begin'' and ``=end'' work very similarly to ``=for'', but
  125. instead of only accepting a single paragraph, all text from ``=begin'' to a
  126. paragraph with a matching ``=end'' are treated as a particular format.</P>
  127. <P>Here are some examples of how to use these:</P>
  128. <PRE>
  129.  =begin html</PRE>
  130. <PRE>
  131.  <br>Figure 1.<IMG SRC="figure1.png"><br></PRE>
  132. <PRE>
  133.  =end html</PRE>
  134. <PRE>
  135.  =begin text</PRE>
  136. <PRE>
  137.    ---------------
  138.    |  foo        |
  139.    |        bar  |
  140.    ---------------</PRE>
  141. <PRE>
  142.  ^^^^ Figure 1. ^^^^</PRE>
  143. <PRE>
  144.  =end text</PRE>
  145. <P>Some format names that formatters currently are known to accept include
  146. ``roff'', ``man'', ``latex'', ``tex'', ``text'', and ``html''. (Some formatters will
  147. treat some of these as synonyms.)</P>
  148. <P>And don't forget, when using any command, that the command lasts up until
  149. the end of the <STRONG>paragraph</STRONG>, not the line. Hence in the examples below, you
  150. can see the empty lines after each command to end its paragraph.</P>
  151. <P>Some examples of lists include:</P>
  152. <PRE>
  153.  =over 4</PRE>
  154. <PRE>
  155.  =item *</PRE>
  156. <PRE>
  157.  First item</PRE>
  158. <PRE>
  159.  =item *</PRE>
  160. <PRE>
  161.  Second item</PRE>
  162. <PRE>
  163.  =back</PRE>
  164. <PRE>
  165.  =over 4</PRE>
  166. <PRE>
  167.  =item Foo()</PRE>
  168. <PRE>
  169.  Description of Foo function</PRE>
  170. <PRE>
  171.  =item Bar()</PRE>
  172. <PRE>
  173.  Description of Bar function</PRE>
  174. <PRE>
  175.  =back</PRE>
  176. <P></P></DL>
  177. <P>
  178. <H2><A NAME="ordinary block of text">Ordinary Block of Text</A></H2>
  179. <P>It will be filled, and maybe even
  180. justified.  Certain interior sequences are recognized both
  181. here and in commands:</P>
  182. <PRE>
  183.     I<text>     Italicize text, used for emphasis or variables
  184.     B<text>     Embolden text, used for switches and programs
  185.     S<text>     Text contains non-breaking spaces
  186.     C<code>     Render code in a typewriter font, or give some other
  187.                 indication that this represents program text
  188.     L<name>     A link (cross reference) to name
  189.                     L<name>             manual page
  190.                     L<name/ident>       item in manual page
  191.                     L<name/"sec">       section in other manual page
  192.                     L<"sec">            section in this manual page
  193.                                         (the quotes are optional)
  194.                     L</"sec">           ditto
  195.                 same as above but only 'text' is used for output.
  196.                 (Text can not contain the characters '/' and '|', 
  197.                 and should contain matched '<' or '>')
  198.                     L<text|name>
  199.                     L<text|name/ident>
  200.                     L<text|name/"sec">
  201.                     L<text|"sec">
  202.                     L<text|/"sec"></PRE>
  203. <PRE>
  204.     F<file>     Used for filenames
  205.     X<index>    An index entry
  206.     Z<>         A zero-width character
  207.     E<escape>   A named character (very similar to HTML escapes)
  208.                     E<lt>               A literal <
  209.                     E<gt>               A literal >
  210.                     E<sol>              A literal /
  211.                     E<verbar>           A literal |
  212.                     (these are optional except in other interior
  213.                      sequences and when preceded by a capital letter)
  214.                     E<n>                Character number n (probably in ASCII)
  215.                     E<html>             Some non-numeric HTML entity, such
  216.                                         as E<Agrave></PRE>
  217. <P>Most of the time, you will only need a single set of angle brackets to
  218. delimit the beginning and end of interior sequences.  However, sometimes
  219. you will want to put a right angle bracket (or greater-than sign '>')
  220. inside of a sequence.  This is particularly common when using a sequence
  221. to provide a different font-type for a snippet of code.  As with all
  222. things in Perl, there is more than one way to do it.  One way is to
  223. simply escape the closing bracket using an <CODE>E</CODE> sequence:</P>
  224. <PRE>
  225.     C<$a E<lt>=E<gt> $b></PRE>
  226. <P>This will produce: ``<CODE>$a <=> $b</CODE>''</P>
  227. <P>A more readable, and perhaps more ``plain'' way is to use an alternate set of
  228. delimiters that doesn't require a ``>'' to be escaped.  As of perl5.5.660,
  229. doubled angle brackets (``<<'' and ``>>'') may be used <EM>if and only if there
  230. is whitespace immediately following the opening delimiter and immediately
  231. preceding the closing delimiter!</EM> For example, the following will do the
  232. trick:</P>
  233. <PRE>
  234.     C<< $a <=> $b >></PRE>
  235. <P>In fact, you can use as many repeated angle-brackets as you like so
  236. long as you have the same number of them in the opening and closing
  237. delimiters, and make sure that whitespace immediately follows the last
  238. '<' of the opening delimiter, and immediately precedes the first '>' of
  239. the closing delimiter.  So the following will also work:</P>
  240. <PRE>
  241.     C<<< $a <=> $b >>>
  242.     C<<<< $a <=> $b >>>></PRE>
  243. <P>This is currently supported by pod2text (Pod::Text), pod2man (Pod::Man),
  244. and any other pod2xxx and Pod::Xxxx translator that uses Pod::Parser
  245. 1.093 or later.</P>
  246. <P>
  247. <H2><A NAME="the intent">The Intent</A></H2>
  248. <P>That's it.  The intent is simplicity, not power.  I wanted paragraphs
  249. to look like paragraphs (block format), so that they stand out
  250. visually, and so that I could run them through fmt easily to reformat
  251. them (that's F7 in my version of <STRONG>vi</STRONG>).  I wanted the translator (and not
  252. me) to worry about whether `` or ' is a left quote or a right quote
  253. within filled text, and I wanted it to leave the quotes alone, dammit, in
  254. verbatim mode, so I could slurp in a working program, shift it over 4
  255. spaces, and have it print out, er, verbatim.  And presumably in a
  256. constant width font.</P>
  257. <P>In particular, you can leave things like this verbatim in your text:</P>
  258. <PRE>
  259.     Perl
  260.     FILEHANDLE
  261.     $variable
  262.     function()
  263.     manpage(3r)</PRE>
  264. <P>Doubtless a few other commands or sequences will need to be added along
  265. the way, but I've gotten along surprisingly well with just these.</P>
  266. <P>Note that I'm not at all claiming this to be sufficient for producing a
  267. book.  I'm just trying to make an idiot-proof common source for nroff,
  268. TeX, and other markup languages, as used for online documentation.
  269. Translators exist for <STRONG>pod2man</STRONG>  (that's for <CODE>nroff(1)</CODE> and troff(1)),
  270. <STRONG>pod2text</STRONG>, <STRONG>pod2html</STRONG>, <STRONG>pod2latex</STRONG>, and <STRONG>pod2fm</STRONG>.</P>
  271. <P>
  272. <H2><A NAME="embedding pods in perl modules">Embedding Pods in Perl Modules</A></H2>
  273. <P>You can embed pod documentation in your Perl scripts.  Start your
  274. documentation with a ``=head1'' command at the beginning, and end it
  275. with a ``=cut'' command.  Perl will ignore the pod text.  See any of the
  276. supplied library modules for examples.  If you're going to put your
  277. pods at the end of the file, and you're using an __END__ or __DATA__
  278. cut mark, make sure to put an empty line there before the first pod
  279. directive.</P>
  280. <PRE>
  281.     __END__</PRE>
  282. <PRE>
  283.     =head1 NAME</PRE>
  284. <PRE>
  285.     modern - I am a modern module</PRE>
  286. <P>If you had not had that empty line there, then the translators wouldn't
  287. have seen it.</P>
  288. <P>
  289. <H2><A NAME="common pod pitfalls">Common Pod Pitfalls</A></H2>
  290. <UL>
  291. <LI>
  292. Pod translators usually will require paragraphs to be separated by
  293. completely empty lines.  If you have an apparently empty line with
  294. some spaces on it, this can cause odd formatting.
  295. <P></P>
  296. <LI>
  297. Translators will mostly add wording around a L<> link, so that
  298. <CODE>L<foo(1)></CODE> becomes ``the <EM>foo</EM>(1) manpage'', for example (see
  299. <STRONG>pod2man</STRONG> for details).  Thus, you shouldn't write things like <CODE>the
  300. LE<lt>fooE<gt> manpage</CODE>, if you want the translated document to read
  301. sensibly.
  302. <P>If you need total control of the text used for a link in the output
  303. use the form L<show this text|foo> instead.</P>
  304. <P></P>
  305. <LI>
  306. The <STRONG>podchecker</STRONG> command is provided to check pod syntax
  307. for errors and warnings. For example, it checks for completely
  308. blank lines in pod segments and for unknown escape sequences.
  309. It is still advised to pass it through
  310. one or more translators and proofread the result, or print out the
  311. result and proofread that.  Some of the problems found may be bugs in
  312. the translators, which you may or may not wish to work around.
  313. <P></P></UL>
  314. <P>
  315. <HR>
  316. <H1><A NAME="see also">SEE ALSO</A></H1>
  317. <P><EM>pod2man</EM>, <A HREF="../../lib/Pod/perlsyn.html#pods: embedded documentation">PODs: Embedded Documentation in the perlsyn manpage</A>,
  318. <EM>podchecker</EM></P>
  319. <P>
  320. <HR>
  321. <H1><A NAME="author">AUTHOR</A></H1>
  322. <P>Larry Wall</P>
  323. <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
  324. <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
  325. <STRONG><P CLASS=block> perlpod - plain old documentation</P></STRONG>
  326. </TD></TR>
  327. </TABLE>
  328.  
  329. </BODY>
  330.  
  331. </HTML>
  332.