Bump API version for new plugin entry points (oops)
[geany-mirror.git] / scripts / create_php_tags.php
blobbecea27d8d45f1d44bb16f33ea46e2f642e039c4
1 #!/usr/bin/php
2 <?php
3 // Author: Matti MÃ¥rds
4 // License: GPL V2 or later
5 //
6 // Script to generate a new php.tags file from a downloaded PHP function summary list from
7 //
8 // http://svn.php.net/repository/phpdoc/doc-base/trunk/funcsummary.txt
9 //
10 // - The script can be run from any directory
11 // - The script downloads the file funcsummary.txt using PHP's stdlib
13 # (from tagmanager/tm_tag.c:32)
14 define("TA_NAME", 200);
15 define("TA_TYPE", 204);
16 define("TA_ARGLIST", 205);
17 define("TA_VARTYPE", 207);
19 # TMTagType (tagmanager/tm_tag.h:47)
20 define("TYPE_FUNCTION", 128);
22 // Create an array of the lines in the file
23 $url = 'http://svn.php.net/repository/phpdoc/doc-base/trunk/funcsummary.txt';
24 $file = file($url, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
26 // Create template for a tag (tagmanager format)
27 $tagTpl = "%s%c%d%c%s%c%s";
29 // String to store the output
30 $tagsOutput = array();
32 // String data base path for tags.php
33 $filePhpTags = implode( DIRECTORY_SEPARATOR,
34 array(
35 dirname(dirname(__FILE__)),
36 'data',
37 'php.tags'
38 ));
39 // Iterate through each line of the file
40 for($line = 0, $lineCount = count($file); $line < $lineCount; ++$line) {
42 // If the line isn't a function definition, skip it
43 if(!preg_match('/^(?P<retType>\w+) (?P<funcName>[\w:]+)(?P<params>\(.*?\))/', $file[$line], $funcDefMatch)) {
44 continue;
46 // Skip methods as they aren't used for now
47 if (strpos($funcDefMatch['funcName'], '::') !== false) {
48 continue;
51 // Get the function description
52 //$funcDesc = trim($file[$line + 1]);
53 // Geany doesn't use the function description (yet?), so use an empty string to save space
54 $funcDesc = '';
56 // Remove the void parameter, it will only confuse some people
57 if($funcDefMatch['params'] === '(void)') {
58 $funcDefMatch['params'] = '()';
61 // $funcDefMatch['funcName'] = str_replace('::', '->', $funcDefMatch['funcName']);
62 $tagsOutput[] = sprintf($tagTpl, $funcDefMatch['funcName'], TA_TYPE, TYPE_FUNCTION,
63 TA_ARGLIST, $funcDefMatch['params'], TA_VARTYPE, $funcDefMatch['retType']);
66 $tagsOutput[] = sprintf(
67 '# format=tagmanager - Automatically generated file - do not edit (created on %s)',
68 date('r'));
69 // Sort the output
70 sort($tagsOutput);
72 file_put_contents($filePhpTags, join("\n", $tagsOutput));
73 echo "Created:\n${filePhpTags}\n";
74 echo str_repeat('-',75)."\n";