Update the create_php_tags.php script

* Uses more recent URL (as updated in other PR)
* Downloads the funcsummary.txt file by itself
* Support running the script from any directory

Closes #47
This commit is contained in:
Fitorec 2012-06-14 08:34:21 -05:00 committed by Matthew Brush
parent 05c9f10dd8
commit f934d2cf94

View File

@ -1,17 +1,14 @@
#!/usr/bin/php
<?php
// Author: Matti Mårds
// License: GPL V2 or later
//
// Script to generate a new php.tags file from a downloaded PHP function summary list from
// http://svn.php.net/viewvc/phpdoc/doc-base/trunk/funcsummary.txt?view=co
// The script expects a file funcsummary.txt in /tmp and will write the parsed tags into
// data/php.tags.
//
// wget -O funcsummary.txt "http://svn.php.net/viewvc/phpdoc/doc-base/trunk/funcsummary.txt?view=co"
// http://svn.php.net/repository/phpdoc/doc-base/trunk/funcsummary.txt
//
// (the script should be run in the top source directory)
// - The script can be run from any directory
// - The script downloads the file funcsummary.txt using PHP's stdlib
# (from tagmanager/tm_tag.c:32)
define("TA_NAME", 200);
@ -23,7 +20,8 @@ define("TA_VARTYPE", 207);
define("TYPE_FUNCTION", 128);
// Create an array of the lines in the file
$file = file('funcsummary.txt');
$url = 'http://svn.php.net/repository/phpdoc/doc-base/trunk/funcsummary.txt';
$file = file($url, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
// Create template for a tag (tagmanager format)
$tagTpl = "%s%c%d%c%s%c%s";
@ -31,6 +29,13 @@ $tagTpl = "%s%c%d%c%s%c%s";
// String to store the output
$tagsOutput = array();
// String data base path for tags.php
$filePhpTags = implode( DIRECTORY_SEPARATOR,
array(
dirname(dirname(__FILE__)),
'data',
'php.tags'
));
// Iterate through each line of the file
for($line = 0, $lineCount = count($file); $line < $lineCount; ++$line) {
@ -54,7 +59,6 @@ for($line = 0, $lineCount = count($file); $line < $lineCount; ++$line) {
}
// $funcDefMatch['funcName'] = str_replace('::', '->', $funcDefMatch['funcName']);
$tagsOutput[] = sprintf($tagTpl, $funcDefMatch['funcName'], TA_TYPE, TYPE_FUNCTION,
TA_ARGLIST, $funcDefMatch['params'], TA_VARTYPE, $funcDefMatch['retType']);
}
@ -65,6 +69,6 @@ $tagsOutput[] = sprintf(
// Sort the output
sort($tagsOutput);
file_put_contents('data/php.tags', join("\n", $tagsOutput));
?>
file_put_contents($filePhpTags, join("\n", $tagsOutput));
echo "Created:\n${filePhpTags}\n";
echo str_repeat('-',75)."\n";