PHPBuilder - Document your PHP scripts Realtime



RSS Twitter
Tips Application Architecture

Document your PHP scripts Realtime

by: Dustin Schneider
|
August 29, 2000

In response to Stefano Locati's "How to Document Your PHP classes", I created a quick & simple PHP script which will parse other PHP3 files and create some basic documentation. The advantage to this is, it can be placed under any comment -- plus it's very extendable. The current scripts recognises these commands:
@@ = Header
%% = Description
!! = Horizontal Line 
;  = End of decleration. 


For example:
/*
@@this_function($var1, $var2);
%%This function takes 2 variables and does absolutely nothing with them.;
!!
*/


Would produce something like this:

this_function($var1, $var2)

Description: This function takes 2 variables and does absolutely nothing with them.
(horizontal line here)


$filename = "FILENAME_HERE";

$fp = fopen($filename, "r");
$buffer = fread($fp, filesize($filename));
fclose($fp);

for($i=0; $i<strlen($buffer); $i++)
{
 // Header
 if ($buffer[$i] == '@' && $buffer[$i+1] == '@')
 {
  echo "

"; $i++; while($buffer[$i++] != ';') { if ($buffer[$i] == ';') break; echo $buffer[$i]; } echo "

"; } // Description if ($buffer[$i] == '%' && $buffer[$i+1] == '%') { echo "Description: "; $i++; while($buffer[$i++] != ';') { if ($buffer[$i] == ';') break; echo $buffer[$i]; } echo "
"; } if ($buffer[$i] == '!' && $buffer[$i+1] == '!') { echo "<hr></hr>"; } }


Dustin Schneider

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Dustin Schneider

Comment:



Comment:

(Maximum characters: 1200). You have characters left.