Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
My rule for documentation is that I should be able to look over the code in a few years and see easily what the code does and whether all or parts of it is useful to any task at hand.

This leads me to a style similar to that of documenting new projects in sections:

  • Purpose: Summary of what the script does and why
  • Scope: Who is this for? Developers? Users? How much of whatever task is assumed versus handled?
  • Input and output requirements: XML input?
  • Dependencies: external programs, file formats, databases, embedded references to paths, etc.
  • Usage: How should I execute it?
  • Change history: This is more for keeping track of updates and debugging purposes but can be very helpful, especially so if more than one developer edits the script. This might be part of CVS or could be at the top of the script. An example:
    # 08/26/04 BW Changed doAssemblyJobs to read bait from file versus DB # 08/25/04 BW Added indexing and formatdb of gss files. # 08/17/04 BW Moved logic of into this script
For documention of individual functions that aren't completely obvious, I tend to add a couple lines of comments to indicate algorithms or other unusual behavior. With good variable names, this isn't needed much. An example:
# Generic job monitor for watching jobs finish. # - No action is taken when each job finishes. # - Function returns when all jobs have finished. # - Inputs: A hash of job IDs from LSF # - Returns: No specified return code

One thing I try to remember is that while things may seem obvious while writing and testing the code, a year or so in the future they won't be. Commenting with that in mind has helped me out in many situations.

In reply to Re: Preferred method of documentation? by bwelch
in thread Preferred method of documentation? by Anonymous Monk

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (3)
    As of 2020-11-25 03:07 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found