]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - scripts/docgen.php
Merge remote-tracking branch 'upstream/master' into social-master
[quix0rs-gnu-social.git] / scripts / docgen.php
index 78bbe37d8a41aa93ef7a245f2fb8ddffddba76fe..9ca4d9dad5271640ca3a9b3975823451d72bc1d0 100755 (executable)
@@ -17,10 +17,30 @@ Options:
 ENDOFHELP;
 
 define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
-require_once INSTALLDIR.'/scripts/commandline.inc';
+set_include_path(INSTALLDIR . DIRECTORY_SEPARATOR . 'extlib' . PATH_SEPARATOR . get_include_path());
 
 $pattern = "*.php *.inc";
 $exclude = 'config.php */extlib/* */local/* */plugins/* */scripts/*';
+$plugin = false;
+
+require_once 'Console/Getopt.php';
+$parser = new Console_Getopt();
+$result = $parser->getopt($_SERVER['argv'], $shortoptions, $longoptions);
+if (PEAR::isError($result)) {
+    print $result->getMessage() . "\n";
+    exit(1);
+}
+list($options, $args) = $result;
+
+foreach ($options as $option) {
+    $arg = $option[0];
+    if ($arg == '--plugin') {
+        $plugin = $options[1];
+    } else if ($arg == 'h' || $arg == '--help') {
+        print $helptext;
+        exit(0);
+    }
+}
 
 if (isset($args[0])) {
     $outdir = $args[0];
@@ -33,8 +53,7 @@ if (isset($args[0])) {
     exit(1);
 }
 
-if (have_option('p', 'plugin')) {
-    $plugin = get_option_value('plugin');
+if ($plugin) {
     $exclude = "*/extlib/*";
     $indir = INSTALLDIR . "/plugins/" . $plugin;
     if (!is_dir($indir)) {
@@ -51,8 +70,19 @@ if (have_option('p', 'plugin')) {
     $indir = INSTALLDIR;
 }
 
+function getVersion()
+{
+    // define('GNUSOCIAL_VERSION', '0.9.1');
+    $source = file_get_contents(INSTALLDIR . '/lib/common.php');
+    if (preg_match('/^\s*define\s*\(\s*[\'"]GNUSOCIAL_VERSION[\'"]\s*,\s*[\'"](.*)[\'"]\s*\)\s*;/m', $source, $matches)) {
+        return $matches[1];
+    }
+    return 'unknown';
+}
+
+
 $replacements = array(
-    '%%version%%' => STATUSNET_VERSION,
+    '%%version%%' => getVersion(),
     '%%indir%%' => $indir,
     '%%pattern%%' => $pattern,
     '%%outdir%%' => $outdir,
@@ -65,7 +95,7 @@ var_dump($replacements);
 $template = file_get_contents(dirname(__FILE__) . '/doxygen.tmpl');
 $template = strtr($template, $replacements);
 
-$templateFile = tempnam(sys_get_temp_dir(), 'statusnet-doxygen');
+$templateFile = tempnam(common_get_temp_dir(), 'statusnet-doxygen');
 file_put_contents($templateFile, $template);
 
 $cmd = "doxygen " . escapeshellarg($templateFile);