5 $longoptions = array('plugin=');
8 $helptext = <<<ENDOFHELP
9 Build HTML documentation from doc comments in source.
11 Usage: docgen.php [options] output-directory
14 --plugin=... build docs for given plugin instead of core
19 define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
20 set_include_path(INSTALLDIR . DIRECTORY_SEPARATOR . 'extlib' . PATH_SEPARATOR . get_include_path());
22 $pattern = "*.php *.inc";
23 $exclude = 'config.php */extlib/* */local/* */plugins/* */scripts/*';
26 require_once 'Console/Getopt.php';
27 $parser = new Console_Getopt();
28 $result = $parser->getopt($_SERVER['argv'], $shortoptions, $longoptions);
29 if (PEAR::isError($result)) {
30 print $result->getMessage() . "\n";
33 list($options, $args) = $result;
35 foreach ($options as $option) {
37 if ($arg == '--plugin') {
38 $plugin = $options[1];
39 } else if ($arg == 'h' || $arg == '--help') {
45 if (isset($args[0])) {
47 if (!is_dir($outdir)) {
48 echo "Output directory $outdir is not a directory.\n";
57 $exclude = "*/extlib/*";
58 $indir = INSTALLDIR . "/plugins/" . $plugin;
59 if (!is_dir($indir)) {
60 $indir = INSTALLDIR . "/plugins";
61 $filename = "{$plugin}Plugin.php";
62 if (!file_exists("$indir/$filename")) {
63 echo "Can't find plugin $plugin.\n";
75 // define('STATUSNET_VERSION', '0.9.1');
76 $source = file_get_contents(INSTALLDIR . '/lib/common.php');
77 if (preg_match('/^\s*define\s*\(\s*[\'"]STATUSNET_VERSION[\'"]\s*,\s*[\'"](.*)[\'"]\s*\)\s*;/m', $source, $matches)) {
84 $replacements = array(
85 '%%version%%' => getVersion(),
86 '%%indir%%' => $indir,
87 '%%pattern%%' => $pattern,
88 '%%outdir%%' => $outdir,
89 '%%htmlout%%' => $outdir,
90 '%%exclude%%' => $exclude,
93 var_dump($replacements);
95 $template = file_get_contents(dirname(__FILE__) . '/doxygen.tmpl');
96 $template = strtr($template, $replacements);
98 $templateFile = tempnam(sys_get_temp_dir(), 'statusnet-doxygen');
99 file_put_contents($templateFile, $template);
101 $cmd = "doxygen " . escapeshellarg($templateFile);
104 passthru($cmd, $retval);
108 unlink($templateFile);
111 echo "Failed! Doxygen config left in $templateFile\n";