Click to See Complete Forum and Search --> : Generate documentation...


KungdenKnege
03-02-2003, 03:36 PM
...automatically. I need a script to do that for me. Someting like Javas JavaDoc.

I've tried PHPDoc and PHPDocumentor. PHPDoc was too buggy and ugly, probably because it's just a beta. PHPDocumentor seemd good, but I can't get it work the way I want?

It ignores my @see, @acces and and my descriptions. It just write them as a "-" in the HTML. Weird.

Anyway, do you guys know of any other solution? (Or maybe you know what I'm doing wrong with PHPDocumentor ;)

Thx
/Kung den Knege

yewboon
03-13-2003, 09:49 PM
I had the same problem as you last time, my solution is to create a simple script, as shown below, to generate the doc i want it to be. This idea is from JavaDoc.

Firstly, I created a script to format the doc layout i want it to be:
---------------------- mySysDoc.php -------------------------------
<?
function ShowFileInfo($FileName)
{
$timestamp = filemtime($FileName);
$LastMod = date("Y-m-d [H:i:s]", $timestamp);

print "<h2 style='font-family:arial;'>System Documentation</h2>";
print "<table border=0 cellspacing=0 cellpadding=0 width=600 style='font-size:12px; font-family:arial; background-color:#e9e9e9;'>";
print "<tr><td width=65><b>File Name</b>: </td>" .
" <td>$FileName</td>" .
" <td width=85><b>Last Modified</b>: </td>" .
" <td width=130>$LastMod</td></tr>" .
"</table><br>";
}


function ShowDoc($FileName)
{
ShowFileInfo($FileName);
$FilePointer = @file($FileName);
$Document = "<table border=0 cellspacing=0 cellpadding=0 width=600 style='font-size:12px; font-family:arial;'>";
for($a=0; $a<count($FilePointer); $a++)
{
if(trim($FilePointer[$a])=='/*@#')
{
$b = $a + 1;
while(trim($FilePointer[$b])!='#@*/')
{
$Line = trim($FilePointer[$b]);
if($Line=='@@@')
{ $Document .= "<tr valign='top'><td colspan=3><hr></td></tr>"; }
else if(substr($Line, 0, 1)=='@')
{
$Document .= "<tr valign='top'><td>" .
"<b><nobr>" . substr($Line, 1, strlen($Line)) . "</nobr></b>" .
"</td><td width=10>:</td><td>";
}
else if(substr($Line, 0, 1)!='@' && $Line!='')
{ $Document .= $Line; }
else if($Line=='')
{
$Document .= "</td></tr>" .
"<tr valign='top'><td colspan=3><br></td></tr>";
}
$b++;
}
$Document .= "<tr valign='top'><td colspan=3><br></td></tr>";
}
}
$Document .= "</table>";
print $Document;
}
?>
--------------------------------------------------------------------------

Next, I used this to comment my php code:
---------------------- search.php -------------------------------
<?
/*@#
@System
Online Shop Floor Control (OSFC)
@Module
Search / View
@Include
mynocache.inc, mylib.inc, myfunctions.inc
@Function
diff_date
@Developed by
Yew Boon

@Description
Display information about a particular S/Q No. in detail form and also process status.
#@*/


function diff_date($date1, $date2)
{
/*@#
@@@
@Function
diff_date($date1, $date2)
@Description
Compare two dates and return the different between them.
#@*/

... here your code ...
}
...
?>
___________________________________________

Finally, i added this to my system library list:
---------------------- SysLibrary.php ---------------------------
<?
include "mySysDoc.php3";
ShowDoc("search.phtml");
?>
---------------------------------------------------------------------

At the end, when i viewing my system library list i can get a well-formatted doc for the search.php script.

For your information; you can custom the mySysDoc.php to get the doc format you want as simple as 123.

Hope this will help you.