%s\n", highlight_string($m[1], true)); } function mf($f, &$m) { return preg_match_all( '/\/\* *\{\{\{ *proto (.*?)(\n|$)(.*?)PHP_(?:FUNCTION|METHOD)\((.*?)\)/s', file_get_contents($f), $m); } function ff($t) { $t = preg_replace('/^ \* /m', '', trim($t, "*/ \n")); $t = preg_replace_callback('/(\<\?php.*?\?\>)/s', 'hl', $t); $t = nl2br(preg_replace('/\n *\* */', "\n", $t)); $t = preg_replace('/(\
\n)+\(\
\n)+/', '

', $t);
    $t = preg_replace('/(\
\n)+\<\/pre\>(\
\n)+/', '

', $t); return sprintf('

%s

', ltrim($t, ' *')); } function e($s) { $a = func_get_args(); array_unshift($a, STDERR); call_user_func_array('fprintf', $a); } $preface = <<<_PREFACE Function Summary of ext/%s _PREFACE; $footer = <<<_FOOTER

Generated at: %s

_FOOTER; if ($_SERVER['argc'] < 2) { die("Usage: {$_SERVER['argv'][0]} [ ...]\n"); } printf($preface, basename(getcwd())); foreach (array_slice($_SERVER['argv'], 1) as $fp) { foreach (glob($fp) as $f) { if (mf($f, $m)) { e("\nAnalyzing %s\n", basename($f)); printf("

%s

\n", basename($f)); foreach ($m[1] as $i => $p) { e("Documenting $p\n"); if ($o = preg_match('/^(.*), (.*)$/', $m[4][$i], $n)) { if ($n[2] == '__construct') { printf("

%s

\n", $n[1], $n[1]); } } printf("%s\n%s\n", $o?3:2, $o?$n[1].'_'.$n[2]:$m[4][$i], $p, $o?3:2, ff($m[3][$i])); } print "
\n"; } } } printf($footer, date('r')); e("\nDone\n"); ?>