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', dirname(__DIR__));
20 define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public');
21 set_include_path(INSTALLDIR . DIRECTORY_SEPARATOR . 'extlib' . PATH_SEPARATOR . get_include_path());
23 $pattern = "*.php *.inc";
24 $exclude = 'config.php */extlib/* */local/* */plugins/* */scripts/*';
27 require_once INSTALLDIR . '/vendor/autoload.php';
28 $parser = new Console_Getopt();
29 $result = $parser->getopt($_SERVER['argv'], $shortoptions, $longoptions);
30 if (PEAR::isError($result)) {
31 print $result->getMessage() . "\n";
34 list($options, $args) = $result;
36 foreach ($options as $option) {
38 if ($arg == '--plugin') {
39 $plugin = $options[1];
40 } else if ($arg == 'h' || $arg == '--help') {
46 if (isset($args[0])) {
48 if (!is_dir($outdir)) {
49 echo "Output directory $outdir is not a directory.\n";
58 $exclude = "*/extlib/*";
59 $indir = INSTALLDIR . "/plugins/" . $plugin;
60 if (!is_dir($indir)) {
61 $indir = INSTALLDIR . "/plugins";
62 $filename = "{$plugin}Plugin.php";
63 if (!file_exists("$indir/$filename")) {
64 echo "Can't find plugin $plugin.\n";
76 // define('GNUSOCIAL_VERSION', '0.9.1');
77 $source = file_get_contents(INSTALLDIR . '/lib/common.php');
78 if (preg_match('/^\s*define\s*\(\s*[\'"]GNUSOCIAL_VERSION[\'"]\s*,\s*[\'"](.*)[\'"]\s*\)\s*;/m', $source, $matches)) {
85 $replacements = array(
86 '%%version%%' => getVersion(),
87 '%%indir%%' => $indir,
88 '%%pattern%%' => $pattern,
89 '%%outdir%%' => $outdir,
90 '%%htmlout%%' => $outdir,
91 '%%exclude%%' => $exclude,
94 var_dump($replacements);
96 $template = file_get_contents(dirname(__FILE__) . '/doxygen.tmpl');
97 $template = strtr($template, $replacements);
99 $templateFile = tempnam(sys_get_temp_dir(), 'statusnet-doxygen');
100 file_put_contents($templateFile, $template);
102 $cmd = "doxygen " . escapeshellarg($templateFile);
105 passthru($cmd, $retval);
109 unlink($templateFile);
112 echo "Failed! Doxygen config left in $templateFile\n";