From e7ea23b18025f41d21095ab8983bd3097b4accfb Mon Sep 17 00:00:00 2001 From: Maurus Cuelenaere Date: Thu, 9 Oct 2008 11:48:26 +0000 Subject: Improve plugin API documentation updater a bit git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18753 a1c6a512-1295-4272-9138-f99709370657 --- utils/rockbox_api/functions.php | 5 ++++- utils/rockbox_api/update.php | 44 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/utils/rockbox_api/functions.php b/utils/rockbox_api/functions.php index 57a7c99b13..d66caa1b29 100755 --- a/utils/rockbox_api/functions.php +++ b/utils/rockbox_api/functions.php @@ -13,7 +13,10 @@ function get_newest() { global $svn; - $text = file_get_contents("../../apps/plugin.h"); + $mypath = $_SERVER['SCRIPT_FILENAME']; + $mypath = substr($mypath, 0, strrpos($mypath, "/"))."/"; + + $text = file_get_contents($mypath."../../apps/plugin.h"); $text = str_replace(array("\r\n", "\r"), "\n", $text); diff --git a/utils/rockbox_api/update.php b/utils/rockbox_api/update.php index ef4a456d12..5fb46c9d58 100755 --- a/utils/rockbox_api/update.php +++ b/utils/rockbox_api/update.php @@ -6,6 +6,7 @@ $input = file_get_contents($argv[1]); $input = parse_documentation($input); +/* Format input */ foreach($input as $rootname => $rootel) { foreach($rootel as $name => $el) @@ -15,6 +16,7 @@ foreach($input as $rootname => $rootel) $new = get_newest(); +/* Format new */ foreach($new as $name => $el) { unset($new[$name]); @@ -43,8 +45,48 @@ foreach($new as $name => $el) $new[$name]["return"][0] = ""; } +/* Compare and merge both */ +$merged = array(); +foreach($new as $name => $el) +{ + if(isset($input[$name])) + { + $merged[$name] = $input[$name]; + $merged[$name]["conditions"] = $new[$name]["conditions"]; + + if(strlen($el["group"][0]) > 0) + $merged[$name]["group"] = $el["group"]; + + if(isset($el["param"])) + { + foreach($el["param"] as $nr => $parel) + { + if($parel != $input[$name]["param"][$nr]) + { + $param = trim($parel); + $p1 = substr($param, 0, strpos($param, " ")); + + $param = trim($input[$name]["param"][$nr]); + $p2 = substr($param, strpos($param, " ")); + $merged[$name]["params"][] = $p1." ".$p2." [AUTO-ADDED]"; + } + else + $merged[$name]["params"][] = $parel; + } + } + + if(!isset($el["return"]) && isset($merged[$name]["return"])) + unset($merged[$name]["return"]); + + unset($input[$name]); + } + else + $merged[$name] = $el; +} -$merged = array_merge($new, $input); +/* Now to the rest of input */ +foreach($input as $name => $el) + $merged[$name." [DEPRECATED]"] = $el; uksort($merged, "func_sort"); -- cgit v1.2.3