http://qs321.pair.com?node_id=694439


in reply to Re: What is your practice for code documentation?
in thread What is your practice for code documentation?

Indeed, the synopsis is extremely valuable. Unfortunately many people leave out a very important part: the result of the code displayed. In my modules I use the same format as I use on PM code examples:
CODE __END__ OUTPUT
For instance, the synopsis in List::Extract would be near useless if it wasn't for the output.

It's easy to generate (and manually test) this by simply typing perl -Mstrict -w and then pasting the code. On your screen you now have the code, __END__, and the output following that, ready to be copied back.

But the module may change, and an important feature of this format is that it's easy to test it. I've written, but not released, Test::Synopsis which extracts the code from the POD, compiles it, and if there were no errors or warnings, the output is compared to what's after __END__ (if anything).

It has proven to be useful to me. I'm considering it for release.

lodin