perl5ever has asked for the wisdom of the Perl Monks concerning the following question:
I'm looking for good examples of how to document a perl module using POD.
What modules would you suggest I look at?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: good examples of POD documentation
by eff_i_g (Curate) on Mar 05, 2009 at 16:40 UTC | |
| [reply] |
|
Re: good examples of POD documentation
by Bloodnok (Vicar) on Mar 05, 2009 at 16:44 UTC | |
Your decision might also be affected by your development environment e.g. Eclipse/E-P-I-C doesn't appear to like the standardised h2xs approach. It may also be that your employer/client might have substantial view of/influence on your choice. Afterthought: looking at some of the Test::Pod modules e.g. Test::Pod::Coverage, might provide some helpful information...
A user level that continues to overstate my experience :-))
| [reply] |
|
Re: good examples of POD documentation
by ELISHEVA (Prior) on Mar 06, 2009 at 12:45 UTC | |
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: 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 | [reply] [d/l] [select] |
by JavaFan (Canon) on Mar 06, 2009 at 14:19 UTC | |
in the file but out of the way - some people feel that keeping documentation, especially lengthy documentation close to each function makes it difficult for them to get a good birds eye view of a module. This is particularly true if your team has a lot of people that are very fluent in reading code. To get POD out of the way, some people prefer to place all of the POD at the top or the bottom.I'm one of the people who puts the POD after the __END__. For the reasons you mention and for an additional reason: I often don't document the code in the same as they appear in the code. In the code, you may want to keep methods accessing the same data close to each other, but for documentation you may have other considerations. I typically use methods I expect to be used often early in the documentation, while lesser used method are documented further down. Sometimes I prefer the documentation to describe the methods sorted lexigraphical. And if the description of method A is build on the description of method B, I like to have in the documentation A right above B. Moving the documentation "out of the way" gives me the freedom of moving documentation (and code) around without changing the order. | [reply] |
|
Re: good examples of POD documentation
by locked_user sundialsvc4 (Abbot) on Mar 05, 2009 at 16:59 UTC | |
Probably the best source of advice is ... existing modules on CPAN. And, follow your own instincts: what represents “great documentatation” to you? | |
by JavaFan (Canon) on Mar 05, 2009 at 18:24 UTC | |
Probably the best source of advice is ... existing modules on CPAN.That's a silly advice. Anyone can upload any crap on CPAN, and many people do. There are modules with good POD on CPAN, but there are also modules with shitty or hardly any POD on CPAN. The existence of a module on CPAN does not imply anything about its quality (code nor documentation wise). Just pointing to CPAN isn't very helpful in this case. | [reply] |
|
Re: good examples of POD documentation
by kyle (Abbot) on Mar 05, 2009 at 16:34 UTC | |
| [reply] |
|
Re: good examples of POD documentation
by jplindstrom (Monsignor) on Mar 06, 2009 at 14:24 UTC | |
These two audiences have two quite different needs. /J | [reply] |