Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you document your PHP functions and classes inline? [closed]

I know there are many different standards for PHP code inline documentation. Here's what I mean by inline documentation, and please correct me if there is a better term:

/** * This is the description for the class below. * * @package    my-package * @subpackage my-subpackage * @author     my-name * @version    my-version * ... */ class orderActions { ... 

What is the best and most widely-accepted form of inline documentation? In other words, what are those forms of inline documentation that everyone agrees on, and are not significantly based on opinions; the universally accepted forms of PHP in-line documentation that everyone should know about, but as a questioner, I'm not sure of yet, but after this question is answered, I will have a good overview of, not involving any particular opinions.

Are there any tools to auto-generate such documentation, or does it have to be done by hand?

I'm not interested in generating manuals -- I want to know how to generate the type of code commenting above, or "inline documentation."

like image 999
James Skidmore Avatar asked Jul 25 '09 19:07

James Skidmore


People also ask

What is phpDoc comment?

phpDoc blocks are descriptive comments that are part of the application code. They are used to describe the PHP element in the exact location in the code where the element appears. The block consists of a short description, long description, and phpDoc tags.

What are PHP functions?

PHP User Defined Functions A function is a block of statements that can be used repeatedly in a program. A function will not execute automatically when a page loads. A function will be executed by a call to the function.


2 Answers

PHPDoc, like what you've posted, is a widely accepted form of PHP documentation.

You can use Doxygen to auto-generate the docs.

Edit: In terms of generating in-line documentation in your code, I have never come across a tool that will go back and do this externally for a project. It's generally left in the realm of the IDE to generate a template while you code.

Eclipse actually does a decent job of this (it's one of the few things I like about Eclipse) and I believe Netbeans does as well. Any major IDE will likely have functionality to assist with this type of template generation.

like image 76
zombat Avatar answered Sep 24 '22 17:09

zombat


Choose from:

  • Doxygen
  • phpDocumentator
  • Sami
  • ApiGen
  • CakePHP API docs
  • phpDox

See also the Wikipedia article, "Comparison of documentation generators", section "by Language".

like image 42
Benoit Blanchon Avatar answered Sep 23 '22 17:09

Benoit Blanchon