Any suggestion how I can document my Perl code? What do you use and what tools are available to help me?
Which module do you use to convert pod to html?
Any suggestion how I can document my Perl code? What do you use and what tools are available to help me?
Which module do you use to convert pod to html?
Not to be overly flip, but the best way to document Perl code is the same way as you would document code in any other language.
As for specific tools, I use a mix of standard inline comments, pod for larger chunks of documentation where a format similar to man is appropriate, and TeX as a final fallback for documents that need to be more freeform. (And, in the spirit of "same as any other language", yes, I do use pod for documenting non-Perl code as well.)
Look inside almost any Perl module and you'll see the Plain Old Documentation (POD) format. On CPAN Search, when looking at a module you have the option of viewing the raw source, so that's one way you can look at the raw pod, but you can also use perldoc from the command line. The -m
switch shows you the file
perldoc -m Foo::Bar
Or, if you want to find the file so you can look at it in your favorite editor, use the -l
switch to find it:
perldoc -l Foo::Bar
Once you start documenting your program, you put the Pod in the file right with the code, either interwoven with the code so the documentation is next to the relevant parts, or at the beginning, middle, or end as one big chunk.
Pod is easily translated to several other formats, such as LaTeX, Postscript, HTML, and so on with translators that come with Perl (pod2latex, pod2ps, pod2html). I even have a pod translator that goes to InDesign. Writing your own Pod translator is easy with Pod::Simple, so if you don't find a translator to your favorite final form, just make it yourself.
There are also several tools that you can add to your test suite to check your Pod. The Test::Pod module checks for format errors, the Test::Pod::Coverage module checks the you've documented each subroutine, and so on. You also might be interested in my Perl documentation documentation.
I definitely recommend POD.
POD can also be used in-line with code but I prefer to put at bottom of program after __END__ (as recommended by Damian Conway in Perl Best Practices).
Look at POD::Server & POD::Webserver, which provides a web front-end to all your PODs.
/I3az/
Which module do you use to convert pod to html?
Check out Pod::ProjectDocs - you get a simple command-line utility that will convert all the POD in your Perl project into a set of HTML pages that look just like what you see on search.cpan.org.
You might also want to check out Perl Best Practices by Damian Conway. I used some of the tips to clean up a small Perl code base I inherited.
No one mentioned Smart::Comments? It's not always what you want but good if you need more power to comments.