12

Does Perl have a Perl Docs generator? Something like Java Docs or PHP Documenter?

Phill Pafford
  • 83,471
  • 91
  • 263
  • 383

4 Answers4

15

Yes, it's called POD (formerly: perldoc)

You simply write documentation in the source, just like with javadoc.

Briefly, "=item" is a bulleted item, e.g. a function or a parameter "=over" goes down a level of identation, "=back" goes up a level. Use "=cut" where you want to switch back to perl code.

Here is an example of what it could look like:

=item $b->add_module ( %options )

Initialize a module. A module is a repository or a branch of a repository.
Valid options are

=over

=item id

Id of this module

=item repo

Url of repository. Currently only subversion repositories are supported.

=back

=cut
sub add_module($%)
{

Simply pass your perl code through the perldoc program to get the formatted documentation.

amarillion
  • 24,487
  • 15
  • 68
  • 80
  • 1
    Well, it's quite different from JavaDoc or PHPDoc in regards to how you document things, but afaik it is the standard documentation tool – Gordon Jan 25 '10 at 17:02
  • 4
    I would highly suggest not ever using pod between code (interlaced), as the markup is really bloated and will just serve to obfuscate navigation and code coherency. Write self-documenting code, and put the pod at the bottom of the document below an `__END__` tag. – Evan Carroll Jan 25 '10 at 17:22
  • 4
    responding to Evan Carroll - this is just personal preference - i generally prefer interlaced pod, it makes it much easier to keep the documentation up-to-date, and any decent editor will make it easy to see what's code and what's pod. – plusplus Jan 25 '10 at 18:01
7

You mean perldoc?

Also see this related Stack Overflow quesion:

Community
  • 1
  • 1
Gordon
  • 312,688
  • 75
  • 539
  • 559
7

Why, yes. Yes, it does! Perldoc.

Paul Nathan
  • 39,638
  • 28
  • 112
  • 212
2

[just for googlers] As people already said, you make documentation with POD (not comments, comments are for maintainers, pod for user documentation). Usually you add your POD at the start and end of your script or module, and before each method), then you can use perldoc your_module in the console, or pod2html to convert to html and browse in a server, or use pdoc (it is a bit old but is very helpful when you want to have a web doc navigator and links to the code in the web).

there is a newer question about formatting the pod that could be also of your interest perl-documentation-pod-browsers

and this one how-can-i-generate-html-documentation-for-perl-code-comments

And there was another one talking about to do a pod2html and using a css file to mimic the cpansearch pages, but I can not find it now.

Community
  • 1
  • 1
Pablo Marin-Garcia
  • 4,151
  • 2
  • 32
  • 50