6 return sprintf("<blockquote>%s</blockquote>\n", highlight_string($m[1], true));
10 return preg_match_all(
11 '/\/\* *\{\{\{ *proto (.*?)(\n|$)(.*?)PHP_(?:FUNCTION|METHOD)\((.*?)\)/s',
12 file_get_contents($f), $m);
16 $t = preg_replace('/^ \* /m', '', trim($t, "*/ \n"));
17 $t = preg_replace_callback('/(\<\?php.*?\?\>)/s', 'hl', $t);
18 $t = str_replace("<br />\n<br />\n", "</p>\n<p>", nl2br(preg_replace('/\n *\* */', "\n", $t)));
19 $t = preg_replace('/(\<br \/\>\n)+\<pre\>(\<br \/\>\n)+/', '</p><pre>', $t);
20 $t = preg_replace('/(\<br \/\>\n)+\<\/pre\>(\<br \/\>\n)+/', '</pre><p>', $t);
21 $t = str_replace("</span><br />\n</code>", "</span></code>", $t);
22 return sprintf('<p>%s</p>', ltrim($t, ' *'));
27 array_unshift($a, STDERR
);
28 call_user_func_array('fprintf', $a);
31 $preface = <<<_PREFACE
34 <title>Function Summary of ext/%s</title>
38 font-family: sans-serif;
65 border: 1px solid #ccc;
106 <p><b>Generated at: %s</b></p>
112 if ($_SERVER['argc'] < 2) {
113 die("Usage: {$_SERVER['argv'][0]} <file>[ <file> ...]\n");
118 printf($preface, basename(getcwd()));
121 foreach (array_slice($_SERVER['argv'], 1) as $fp) {
122 foreach (glob($fp) as $f) {
123 if (isset($seen[$f])) {
130 e("\nAnalyzing %s\n", basename($f));
131 printf("<h1 id=\"%s\">%s</h1>\n", basename($f), basename($f));
132 foreach ($m[1] as $i => $p) {
133 e("Documenting $p\n");
134 if ($o = preg_match('/^(.*), (.*)$/', $m[4][$i], $n)) {
137 printf("<h2 id=\"%s\" class=\"o\">%s</h2>\n", $n[1], $n[1]);
139 $TOC[basename($f)][$n[1]][$n[2]] = $n[1].'::'.$n[2].'()';
140 printf("<h%d id=\"%s\">%s</h%d>\n", 3, $n[1].'_'.$n[2], $p, 3);
142 $TOC[basename($f)][$m[4][$i]] = $m[4][$i].'()';
143 printf("<h%d id=\"%s\">%s</h%d>\n", 2, $m[4][$i], $p, 2);
145 print ff($m[3][$i]) ."\n";
147 print "<hr noshade>\n";
151 printf("<div class=\"toc\"><strong>Table of Contents</strong>\n<ul>\n");
152 foreach ($TOC as $file => $f) {
153 printf("<li><a class=\"tocfile\" href=\"#%s\">%s</a>\n<ul>\n", $file, $file);
154 foreach ($f as $cof => $met) {
155 if (is_array($met)) {
156 foreach ($met as $id => $m) {
157 printf("<li><a href=\"#%s_%s\">%s</a></li>\n", $cof, $id, $m);
160 printf("<li><a href=\"#%s\">%s</a>\n", $cof, $cof);
164 printf("</ul>\n</li>\n");
166 printf("</ul>\n</div>\n");
168 printf($footer, date('r'));