cvs: docweb /cron/weekly meta_info /include docweb_dao_common.class.php docweb_dao_metainfo.class.php /scripts gen_function_aliases.php gen_missing_examples.php gen_undocumented_functions.php
[email protected] ("Sean Coates")
| Newsgroups | php.doc.web |
|---|---|
| Message-ID | <cvssean1107752646@cvsserver> |
sean Mon Feb 7 00:04:06 2005 EDT
Added files:
/docweb/scripts gen_missing_examples.php
gen_undocumented_functions.php
Modified files:
/docweb/cron/weekly meta_info
/docweb/include docweb_dao_common.class.php
docweb_dao_metainfo.class.php
/docweb/scripts gen_function_aliases.php
Log:
more meta-info (erigol) scripts
sean-20050207000406.txt
(text/plain, 15.5 KB)
http://cvs.php.net/diff.php/docweb/cron/weekly/meta_info?r1=1.1&r2=1.2&ty=u
Index: docweb/cron/weekly/meta_info
diff -u docweb/cron/weekly/meta_info:1.1 docweb/cron/weekly/meta_info:1.2
--- docweb/cron/weekly/meta_info:1.1 Sun Feb 6 19:38:20 2005
+++ docweb/cron/weekly/meta_info Mon Feb 7 00:04:04 2005
@@ -4,3 +4,5 @@
cd ${SCRIPTSDIR}
${PHP} gen_function_aliases.php
+${PHP} gen_missing_examples.php
+${PHP} gen_undocumented_functions.php
http://cvs.php.net/diff.php/docweb/include/docweb_dao_common.class.php?r1=1.1&r2=1.2&ty=u
Index: docweb/include/docweb_dao_common.class.php
diff -u docweb/include/docweb_dao_common.class.php:1.1 docweb/include/docweb_dao_common.class.php:1.2
--- docweb/include/docweb_dao_common.class.php:1.1 Sun Feb 6 19:37:35 2005
+++ docweb/include/docweb_dao_common.class.php Mon Feb 7 00:04:06 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
| Author: Sean Coates <[email protected]> |
+----------------------------------------------------------------------+
-$Id: docweb_dao_common.class.php,v 1.1 2005/02/07 00:37:35 sean Exp $
+$Id: docweb_dao_common.class.php,v 1.2 2005/02/07 05:04:06 sean Exp $
*/
define('DOCWEB_DAO_DB_FILE', SQLITE_DIR . 'docweb.sqlite');
@@ -172,6 +172,40 @@
}
}
+ // missing_examples
+ if (!$this->tableExists('missing_examples')) {
+ $sql = "
+ CREATE
+ TABLE
+ missing_examples
+ (
+ extension VARCHAR(100),
+ function VARCHAR(100)
+ )
+ ";
+ if (PEAR::isError($create = $this->DB->query($sql)))
+ {
+ die("Query Error: ". $create->getMessage() ."\n");
+ }
+ }
+
+ // undocumented_functions
+ if (!$this->tableExists('undocumented_functions')) {
+ $sql = "
+ CREATE
+ TABLE
+ undocumented_functions
+ (
+ extension VARCHAR(100),
+ function VARCHAR(100)
+ )
+ ";
+ if (PEAR::isError($create = $this->DB->query($sql)))
+ {
+ die("Query Error: ". $create->getMessage() ."\n");
+ }
+ }
+
// all complete
return TRUE;
}
http://cvs.php.net/diff.php/docweb/include/docweb_dao_metainfo.class.php?r1=1.1&r2=1.2&ty=u
Index: docweb/include/docweb_dao_metainfo.class.php
diff -u docweb/include/docweb_dao_metainfo.class.php:1.1 docweb/include/docweb_dao_metainfo.class.php:1.2
--- docweb/include/docweb_dao_metainfo.class.php:1.1 Sun Feb 6 19:38:20 2005
+++ docweb/include/docweb_dao_metainfo.class.php Mon Feb 7 00:04:06 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
| Author: Sean Coates <[email protected]> |
+----------------------------------------------------------------------+
-$Id: docweb_dao_metainfo.class.php,v 1.1 2005/02/07 00:38:20 sean Exp $
+$Id: docweb_dao_metainfo.class.php,v 1.2 2005/02/07 05:04:06 sean Exp $
*/
require_once 'docweb_dao_common.class.php';
@@ -66,6 +66,9 @@
return TRUE;
}
+ /**
+ * Purges function_aliases table
+ */
function purgeAliases()
{
$sql = "
@@ -79,5 +82,123 @@
}
return TRUE;
}
+
+ /**
+ * Determines if the passed function name is an alias
+ *
+ * @param string $func
+ * @return bool
+ */
+ function isAlias($func)
+ {
+ $sql = "
+ SELECT
+ COUNT(function)
+ FROM
+ function_aliases
+ WHERE
+ alias = '". $this->DB->escapeSimple($func) ."'
+ ";
+ if (PEAR::isError($match = $this->DB->getOne($sql))) {
+ echo " ** Query failed.\n";
+ return FALSE;
+ }
+ return $match ? TRUE : FALSE;
+ }
+
+ /**
+ * Purges missing_examples table
+ */
+ function purgeExamples()
+ {
+ $sql = "
+ DELETE
+ FROM
+ missing_examples
+ ";
+ if (PEAR::isError($this->DB->query($sql))) {
+ echo " ** Purge Query failed.\n";
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Store missing example data
+ *
+ * @param string $ext Extension to which this function belongs
+ * @param string $func Function name
+ * @return bool
+ */
+ function storeMissingExample($ext, $func)
+ {
+ $sql = "
+ INSERT
+ INTO
+ missing_examples
+ (
+ extension,
+ function
+ )
+ VALUES
+ (
+ '". $this->DB->escapeSimple($ext) ."',
+ '". $this->DB->escapeSimple($func) ."'
+ )
+ ";
+ if (PEAR::isError($this->DB->query($sql))) {
+ echo " ** Query failed.\n";
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Purges undocumented_functions table
+ */
+ function purgeUndocumented()
+ {
+ $sql = "
+ DELETE
+ FROM
+ undocumented_functions
+ ";
+ if (PEAR::isError($this->DB->query($sql))) {
+ echo " ** Purge Query failed.\n";
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Store missing example data
+ *
+ * @param string $ext Extension to which this function belongs
+ * @param string $func Function name
+ * @return bool
+ */
+ function storeUndocumentedFunction($ext, $func)
+ {
+ $sql = "
+ INSERT
+ INTO
+ undocumented_functions
+ (
+ extension,
+ function
+ )
+ VALUES
+ (
+ '". $this->DB->escapeSimple($ext) ."',
+ '". $this->DB->escapeSimple($func) ."'
+ )
+ ";
+ if (PEAR::isError($this->DB->query($sql))) {
+ echo " ** Query failed.\n";
+ return FALSE;
+ }
+ return TRUE;
+ }
+
}
?>
\ No newline at end of file
http://cvs.php.net/diff.php/docweb/scripts/gen_function_aliases.php?r1=1.1&r2=1.2&ty=u
Index: docweb/scripts/gen_function_aliases.php
diff -u docweb/scripts/gen_function_aliases.php:1.1 docweb/scripts/gen_function_aliases.php:1.2
--- docweb/scripts/gen_function_aliases.php:1.1 Sun Feb 6 19:38:20 2005
+++ docweb/scripts/gen_function_aliases.php Mon Feb 7 00:04:06 2005
@@ -17,7 +17,7 @@
| Author: Dave Barr <[email protected]> |
| DocWeb Port: Sean Coates <[email protected]> |
+----------------------------------------------------------------------+
-$Id: gen_function_aliases.php,v 1.1 2005/02/07 00:38:20 sean Exp $
+$Id: gen_function_aliases.php,v 1.2 2005/02/07 05:04:06 sean Exp $
*/
set_time_limit(0);
@@ -27,8 +27,13 @@
require_once '../include/lib_meta_info.inc.php';
require_once '../include/docweb_dao_metainfo.class.php';
+echo "Generating Function Aliases data...\n";
+
$DAO = new DocWeb_DAO_MetaInfo(TRUE);
+$DAO->metaLogStartTime('aliases');
+$DAO->purgeAliases();
+
// Special places to look for aliases */
$special = array(
'info' => 'ZendEngine2/zend_builtin_functions.c',
@@ -80,10 +85,6 @@
ksort($aliases, SORT_STRING);
-$DAO->metaLogStartTime('aliases');
-
-$DAO->purgeAliases();
-
foreach ($aliases AS $ext => $aliasData) {
foreach ($aliasData AS $alias => $func) {
echo "[$ext] $alias -> $func\n";
http://cvs.php.net/co.php/docweb/scripts/gen_missing_examples.php?r=1.1&p=1
Index: docweb/scripts/gen_missing_examples.php
+++ docweb/scripts/gen_missing_examples.php
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
+----------------------------------------------------------------------+
| PHP Documentation Site Source Code |
+----------------------------------------------------------------------+
| Copyright (c) 2005 The PHP Group |
| Copyright (c) 1997-2004 Dave Barr |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_0.txt. |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| [email protected] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Dave Barr <[email protected]> |
| DocWeb Port: Sean Coates <[email protected]> |
+----------------------------------------------------------------------+
$Id: gen_missing_examples.php,v 1.1 2005/02/07 05:04:06 sean Exp $
*/
set_time_limit(0);
$scriptBegin = time();
$inCli = true;
require_once '../include/init.inc.php';
require_once '../include/lib_meta_info.inc.php';
require_once '../include/docweb_dao_metainfo.class.php';
echo "Generating Missing Examples data...\n";
$DAO = new DocWeb_DAO_MetaInfo(TRUE);
$reference = CVS_DIR . '/phpdoc-all/en/reference';
$excludefuncs = array(
'overload' => 'The example is in the introductory section',
'mysql-db-query' => 'Deprecated function',
'mysql-change-user' => 'PHP 3',
);
$exts = array();
$dir = opendir($reference);
while ($entry = readdir($dir)) {
if ($entry == "." || $entry == "..") {
continue;
}
// entry is a directory, and has a valid functions sub-directory
if (is_dir("$reference/$entry") && is_dir("$reference/$entry/functions")) {
$exts[] = $entry;
}
}
closedir($dir);
sort($exts, SORT_STRING);
$extfuncs = array();
$functotal = 0;
foreach ($exts as $ext) {
$extfuncs[$ext] = array();
$funcdir = "$reference/$ext/functions";
$dir = opendir($funcdir);
while ($entry = readdir($dir)) {
$function = substr($entry, 0, -4);
// found a file in the functions directory, and it's an .xml file
if (
is_file("$funcdir/$entry") &&
substr($entry, -4) == ".xml" &&
strstr(substr($entry, 0, -4), ".") === false &&
!isset($excludefuncs[$function])
) {
$file = file_get_contents("$funcdir/$entry");
$ufunction = str_replace('-', '_', $function);
$alias = $DAO->isAlias($ufunction);
if (
strstr($file, "<example") === false &&
strstr($file, "<informalexample") === false
) {
// this function doesn't have an example
// check if this function is an alias
if (!$alias) {
$extfuncs[$ext][] = $ufunction;
}
}
if (!$alias) {
$functotal++;
}
}
}
sort($extfuncs[$ext], SORT_STRING);
closedir($dir);
}
$notmissing = array();
$extcount = 0;
$total = 0;
foreach ($extfuncs as $name => $ext) {
$exttotal = count($ext);
if ($exttotal == 0) {
$notmissing[] = $name;
}
else {
$extcount++;
$total += $exttotal;
}
}
$DAO->purgeExamples();
foreach (array_diff($extfuncs, $notmissing) AS $ext => $extData) {
foreach ($extData AS $func) {
echo "[$ext] $func\n";
$DAO->storeMissingExample($ext, $func);
}
}
echo "** Done.\n";
?>
http://cvs.php.net/co.php/docweb/scripts/gen_undocumented_functions.php?r=1.1&p=1
Index: docweb/scripts/gen_undocumented_functions.php
+++ docweb/scripts/gen_undocumented_functions.php
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
+----------------------------------------------------------------------+
| PHP Documentation Site Source Code |
+----------------------------------------------------------------------+
| Copyright (c) 2005 The PHP Group |
| Copyright (c) 1997-2004 Dave Barr |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_0.txt. |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| [email protected] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Dave Barr <[email protected]> |
| DocWeb Port: Sean Coates <[email protected]> |
+----------------------------------------------------------------------+
$Id: gen_undocumented_functions.php,v 1.1 2005/02/07 05:04:06 sean Exp $
*/
set_time_limit(0);
$scriptBegin = time();
$inCli = true;
require_once '../include/init.inc.php';
require_once '../include/lib_meta_info.inc.php';
require_once '../include/docweb_dao_metainfo.class.php';
echo "Generating Missing Examples data...\n";
$DAO = new DocWeb_DAO_MetaInfo(TRUE);
$reference = CVS_DIR . "/phpdoc-all/en/reference";
$exts = array();
$dir = opendir($reference);
while ($entry = readdir($dir)) {
if ($entry == "." || $entry == "..")
continue;
// entry is a directory, and has a valid functions sub-directory
if (is_dir("$reference/$entry") && is_dir("$reference/$entry/functions")) {
$exts[] = $entry;
}
}
closedir($dir);
sort($exts, SORT_STRING);
$extfuncs = array();
foreach ($exts as $ext) {
$extfuncs[$ext] = array();
$funcdir = "$reference/$ext/functions";
$dir = opendir($funcdir);
while ($entry = readdir($dir)) {
// found a file in the functions directory, and it's an .xml file
if (
is_file("$funcdir/$entry") &&
substr($entry, -4) == ".xml" &&
strstr(substr($entry, 0, -4), ".") === false
) {
$file = file_get_contents("$funcdir/$entry");
if (strstr($file, "&warn.undocumented.func;") !== false) {
// this function isn't documented
$function = str_replace('-', '_', substr($entry, 0, -4));
// check if this function is an alias
if (!$DAO->isAlias($function)) {
$extfuncs[$ext][$function] = true;
}
}
}
}
asort($extfuncs[$ext], SORT_STRING);
closedir($dir);
}
$notmissing = array();
$extcount = 0;
$total = 0;
foreach ($extfuncs as $name => $ext) {
$exttotal = count($ext);
if ($exttotal == 0) {
$notmissing[] = $name;
}
else {
$extcount++;
$total += $exttotal;
}
}
$DAO->purgeUndocumented();
foreach (array_diff($extfuncs, $notmissing) AS $ext => $extData) {
foreach ($extData AS $func => $junk) {
echo "[$ext] $func\n";
$DAO->storeUndocumentedFunction($ext, $func);
}
}
echo "** Done.\n";
?>