- ditch redundant http_split_response
[m6w6/ext-http] / funcsummary.php
1 <?php
2
3 function hl($m)
4 {
5 return sprintf("<blockquote>%s</blockquote>\n", highlight_string($m[1], true));
6 }
7 function mf($f, &$m)
8 {
9 return preg_match_all(
10 '/\/\* *\{\{\{ *proto (.*?)(\n|$)(.*?)PHP_(?:FUNCTION|METHOD)\((.*?)\)/s',
11 file_get_contents($f), $m);
12 }
13 function ff($t)
14 {
15 $t = preg_replace('/^ \* /m', '', trim($t, "*/ \n"));
16 $t = preg_replace_callback('/(\<\?php.*?\?\>)/s', 'hl', $t);
17 $t = 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 return sprintf('<p>%s</p>', ltrim($t, ' *'));
21 }
22
23 $preface = <<<_PREFACE
24 <html>
25 <head>
26 <title>Function Summary of ext/%s</title>
27 <style>
28 body {
29 font-size: 80%%;
30 font-family: sans-serif;
31 }
32 h2, h3 {
33 color: #339;
34 clear: both;
35 font-size: 1.2em;
36 background: #ffc;
37 padding: .2em;
38 }
39 h2.o {
40 color: #66b;
41 clear: both;
42 font-size: 1.3em;
43 background: #f0f0f0;
44 padding: .2em;
45 }
46 p {
47 margin-left: 1em;
48 }
49 pre {
50 font-size: 1.2em;
51 }
52 br {
53 display: none;
54 }
55 blockquote {
56 margin-bottom: 3em;
57 border: 1px solid #ccc;
58 background: #f0f0f0;
59 padding: 0em 1em;
60 width: auto;
61 float: left;
62 }
63 p, pre {
64 clear: both;
65 }
66 p br, pre code br {
67 display: block;
68 }
69 </style>
70 </head>
71 <body>
72 _PREFACE;
73
74 $footer = <<<_FOOTER
75 <p><b>Generated at: %s</b></p>
76 </body>
77 </html>
78
79 _FOOTER;
80
81 if ($_SERVER['argc'] < 2) {
82 die("Usage: {$_SERVER['argv'][0]} <file>[ <file> ...]\n");
83 }
84
85 printf($preface, basename(getcwd()));
86
87 foreach (array_slice($_SERVER['argv'], 1) as $f) {
88 if (mf($f, $m)) {
89 printf("<h1>%s</h1>\n", basename($f));
90 foreach ($m[1] as $i => $p) {
91 if ($o = preg_match('/^(.*), (.*)$/', $m[4][$i], $n)) {
92 if ($n[2] == '__construct') {
93 printf("<h2 id=\"%s\" class=\"o\">%s</h2>\n", $n[1], $n[1]);
94 }
95 }
96 printf("<h%d id=\"%s\">%s</h%d>\n%s\n",
97 $o?3:2, $o?$n[1].'_'.$n[2]:$m[4][$i], $p, $o?3:2, ff($m[3][$i]));
98 }
99 print "<hr noshade>\n";
100 }
101 }
102
103 printf($footer, date('r'));
104 ?>
105