[Phpfreechat-svn] SF.net SVN: phpfreechat: [1166] trunk/misc/generate-doc-from-svn.php
Status: Beta
Brought to you by:
kerphi
|
From: <ke...@us...> - 2007-08-30 12:05:57
|
Revision: 1166
http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1166&view=rev
Author: kerphi
Date: 2007-08-30 05:05:55 -0700 (Thu, 30 Aug 2007)
Log Message:
-----------
Finalize the doc generator php script
Modified Paths:
--------------
trunk/misc/generate-doc-from-svn.php
Modified: trunk/misc/generate-doc-from-svn.php
===================================================================
--- trunk/misc/generate-doc-from-svn.php 2007-08-30 12:05:23 UTC (rev 1165)
+++ trunk/misc/generate-doc-from-svn.php 2007-08-30 12:05:55 UTC (rev 1166)
@@ -1,36 +1,80 @@
<?php
-echo '<pre>';
-$f = 'https://phpfreechat.svn.sourceforge.net/svnroot/phpfreechat/trunk/src/pfcglobalconfig.class.php';
-$data = file_get_contents($f);
+/**
+ * This script is used to parse the parameter descriptions in pfcglobalconfig.class.php
+ * So that the official doc is keept up to date.
+ */
+function pfc_generate_doc($f = NULL)
+{
+ $f = ($f != NULL) ? $f : dirname(__FILE__).'/../src/pfcglobalconfig.class.php';
-$offset = 0;
-preg_match('/class pfcGlobalConfig/',$data,$matches, PREG_OFFSET_CAPTURE, $offset);
-$offset = $matches[0][1];
+ $ct_params = array();
+// $ct_params['http'] = array( 'proxy' => 'tcp://proxyout.inist.fr:8080', 'request_fulluri' => true );
+ $ct = stream_context_create($ct_params);
+ $data = file_get_contents($f, false, $ct);
-if (preg_match('/\/\*\*/', $data, $matches1, PREG_OFFSET_CAPTURE, $offset))
-{
- // debut de commentaire
- $offset1 = $matches1[0][1];
- print_r($matches);
+ if (preg_match('/class pfcGlobalConfig/',$data,$matches, PREG_OFFSET_CAPTURE, $offset))
+ {
+ $offset_start = $matches[0][1];
+ }
+ if (preg_match('/function pfcGlobalConfig/', $data, $matches, PREG_OFFSET_CAPTURE, $offset))
+ {
+ $offset_end = $matches[0][1];
+ }
+
+ $offset = $offset_start;
+ $plist = array();
+ $continue = true;
+ while ($offset < $offset_end)
+ {
+ $p = array();
+
+ // search for the begining of the description
+ if (preg_match('/\/\*\*/', $data, $matches1, PREG_OFFSET_CAPTURE, $offset))
+ $offset1 = $matches1[0][1];
+ else
+ $offset = $offset_end;
+
+ // search for the end of the description
+ if ($offset1 < $offset_end &&
+ preg_match('/\*\//', $data, $matches3, PREG_OFFSET_CAPTURE, $offset))
+ {
+ $offset3 = $matches3[0][1];
+
+ // search for the parameter description
+ $p['desc'] = '';
+ while($offset2 < $offset3)
+ {
+ if (preg_match('/\s+\*\s+(.*)/', $data, $matches2, PREG_OFFSET_CAPTURE, $offset))
+ {
+ $offset2 = $matches2[1][1];
+ if ($offset2 < $offset3)
+ {
+ $offset = $offset2;
+ $p['desc'] .= ' '.$matches2[1][0];
+ }
+ }
+ else
+ break;
+ }
+ $p['desc'] = trim($p['desc']);
+
+ // search for the parameter name/default value
+ if (preg_match('/var\s+\$([a-z_]+)\s+=\s+(.*);/i', $data, $matches4, PREG_OFFSET_CAPTURE, $offset))
+ {
+ $offset = $matches4[1][1];
+ $p['name'] = $matches4[1][0];
+ $p['value'] = $matches4[2][0];
+ }
+ else
+ $offset = $offset_end;
+ }
+ else
+ $offset = $offset_end;
+
+ if (count($p) > 0) $plist[] = $p;
+ }
+ return $plist;
}
-if (preg_match('/\*\s(.*)/', $data, $matches2, PREG_OFFSET_CAPTURE, $offset))
-{
- // dans le commentaire
- $offset2 = $matches2[1][1];
- print_r($matches);
-}
-if (preg_match('/\*\//', $data, $matches3, PREG_OFFSET_CAPTURE, $offset))
-{
- // fin de commentaire
- $offset3 = $matches3[0][1];
- print_r($matches);
-}
-if (preg_match('/var\s+\$([a-z]+)\s+=\s+(.*);/i', $data, $matches4, PREG_OFFSET_CAPTURE, $offset))
-{
- // analyse du parametre
- $offset4 = $matches4[1][1];
- print_r($matches);
-}
?>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|