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 require_once INSTALLDIR.'/scripts/commandline.inc';
22 $pattern = "*.php *.inc";
23 $exclude = 'config.php */extlib/* */local/* */plugins/* */scripts/*';
25 if (isset($args[0])) {
27 if (!is_dir($outdir)) {
28 echo "Output directory $outdir is not a directory.\n";
36 if (have_option('p', 'plugin')) {
37 $plugin = get_option_value('plugin');
38 $exclude = "*/extlib/*";
39 $indir = INSTALLDIR . "/plugins/" . $plugin;
40 if (!is_dir($indir)) {
41 $indir = INSTALLDIR . "/plugins";
42 $filename = "{$plugin}Plugin.php";
43 if (!file_exists("$indir/$filename")) {
44 echo "Can't find plugin $plugin.\n";
54 $replacements = array(
55 '%%version%%' => STATUSNET_VERSION,
56 '%%indir%%' => $indir,
57 '%%pattern%%' => $pattern,
58 '%%outdir%%' => $outdir,
59 '%%htmlout%%' => $outdir,
60 '%%exclude%%' => $exclude,
63 var_dump($replacements);
65 $template = file_get_contents(dirname(__FILE__) . '/doxygen.tmpl');
66 $template = strtr($template, $replacements);
68 $templateFile = tempnam(sys_get_temp_dir(), 'statusnet-doxygen');
69 file_put_contents($templateFile, $template);
71 $cmd = "doxygen " . escapeshellarg($templateFile);
74 passthru($cmd, $retval);
78 unlink($templateFile);
81 echo "Failed! Doxygen config left in $templateFile\n";