branch off v1 as R_1_7
[m6w6/ext-http] / scripts / check_docs.php
1 #!/usr/bin/env php
2 <?php
3 // $Id$
4
5 function re($file, $re, &$m=NULL) {
6 global $doc;
7 return file_exists("$doc/$file") ? preg_match($re, file_get_contents("$doc/$file"), $m) : 0;
8 }
9 function fe($file) {
10 global $doc;
11 return file_exists("$doc/$file");
12 }
13 function fg($path, &$g=NULL) {
14 global $doc;
15 return count($g = glob("$doc/$path"));
16 }
17
18 $ext = "http";
19 $doc = "/home/mike/Development/src/php/phpdoc/en/trunk/reference/$ext";
20 $ref = new ReflectionExtension($ext);
21
22 printf("Undocumented INI options:\n");
23 foreach ($ref->getINIEntries() as $name => $tmp) {
24 re("configuration.xml", "#<entry>$name</entry>#") or printf("\t%s (%s)\n", $name, $tmp);
25 }
26 printf("\n");
27
28 printf("Undocumented stream filters:\n");
29 foreach (preg_grep("/^$ext\./", stream_get_filters()) as $filter) {
30 fe(sprintf("streamfilters/%s.xml", substr($filter, 5))) or printf("\t%s\n", $filter);
31 }
32 printf("\n");
33
34 printf("Undocumented constants:\n");
35 foreach ($ref->getConstants() as $name => $tmp) {
36 re("constants.xml", "#<constant>$name</constant>#") or printf("\t%s (%s)\n", $name, $tmp);
37 }
38 printf("\n");
39
40
41 printf("Undocumented functions:\n");
42 foreach ($ref->getFunctions() as $func) {
43 /* @var $func ReflectionFunction */
44 fg(sprintf("functions/*/%s.xml", strtr($func->getName(),'_','-'))) or printf("\t%s()\n", $func->getName());
45 }
46 printf("\n");
47
48 printf("Undocumented classes/members:\n");
49 foreach ($ref->getClasses() as $class) {
50 if (substr($class->getName(), -strlen("Exception")) === "Exception") continue;
51 /* @var $class ReflectionClass */
52 fg(sprintf("%s.xml", $class->getName())) or printf(" %s\n", $class->getName());
53 foreach ($class->getConstants() as $name => $tmp) {
54 re($class->getName().".xml", "#>$name<#") or printf("\t%s::%s (%s)\n", $class->getName(), $name, $tmp);
55 }
56 foreach ($class->getProperties() as $prop) {
57 /* @var $prop ReflectionProperty */
58 $prop->isPrivate() or re($class->getName().".xml", "#>{$prop->getName()}<#") or printf("\t%s::$%s\n", $class->getName(), $prop->getName());
59 }
60 foreach ($class->getMethods() as $meth) {
61 /* @var $meth ReflectionMethod */
62 try {
63 $meth->getPrototype();
64 } catch (Exception $ex) {
65 // if getPrototype throws an exception it's definitely not a method declared in an interface
66 $meth->isPrivate() or fg(sprintf("%s/%s.xml", $class->getName(), strtr(trim($meth->getName(),'_'),'_','-'))) or printf("\t%s%s::%s()\n", $meth->isStatic()?'static ':'', $class->getName(), $meth->getName());
67 }
68
69 }
70 printf("\n");
71 }
72 printf("\n");
73
74 printf("Undocumented request options:\n");
75 if (is_file($file = dirname(__FILE__)."/../http_request_api.c")) {
76 if (preg_match_all("#(?:http_request_option\(request,\s*options,\s*\")(\w+)(?=\")#", file_get_contents($file), $match)) {
77 foreach ($match[1] as $opt) {
78 re("request-options.xml", "#<term>\s*$opt#") or printf("\t%s\n", $opt);
79 }
80 printf("\n");
81 printf("List of request option entities:\n");
82 foreach ($match[1] as $opt) {
83 printf("\t<!ENTITY link.http.request.option.%1\$s '<link linkend=\"http.request.option.%1\$s\"><literal>%1\$s</literal> request option</link>'>\n", $opt);
84 }
85 }
86 } else {
87 printf("\thttp_request_api.c not found\n");
88 }
89 printf("\n");
90
91 ?>