6 require_once $_composer_autoload_path ?? __DIR__
."/../vendor/autoload.php";
9 fprintf(STDERR
, "Usage: %s <ns> <stub.php> [<destination>]\n", $argv[0]);
13 $namespace = $argv[1];
14 require_once $argv[2];
15 $destination = ($argc > 3) ?
$argv[3] : ".";
17 if (!is_dir($destination)) {
18 fprintf(STDERR
, "Missing $destination/; Making dir.");
19 mkdir($destination) ||
exit -1;
21 if (!file_exists("$destination/$namespace.mdref")) {
22 fprintf(STDERR
, "Missing $destination/$namespace.mdref; generated default.\n");
23 file_put_contents("$destination/$namespace.mdref", "./%s") ||
exit -2;
25 if (!file_exists("$destination/$namespace.md")) {
26 fprintf(STDERR
, "Missing $destination/$namespace.md; hard linking README.md\n");
27 link(dirname($argv[2]) . "/README.md", "$destination/$namespace.md") ||
exit -3;
30 $inspector = new Inspector
;
31 $inspector->inspectNamespace($namespace);
33 $generator = new Generator($destination);
34 $generator->generateFunctions($inspector->getFunctions());
35 $generator->generateClasses($inspector->getClasses());