Asking for good examples of POD is a little like asking for good examples of a web page. What's good depends on the complexity of your module, your development needs, your production environment, and even your personal style. There is a lot of variety in both visible content and internal placement of the POD that creates the content. I'll highlight a few points here, but my recommendation is that you study some CPAN modules and ask yourself "What works (communicates well) and why?" Then develop a style of your own.

There is a basic skeleton that many of the CPAN modules seem to follow. This consists of the following sections:

  1. NAME section - name of function in bold followed by a one line description.
  2. various descriptive sections - often this is divided into two sections. The first is a SYNOPSIS section that gives a quick thumbnail sketch of the module's capabilities, usually via sample code or a list of function/methods. The second is a much longer section titled DESCRIPTION. This covers all the points that may not be obvious from the synopsis. However, the number and organization of the description sections can vary a lot depending on the complexity of the module
  3. CAVEATS (sometimes titled "BUGS AND CAVEATS", "NOTES AND CAVEATS", "NOTES" or "BUGS") - one or more sections listing known bugs, unrealized implementation goals, and general restrictions on use contexts - for example: operating system limitations or whether or not the module plays well with Apache and mod_perl
  4. SEE ALSO - section listing related modules. Modules can be related because they do the same thing a different way, provide helpful background information or because they are a useful complement to module at hand. Sometimes you will also see a brief description explaining why they should be "seen also".
  5. AUTHOR - section listing everyone who wrote or helped with the module.
  6. COPYRIGHT - section listing who holds the copy rights and licensing agreements.

To sort out what information belongs in your description sections is probably the hardest part of writing good POD. A lot depends on the complexity of your module:

If the parameters are simple and the role of each function is pretty obvious from its name, you may be able to get away with documentation that consists of a brief SYNOPSIS section followed by a DESCRIPTION section briefly describing each function and its parameters one by one.

If there are a lot of similarly defined parameters, it is often a good idea to have the synopsis section use consistent variable names for each parameter. Then include a subsection of DESCRIPTION explaining what values parameters $x, $y, $mumblefoo can take. This can save a lot of time for your module user: without users have to scan back and forth between your individual function descriptions to figure out if $x in makeFred($x) has the same meaning as $x in in makeBarney($x). Not fun.

For more complex modules, its hard to come up with rules of thumb, so I refer you back to the original advice: study a variety of CPAN modules and ask yourself - what does and does not get its point across and make the module easier to use?

Once one has figured out what to document, the next question is where to document. There are several styles and I don't know that one is right - they suit different programming styles, maintenence and production needs:

One final issue relating to POD is the role of "hidden POD". POD can be used for many things including in-line test cases, private developer notes, and cook book examples. The normal document generator will quietly ignore =foobar if it doesn't know what foobar is supposed to mean. There are numerous modules on CPAN that take advantage of this feature to embed all sorts of maintenence related information in source code files. For example, see Test::Inline for inline test cases and Test::Cookbook for cookbook examples that double as executable code. (Note: I don't use either of these modules - so I can't vouch for their safety)

Best, beth


In reply to Re: good examples of POD documentation by ELISHEVA
in thread good examples of POD documentation by perl5ever

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.