5 return sprintf("<blockquote>%s</blockquote>\n", highlight_string($m[1], true));
10 '/\/\* *\{\{\{ *proto (.*?)(\n|$)(.*?)PHP_(?:FUNCTION|METHOD)\((.*?)\)/s',
11 file_get_contents($f), $m);
15 $t = preg_replace('/^ \* /m', '', trim($t, "*/ \n"));
16 $t = preg_replace_callback('/(\<\?php.*?\?\>)/s', 'hl', $t);
17 $t = str_replace("<br />\n<br />\n", "</p>\n<p>", nl2br(preg_replace('/\n *\* */', "\n", $t)));
18 $t = preg_replace('/(\<br \/\>\n)+\<pre\>(\<br \/\>\n)+/', '</p><pre>', $t);
19 $t = preg_replace('/(\<br \/\>\n)+\<\/pre\>(\<br \/\>\n)+/', '</pre><p>', $t);
20 $t = str_replace("</span><br />\n</code>", "</span></code>", $t);
21 return sprintf('<p>%s</p>', ltrim($t, ' *'));
26 array_unshift($a, STDERR
);
27 call_user_func_array('fprintf', $a);
30 $preface = <<<_PREFACE
33 <title>Function Summary of ext/%s</title>
37 font-family: sans-serif;
64 border: 1px solid #ccc;
102 <p><b>Generated at: %s</b></p>
108 if ($_SERVER['argc'] < 2) {
109 die("Usage: {$_SERVER['argv'][0]} <file>[ <file> ...]\n");
114 printf($preface, basename(getcwd()));
116 foreach (array_slice($_SERVER['argv'], 1) as $fp) {
117 foreach (glob($fp) as $f) {
120 e("\nAnalyzing %s\n", basename($f));
121 printf("<h1 id=\"%s\">%s</h1>\n", basename($f), basename($f));
122 foreach ($m[1] as $i => $p) {
123 e("Documenting $p\n");
124 if ($o = preg_match('/^(.*), (.*)$/', $m[4][$i], $n)) {
125 if ($n[2] == '__construct') {
126 printf("<h2 id=\"%s\" class=\"o\">%s</h2>\n", $n[1], $n[1]);
128 $TOC[basename($f)][$n[1]][$n[2]] = $n[1].'::'.$n[2].'()';
129 printf("<h%d id=\"%s\">%s</h%d>\n", 3, $n[1].'_'.$n[2], $p, 3);
131 $TOC[basename($f)][$m[4][$i]] = $m[4][$i].'()';
132 printf("<h%d id=\"%s\">%s</h%d>\n", 2, $m[4][$i], $p, 2);
134 print ff($m[3][$i]) ."\n";
136 print "<hr noshade>\n";
140 printf("<div class=\"toc\"><strong>Table of Contents</strong>\n<ul>\n");
141 foreach ($TOC as $file => $f) {
142 printf("<li><a href=\"#%s\">%s\n<ul>\n", $file, $file);
143 foreach ($f as $cof => $met) {
144 if (is_array($met)) {
145 foreach ($met as $id => $m) {
146 printf("<li><a href=\"#%s_%s\">%s</a></li>\n", $cof, $id, $m);
149 printf("<li><a href=\"#%s\">%s</a>\n", $cof, $cof);
153 printf("</ul>\n</li>\n");
155 printf("</ul>\n</div>\n");
157 printf($footer, date('r'));