Cari di Perl 
    Perl Tutorial
Daftar Isi
(Sebelumnya) Plain Old Documentation: forma ...Various Perl diagnostics (Berikutnya)
Language Reference

Perl POD style guide

Daftar Isi

NAME

perlpodstyle - Perl POD style guide

DESCRIPTION

These are general guidelines for how to write POD documentation for Perlscripts and modules, based on general guidelines for writing good Unix manpages. All of these guidelines are, of course, optional, but followingthem will make your documentation more consistent with other documentationon the system.

Here are some simple guidelines for markup; see perlpod for details.

  • bold (B<>)

    NOTE: Use extremely rarely. Do not use bold for emphasis; that'swhat italics are for. Restrict bold for notices like NOTE: andWARNING:. However, program arguments and options--but not theirnames!--are written in bold (using B<>) to distinguish the -fcommand-line option from the -f filetest operator.

  • italic (I<>)

    Use italic to emphasize text, like this. Function names aretraditionally written in italics; if you write a function as function(),Pod::Man will take care of this for you. Names of programs, including thename of the program being documented, are conventionally written in italics(using I<>) wherever they occur in normal roman text.

  • code (C<>)

    Literal code should be in C<>. However metasyntactic placeholdersshould furthermore be nested in "italics" (actually, oblique) likeC<I<>>. That wayC<accept(I<NEWSOCKET>, <GENERICSOCKET>)>renders as accept(NEWSOCKET, GENERICSOCKET).

  • files (F<>)

    Filenames, whether absolute or relative, are specified with the F<>markup. This will render as italics, but has other semantic connotations.

References to other man pages should be in the form "manpage(section)" or"L<manpage(section)>", and Pod::Man will automatically formatthose appropriately. Both will render as manpage(section). The secondform, with L<>, is used to request that a POD formatter make a linkto the man page if possible. As an exception, one normally omits thesection when referring to module documentation because not all systemsplace it in section 3, although that is the default. You may useL<Module::Name> for module references instead, but this isoptional because the translators are supposed to recognize modulereferences in pod, just as they do variable references like $foo and such.

References to other programs or functions are normally in the form of manpage references so that cross-referencing tools can provide the user withlinks and the like. It's possible to overdo this, though, so be careful notto clutter your documentation with too much markup. References to otherprograms that are not given as man page references should be enclosed initalics via I<>.

Major headers should be set out using a =head1 directive, and arehistorically written in the rather startling ALL UPPER CASE format; this isnot mandatory, but it's strongly recommended so that sections haveconsistent naming across different software packages. The translators aresupposed to translate all caps into small caps. Minor headers may beincluded using =head2, and are typically in mixed case.

The standard sections of a manual page are:

  • NAME

    Mandatory section; should be a comma-separated list of programs orfunctions documented by this POD page, such as:

    1. foo, bar - programs to do something

    Manual page indexers are often extremely picky about the format of thissection, so don't put anything in it except this line. Every program orfunction documented by this POD page should be listed, separated by acomma and a space. For a Perl module, just give the module name. Asingle dash, and only a single dash, should separate the list of programsor functions from the description. Do not use any markup such asC<> or I<> anywhere in this line. Functions should not bequalified with () or the like. The description should ideally fit on asingle line, even if a man program replaces the dash with a few tabs.

  • SYNOPSIS

    A short usage summary for programs and functions. This section ismandatory for section 3 pages. For Perl module documentation, it'susually convenient to have the contents of this section be a verbatimblock showing some (brief) examples of typical ways the module is used.

  • DESCRIPTION

    Extended description and discussion of the program or functions, or thebody of the documentation for man pages that document something else. Ifparticularly long, it's a good idea to break this up into subsections=head2 directives like:

    1. =head2 Normal Usage
    2. =head2 Advanced Features
    3. =head2 Writing Configuration Files

    or whatever is appropriate for your documentation.

    For a module, this is generally where the documentation of the interfacesprovided by the module goes, usually in the form of a list with an=item for each interface. Depending on how many interfaces there are,you may want to put that documentation in separate METHODS, FUNCTIONS,CLASS METHODS, or INSTANCE METHODS sections instead and save theDESCRIPTION section for an overview.

  • OPTIONS

    Detailed description of each of the command-line options taken by theprogram. This should be separate from the description for the use ofparsers like Pod::Usage. This is normally presented as a list, witheach option as a separate =item. The specific option string should beenclosed in B<>. Any values that the option takes should beenclosed in I<>. For example, the section for the option--section=manext would be introduced with:

    1. =item B<--section>=I<manext>

    Synonymous options (like both the short and long forms) are separated by acomma and a space on the same =item line, or optionally listed as theirown item with a reference to the canonical name. For example, since--section can also be written as -s, the above would be:

    1. =item B<-s> I<manext>, B<--section>=I<manext>

    Writing the short option first is recommended because it's easier to read.The long option is long enough to draw the eye to it anyway and the shortoption can otherwise get lost in visual noise.

  • RETURN VALUE

    What the program or function returns, if successful. This section can beomitted for programs whose precise exit codes aren't important, providedthey return 0 on success and non-zero on failure as is standard. Itshould always be present for functions. For modules, it may be useful tosummarize return values from the module interface here, or it may be moreuseful to discuss return values separately in the documentation of eachfunction or method the module provides.

  • ERRORS

    Exceptions, error return codes, exit statuses, and errno settings.Typically used for function or module documentation; program documentationuses DIAGNOSTICS instead. The general rule of thumb is that errorsprinted to STDOUT or STDERR and intended for the end user aredocumented in DIAGNOSTICS while errors passed internal to the callingprogram and intended for other programmers are documented in ERRORS. Whendocumenting a function that sets errno, a full list of the possible errnovalues should be given here.

  • DIAGNOSTICS

    All possible messages the program can print out and what they mean. Youmay wish to follow the same documentation style as the Perl documentation;see perldiag(1) for more details (and look at the POD source as well).

    If applicable, please include details on what the user should do tocorrect the error; documenting an error as indicating "the input buffer istoo small" without telling the user how to increase the size of the inputbuffer (or at least telling them that it isn't possible) aren't veryuseful.

  • EXAMPLES

    Give some example uses of the program or function. Don't skimp; usersoften find this the most useful part of the documentation. The examplesare generally given as verbatim paragraphs.

    Don't just present an example without explaining what it does. Adding ashort paragraph saying what the example will do can increase the value ofthe example immensely.

  • ENVIRONMENT

    Environment variables that the program cares about, normally presented asa list using =over, =item, and =back. For example:

    1. =over 6
    2. =item HOME
    3. Used to determine the user's home directory. F<.foorc> in this
    4. directory is read for configuration details, if it exists.
    5. =back

    Since environment variables are normally in all uppercase, no additionalspecial formatting is generally needed; they're glaring enough as it is.

  • FILES

    All files used by the program or function, normally presented as a list,and what it uses them for. File names should be enclosed in F<>.It's particularly important to document files that will be potentiallymodified.

  • CAVEATS

    Things to take special care with, sometimes called WARNINGS.

  • BUGS

    Things that are broken or just don't work quite right.

  • RESTRICTIONS

    Bugs you don't plan to fix. :-)

  • NOTES

    Miscellaneous commentary.

  • AUTHOR

    Who wrote it (use AUTHORS for multiple people). It's a good idea toinclude your current email address (or some email address to which bugreports should be sent) or some other contact information so that usershave a way of contacting you. Remember that program documentation tendsto roam the wild for far longer than you expect and pick a contact methodthat's likely to last.

  • HISTORY

    Programs derived from other sources sometimes have this. Some people keepa modification log here, but that usually gets long and is normally bettermaintained in a separate file.

  • COPYRIGHT AND LICENSE

    For copyright

    1. Copyright YEAR(s) YOUR NAME(s)

    (No, (C) is not needed. No, "all rights reserved" is not needed.)

    For licensing the easiest way is to use the same licensing as Perl itself:

    1. This library is free software; you may redistribute it and/or modify
    2. it under the same terms as Perl itself.

    This makes it easy for people to use your module with Perl. Note thatthis licensing example is neither an endorsement or a requirement, you areof course free to choose any licensing.

  • SEE ALSO

    Other man pages to check out, like man(1), man(7), makewhatis(8), orcatman(8). Normally a simple list of man pages separated by commas, or aparagraph giving the name of a reference work. Man page references, ifthey use the standard name(section) form, don't have to be enclosed inL<> (although it's recommended), but other things in this sectionprobably should be when appropriate.

    If the package has a mailing list, include a URL or subscriptioninstructions here.

    If the package has a web site, include a URL here.

Documentation of object-oriented libraries or modules may want to useCONSTRUCTORS and METHODS sections, or CLASS METHODS and INSTANCE METHODSsections, for detailed documentation of the parts of the library and savethe DESCRIPTION section for an overview. Large modules with a functioninterface may want to use FUNCTIONS for similar reasons. Some people useOVERVIEW to summarize the description if it's quite long.

Section ordering varies, although NAME must always be the first section(you'll break some man page systems otherwise), and NAME, SYNOPSIS,DESCRIPTION, and OPTIONS generally always occur first and in that order ifpresent. In general, SEE ALSO, AUTHOR, and similar material should beleft for last. Some systems also move WARNINGS and NOTES to last. Theorder given above should be reasonable for most purposes.

Some systems use CONFORMING TO to note conformance to relevant standardsand MT-LEVEL to note safeness for use in threaded programs or signalhandlers. These headings are primarily useful when documenting parts of aC library.

Finally, as a general note, try not to use an excessive amount of markup.As documented here and in Pod::Man, you can safely leave Perl variables,module names, function names, man page references, and the like unadornedby markup, and the POD translators will figure it all out for you. Thismakes it much easier to later edit the documentation. Note that manyexisting translators will do the wrong thing with email addresses whenwrapped in L<>, so don't do that.

You can check whether your documentation looks right by running

  1. % pod2text -o something.pod | less

If you have groff installed, you can get an even better look this way:

  1. % pod2man something.pod | groff -Tps -mandoc > something.ps

Now view the resulting Postscript file to see whether everything checks out.

SEE ALSO

For additional information that may be more accurate for your specificsystem, see either man(5) or man(7) depending on your system manualsection numbering conventions.

This documentation is maintained as part of the podlators distribution.The current version is always available from its web site at<http://www.eyrie.org/~eagle/software/podlators/>.

AUTHOR

Russ Allbery <[email protected]>, with large portions of this documentationtaken from the documentation of the original pod2man implementation byLarry Wall and Tom Christiansen.

COPYRIGHT AND LICENSE

Copyright 1999, 2000, 2001, 2004, 2006, 2008, 2010 Russ Allbery<[email protected]>.

This documentation is free software; you may redistribute it and/or modifyit under the same terms as Perl itself.

 
Source : perldoc.perl.org - Official documentation for the Perl programming language
Site maintained by Jon Allen (JJ)     See the project page for more details
Documentation maintained by the Perl 5 Porters
(Sebelumnya) Plain Old Documentation: forma ...Various Perl diagnostics (Berikutnya)