From 6a9f32f7d943bd619aaa94b9699d5e0fa5b57b8f Mon Sep 17 00:00:00 2001 From: SVN Migration Date: Sat, 5 Jul 2008 19:53:37 +0000 Subject: [PATCH 01/12] This commit was manufactured by cvs2svn to create branch 'RESTRUCTURE'. From c867e82cdebbdc724b1d3d0606262ac2d09533a2 Mon Sep 17 00:00:00 2001 From: Gwynne Raskind Date: Wed, 9 Jul 2008 11:32:54 +0000 Subject: [PATCH 02/12] fix spelling error --- config.php | 4 ++-- phpdotnet/phd/Config.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config.php b/config.php index 1fc01b7fc..9d6079e50 100644 --- a/config.php +++ b/config.php @@ -123,7 +123,7 @@ public function getopt() $opts = $this->getOptionList(); $args = getopt(implode("", array_values($opts)), array_keys($opts)); if ($args === false) { - trigger_error("Something happend with getopt(), please report a bug", E_USER_ERROR); + trigger_error("Something happened with getopt(), please report a bug", E_USER_ERROR); } foreach ($args as $k => $v) { @@ -132,7 +132,7 @@ public function getopt() call_user_func($handler, $k, $v); } else { var_dump($k, $v); - trigger_error("Hmh, something weird has happend, I don't know this option", E_USER_ERROR); + trigger_error("Hmh, something weird has happened, I don't know this option", E_USER_ERROR); } } } diff --git a/phpdotnet/phd/Config.php b/phpdotnet/phd/Config.php index 1fc01b7fc..9d6079e50 100644 --- a/phpdotnet/phd/Config.php +++ b/phpdotnet/phd/Config.php @@ -123,7 +123,7 @@ public function getopt() $opts = $this->getOptionList(); $args = getopt(implode("", array_values($opts)), array_keys($opts)); if ($args === false) { - trigger_error("Something happend with getopt(), please report a bug", E_USER_ERROR); + trigger_error("Something happened with getopt(), please report a bug", E_USER_ERROR); } foreach ($args as $k => $v) { @@ -132,7 +132,7 @@ public function getopt() call_user_func($handler, $k, $v); } else { var_dump($k, $v); - trigger_error("Hmh, something weird has happend, I don't know this option", E_USER_ERROR); + trigger_error("Hmh, something weird has happened, I don't know this option", E_USER_ERROR); } } } From 40bc17f9c570c634a04d6a981514c269c49a08c0 Mon Sep 17 00:00:00 2001 From: Gwynne Raskind Date: Wed, 9 Jul 2008 11:33:33 +0000 Subject: [PATCH 03/12] whitespace consistency --- config.php | 28 ++++++++++++++-------------- phpdotnet/phd/Config.php | 28 ++++++++++++++-------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/config.php b/config.php index 9d6079e50..a89e95cbf 100644 --- a/config.php +++ b/config.php @@ -85,22 +85,22 @@ function phd_bool($val) { } switch ($val) { - case "on": - case "yes": - case "true": - case "1": - return true; - break; + case "on": + case "yes": + case "true": + case "1": + return true; + break; - case "off": - case "no": - case "false": - case "0": - return false; - break; + case "off": + case "no": + case "false": + case "0": + return false; + break; - default: - return null; + default: + return null; } } /* }}} */ diff --git a/phpdotnet/phd/Config.php b/phpdotnet/phd/Config.php index 9d6079e50..a89e95cbf 100644 --- a/phpdotnet/phd/Config.php +++ b/phpdotnet/phd/Config.php @@ -85,22 +85,22 @@ function phd_bool($val) { } switch ($val) { - case "on": - case "yes": - case "true": - case "1": - return true; - break; + case "on": + case "yes": + case "true": + case "1": + return true; + break; - case "off": - case "no": - case "false": - case "0": - return false; - break; + case "off": + case "no": + case "false": + case "0": + return false; + break; - default: - return null; + default: + return null; } } /* }}} */ From df111fd180660a1e62a4d44cd2cb27c08bdf2d0f Mon Sep 17 00:00:00 2001 From: Gwynne Raskind Date: Wed, 9 Jul 2008 12:14:11 +0000 Subject: [PATCH 04/12] restructure. Fixes several spelling errors, removes pre-5.3 compatability, refactors options processing (again), removes vim cruft which prevents proper \?> syntax, fixed how config is included, use trigger_error() for config errors --- compile.php | 19 + config.php | 8 +- include/PhDCommonOptions.class.php | 117 +++++++ include/PhDCompileOptions.class.php | 32 ++ ...s.class.php => PhDRenderOptions.class.php} | 103 +----- phpdotnet/phd/BuildOptionsParser.php | 328 ------------------ phpdotnet/phd/Config.php | 8 +- build.php => render.php | 43 +-- 8 files changed, 192 insertions(+), 466 deletions(-) create mode 100644 compile.php create mode 100644 include/PhDCommonOptions.class.php create mode 100644 include/PhDCompileOptions.class.php rename include/{PhDBuildOptions.class.php => PhDRenderOptions.class.php} (68%) delete mode 100644 phpdotnet/phd/BuildOptionsParser.php rename build.php => render.php (89%) diff --git a/compile.php b/compile.php new file mode 100644 index 000000000..b7586034b --- /dev/null +++ b/compile.php @@ -0,0 +1,19 @@ +#!@php_bin@ + diff --git a/config.php b/config.php index a89e95cbf..046d5b4d2 100644 --- a/config.php +++ b/config.php @@ -138,14 +138,12 @@ public function getopt() } } -/* {{{ Can't function_call()['key'], so val(function_call(), 'key') */ +/* {{{ Can't function_call()['key'], so val(function_call(), 'key') + See */ function val($a, $k) { return $a[$k]; } /* }}} */ -/* -* vim600: sw=4 ts=4 syntax=php et -* vim<600: sw=4 ts=4 -*/ +?> diff --git a/include/PhDCommonOptions.class.php b/include/PhDCommonOptions.class.php new file mode 100644 index 000000000..525decc04 --- /dev/null +++ b/include/PhDCommonOptions.class.php @@ -0,0 +1,117 @@ + "c:", // Use color output if possible + "verbose:" => "v", // Adjust the verbosity level + "version" => "V", // Print out version information + "help" => "h", // Print out help + ); + } + + public function option_v($k, $v) + { + if ($k[0] === 'V') { + $this->option_version($k, $v); + return; + } + + if (is_array($v)) { + foreach($v as $i => $val) { + $this->verbose |= pow(2, $i); + } + } else { + $this->verbose |= 1; + } + PhDConfig::set_verbose($this->verbose); + error_reporting($GLOBALS['olderrrep'] | $this->verbose); + } + + public function option_verbose($k, $v) + { + foreach((array)$v as $i => $val) { + foreach(explode("|", $val) as $const) { + if (defined($const)) { + $this->verbose |= (int)constant($const); + } elseif (is_numeric($const)) { + $this->verbose |= (int)$const; + } else { + trigger_error("Unknown option passed to --$k, $const", E_USER_ERROR); + } + } + } + PhDConfig::set_verbose($this->verbose); + error_reporting($GLOBALS['olderrrep'] | $this->verbose); + } + + public function option_c($k, $v) + { + $this->option_color($k, $v); + } + public function option_color($k, $v) + { + if (is_array($v)) { + trigger_error(sprintf("You cannot pass %s more than once", $k), E_USER_ERROR); + } + $val = phd_bool($v); + if (is_bool($val)) { + if ($val && function_exists('posix_isatty')) { + PhDConfig::set_phd_info_color(posix_isatty(PhDConfig::phd_info_output()) ? '01;32' : false); // Bright (bold) green + PhDConfig::set_user_error_color(posix_isatty(PhDConfig::user_error_output()) ? '01;33' : false); // Bright (bold) yellow + PhDConfig::set_php_error_color(posix_isatty(PhDConfig::php_error_output()) ? '01;31' : false); // Bright (bold) red + } else { + PhDConfig::set_phd_info_color(false); + PhDConfig::set_user_error_color(false); + PhDConfig::set_php_error_color(false); + } + } else { + trigger_error("yes/no || on/off || true/false || 1/0 expected", E_USER_ERROR); + } + } + + public function option_version($k, $v) + { + printf("%s\n", $this->getTitleText()); + printf("PhD version: %s\n", PHD_VERSION); + printf("Copyright (c) 2008 The PHP Documentation Group\n"); + exit(0); + } + + public function option_h($k, $v) + { + $this->option_help($k, $v); + } + public function option_help($k, $v) + { + echo $this->getTitleText() . "\n"; + echo "PhD version: " . PHD_VERSION . "\n"; + echo <<getHelpText()} + -v + --verbose Adjusts the verbosity level + -c + --color Enable color output when output is to a terminal (default: false) + -V + --version Print the PhD version information + -h + --help This help + +Most options can be passed multiple times for greater effect. + +ENDBLOB; + exit(0); + } +} + +?> diff --git a/include/PhDCompileOptions.class.php b/include/PhDCompileOptions.class.php new file mode 100644 index 000000000..a96ddba80 --- /dev/null +++ b/include/PhDCompileOptions.class.php @@ -0,0 +1,32 @@ + "?:", // ????? + )); + } + + protected function getTitleText() + { + return "PhD XML Compiler"; + } + + protected function getHelpText() + { + return <<<'ENDBLOB' + -o + --output The output directory or file (default: ./.manual.xml) +ENDBLOB; + } +} + +$optParser = new PhDCompileOptionsParser; +$optParser->getopt(); + +?> diff --git a/include/PhDBuildOptions.class.php b/include/PhDRenderOptions.class.php similarity index 68% rename from include/PhDBuildOptions.class.php rename to include/PhDRenderOptions.class.php index 3a7f42ca4..0430491b4 100644 --- a/include/PhDBuildOptions.class.php +++ b/include/PhDRenderOptions.class.php @@ -1,14 +1,15 @@ "f:", // The format to render (xhtml, pdf...) "theme:" => "t:", // The theme to render (phpweb, bightml..) "index:" => "i:", // Re-index or load from cache @@ -16,12 +17,8 @@ public function getOptionList() "output:" => "o:", // The output directory "partial:" => "p:", // The ID to render (optionally ignoring its children) "skip:" => "s:", // The ID to skip (optionally skipping its children too) - "verbose:" => "v", // Adjust the verbosity level "list::" => "l::", // List supported themes/formats - "color:" => "c:", // Use color output if possible - "version" => "V", // Print out version information - "help" => "h", // Print out help - ); + )); } public function option_f($k, $v) @@ -156,41 +153,6 @@ public function option_skip($k, $v) PhDConfig::set_skip_ids($skip_ids); } - public function option_v($k, $v) - { - if ($k[0] === 'V') { - $this->option_version($k, $v); - return; - } - - if (is_array($v)) { - foreach($v as $i => $val) { - $this->verbose |= pow(2, $i); - } - } else { - $this->verbose |= 1; - } - PhDConfig::set_verbose($this->verbose); - error_reporting($GLOBALS['olderrrep'] | $this->verbose); - } - - public function option_verbose($k, $v) - { - foreach((array)$v as $i => $val) { - foreach(explode("|", $val) as $const) { - if (defined($const)) { - $this->verbose |= (int)constant($const); - } elseif (is_numeric($const)) { - $this->verbose |= (int)$const; - } else { - trigger_error("Unknown option passed to --$k, $const", E_USER_ERROR); - } - } - } - PhDConfig::set_verbose($this->verbose); - error_reporting($GLOBALS['olderrrep'] | $this->verbose); - } - public function option_l($k, $v) { $this->option_list($k, $v); @@ -251,48 +213,14 @@ public function option_list($k, $v) exit(0); } - public function option_c($k, $v) - { - $this->option_color($k, $v); - } - public function option_color($k, $v) - { - if (is_array($v)) { - trigger_error(sprintf("You cannot pass %s more than once", $k), E_USER_ERROR); - } - $val = phd_bool($v); - if (is_bool($val)) { - if ($val && function_exists('posix_isatty')) { - PhDConfig::set_phd_info_color(posix_isatty(PhDConfig::phd_info_output()) ? '01;32' : false); // Bright (bold) green - PhDConfig::set_user_error_color(posix_isatty(PhDConfig::user_error_output()) ? '01;33' : false); // Bright (bold) yellow - PhDConfig::set_php_error_color(posix_isatty(PhDConfig::php_error_output()) ? '01;31' : false); // Bright (bold) red - } else { - PhDConfig::set_phd_info_color(false); - PhDConfig::set_user_error_color(false); - PhDConfig::set_php_error_color(false); - } - } else { - trigger_error("yes/no || on/off || true/false || 1/0 expected", E_USER_ERROR); - } - } - - public function option_version($k, $v) + protected function getTitleText() { - printf("PhD version: %s\n", PHD_VERSION); - printf("Copyright (c) 2008 The PHP Documentation Group\n"); - exit(0); + return "PhD Renderer"; } - public function option_h($k, $v) + protected function getHelpText() { - $this->option_help($k, $v); - } - public function option_help($k, $v) - { - echo "PhD version: " .PHD_VERSION; - echo "\nCopyright (c) 2008 The PHP Documentation Group\n - -v - --verbose Adjusts the verbosity level + return <<<'ENDBLOB' -f --format The build format to use -t @@ -309,20 +237,11 @@ public function option_help($k, $v) --list Print out the supported formats/themes (default: both) -o --output The output directory (default: .) - -c - --color Enable color output when output is to a terminal (default: false) - -V - --version Print the PhD version information - -h - --help This help - -Most options can be passed multiple times for greater affect. -NOTE: Long options are only supported using PHP5.3\n"; - exit(0); +ENDBLOB; } } -$optParser = new PhDBuildOptionsParser; +$optParser = new PhDRenderOptionsParser; $optParser->getopt(); ?> diff --git a/phpdotnet/phd/BuildOptionsParser.php b/phpdotnet/phd/BuildOptionsParser.php deleted file mode 100644 index 3a7f42ca4..000000000 --- a/phpdotnet/phd/BuildOptionsParser.php +++ /dev/null @@ -1,328 +0,0 @@ - "f:", // The format to render (xhtml, pdf...) - "theme:" => "t:", // The theme to render (phpweb, bightml..) - "index:" => "i:", // Re-index or load from cache - "docbook:" => "d:", // The Docbook XML file to render from (.manual.xml) - "output:" => "o:", // The output directory - "partial:" => "p:", // The ID to render (optionally ignoring its children) - "skip:" => "s:", // The ID to skip (optionally skipping its children too) - "verbose:" => "v", // Adjust the verbosity level - "list::" => "l::", // List supported themes/formats - "color:" => "c:", // Use color output if possible - "version" => "V", // Print out version information - "help" => "h", // Print out help - ); - } - - public function option_f($k, $v) - { - $this->option_format($k, $v); - } - public function option_format($k, $v) - { - if ($v != "xhtml") { - trigger_error("Only xhtml is supported at this time", E_USER_ERROR); - } - } - - public function option_t($k, $v) - { - $this->option_theme($k, $v); - } - public function option_theme($k, $v) - { - /* Remove the default themes */ - $themes = PhDConfig::output_theme(); - $themes['xhtml']['php'] = array(); - - foreach((array)$v as $i => $val) { - switch($val) { - case "phpweb": - case "chunkedhtml": - case "bightml": - case "chmsource": - if (!in_array($val, $themes["xhtml"]["php"])) { - $themes["xhtml"]["php"][] = $val; - } - break; - default: - trigger_error(sprintf("Unknown theme '%s'", $val), E_USER_ERROR); - } - } - PhDConfig::set_output_theme($themes); - } - - public function option_i($k, $v) - { - $this->option_index($k, $v); - } - public function option_index($k, $v) - { - if (is_array($v)) { - trigger_error(sprintf("You cannot pass %s more than once", $k), E_USER_ERROR); - } - $val = phd_bool($v); - if (is_bool($val)) { - PhDConfig::set_index($val); - } else { - trigger_error("yes/no || on/off || true/false || 1/0 expected", E_USER_ERROR); - } - } - - public function option_d($k, $v) - { - $this->option_docbook($k, $v); - } - public function option_docbook($k, $v) - { - if (is_array($v)) { - trigger_error("Can only parse one file at a time", E_USER_ERROR); - } - if (!file_exists($v) || is_dir($v) || !is_readable($v)) { - trigger_error(sprintf("'%s' is not a readable docbook file", $v), E_USER_ERROR); - } - PhDConfig::set_xml_root(dirname($v)); - PhDConfig::set_xml_file($v); - $this->docbook = true; - } - - public function option_o($k, $v) - { - $this->option_output($k, $v); - } - public function option_output($k, $v) - { - if (is_array($v)) { - trigger_error("Only a single output location can be supplied", E_USER_ERROR); - } - @mkdir($v, 0777, true); - if (!is_dir($v) || !is_readable($v)) { - trigger_error(sprintf("'%s' is not a valid directory", $v), E_USER_ERROR); - } - PhDConfig::set_output_dir($v); - } - - public function option_p($k, $v) - { - $this->option_partial($k, $v); - } - public function option_partial($k, $v) - { - $render_ids = PhDConfig::render_ids(); - foreach((array)$v as $i => $val) { - $recursive = true; - if (strpos($val, "=") !== false) { - list($val, $recursive) = explode("=", $val); - - if (!is_numeric($recursive) && defined($recursive)) { - $recursive = constant($recursive); - } - $recursive = (bool) $recursive; - } - $render_ids[$val] = $recursive; - } - PhDConfig::set_render_ids($render_ids); - } - - public function option_s($k, $v) - { - $this->option_skip($k, $v); - } - public function option_skip($k, $v) - { - $skip_ids = PhDConfig::skip_ids(); - foreach((array)$v as $i => $val) { - $recursive = true; - if (strpos($val, "=") !== false) { - list($val, $recursive) = explode("=", $val); - - if (!is_numeric($recursive) && defined($recursive)) { - $recursive = constant($recursive); - } - $recursive = (bool) $recursive; - } - $skip_ids[$val] = $recursive; - } - PhDConfig::set_skip_ids($skip_ids); - } - - public function option_v($k, $v) - { - if ($k[0] === 'V') { - $this->option_version($k, $v); - return; - } - - if (is_array($v)) { - foreach($v as $i => $val) { - $this->verbose |= pow(2, $i); - } - } else { - $this->verbose |= 1; - } - PhDConfig::set_verbose($this->verbose); - error_reporting($GLOBALS['olderrrep'] | $this->verbose); - } - - public function option_verbose($k, $v) - { - foreach((array)$v as $i => $val) { - foreach(explode("|", $val) as $const) { - if (defined($const)) { - $this->verbose |= (int)constant($const); - } elseif (is_numeric($const)) { - $this->verbose |= (int)$const; - } else { - trigger_error("Unknown option passed to --$k, $const", E_USER_ERROR); - } - } - } - PhDConfig::set_verbose($this->verbose); - error_reporting($GLOBALS['olderrrep'] | $this->verbose); - } - - public function option_l($k, $v) - { - $this->option_list($k, $v); - } - public function option_list($k, $v) - { - static $formatList = NULL; - static $themeList = NULL; - - if (is_null($formatList)) { - $formatList = array(); - foreach (glob($GLOBALS['ROOT'] . "/formats/*.php") as $item) { - $formatList[] = substr(basename($item), 0, -4); - } - } - if (is_null($themeList)) { - $themeList = array(); - foreach (glob($GLOBALS['ROOT'] . "/themes/*", GLOB_ONLYDIR) as $item) { - if (!in_array(basename($item), array('CVS', '.', '..'))) { - $maintheme = basename($item); - $subthemes = array(); - foreach (glob($item . "/*.php") as $subitem) { - $subthemes[] = substr(basename($subitem), 0, -4); - } - $themeList[$maintheme] = $subthemes; - } - } - } - - if ($v === false) { - $v = array('f', 't'); - } - - foreach((array)$v as $val) { - switch($val) { - case "f": - case "format": - case "formats": { - echo "Supported formats:\n"; - echo "\t" . implode("\n\t", $formatList) . "\n"; - break; - } - - case "t": - case "theme": - case "themes": - echo "Supported themes:\n"; - foreach ($themeList as $theme => $subthemes) { - echo "\t" . $theme . "\n\t\t" . implode("\n\t\t", $subthemes) . "\n"; - } - break; - - default: - echo "Unknown list type '$val'\n"; - break; - } - } - exit(0); - } - - public function option_c($k, $v) - { - $this->option_color($k, $v); - } - public function option_color($k, $v) - { - if (is_array($v)) { - trigger_error(sprintf("You cannot pass %s more than once", $k), E_USER_ERROR); - } - $val = phd_bool($v); - if (is_bool($val)) { - if ($val && function_exists('posix_isatty')) { - PhDConfig::set_phd_info_color(posix_isatty(PhDConfig::phd_info_output()) ? '01;32' : false); // Bright (bold) green - PhDConfig::set_user_error_color(posix_isatty(PhDConfig::user_error_output()) ? '01;33' : false); // Bright (bold) yellow - PhDConfig::set_php_error_color(posix_isatty(PhDConfig::php_error_output()) ? '01;31' : false); // Bright (bold) red - } else { - PhDConfig::set_phd_info_color(false); - PhDConfig::set_user_error_color(false); - PhDConfig::set_php_error_color(false); - } - } else { - trigger_error("yes/no || on/off || true/false || 1/0 expected", E_USER_ERROR); - } - } - - public function option_version($k, $v) - { - printf("PhD version: %s\n", PHD_VERSION); - printf("Copyright (c) 2008 The PHP Documentation Group\n"); - exit(0); - } - - public function option_h($k, $v) - { - $this->option_help($k, $v); - } - public function option_help($k, $v) - { - echo "PhD version: " .PHD_VERSION; - echo "\nCopyright (c) 2008 The PHP Documentation Group\n - -v - --verbose Adjusts the verbosity level - -f - --format The build format to use - -t - --theme The theme to use - -i - --index Index before rendering (default) or load from cache (false) - -d - --docbook The Docbook file to render from - -p - --partial The ID to render, optionally skipping its children chunks (default to true; render children) - -s - --skip The ID to skip, optionally skipping its children chunks (default to true; skip children) - -l - --list Print out the supported formats/themes (default: both) - -o - --output The output directory (default: .) - -c - --color Enable color output when output is to a terminal (default: false) - -V - --version Print the PhD version information - -h - --help This help - -Most options can be passed multiple times for greater affect. -NOTE: Long options are only supported using PHP5.3\n"; - exit(0); - } -} - -$optParser = new PhDBuildOptionsParser; -$optParser->getopt(); - -?> diff --git a/phpdotnet/phd/Config.php b/phpdotnet/phd/Config.php index a89e95cbf..046d5b4d2 100644 --- a/phpdotnet/phd/Config.php +++ b/phpdotnet/phd/Config.php @@ -138,14 +138,12 @@ public function getopt() } } -/* {{{ Can't function_call()['key'], so val(function_call(), 'key') */ +/* {{{ Can't function_call()['key'], so val(function_call(), 'key') + See */ function val($a, $k) { return $a[$k]; } /* }}} */ -/* -* vim600: sw=4 ts=4 syntax=php et -* vim<600: sw=4 ts=4 -*/ +?> diff --git a/build.php b/render.php similarity index 89% rename from build.php rename to render.php index 639507f17..e54397053 100644 --- a/build.php +++ b/render.php @@ -12,41 +12,16 @@ } /* }}} */ -(include $ROOT . "/config.php") - or die("Configuration file not found.\nRe-run phd-setup.\n"); +require_once ($ROOT . "/config.php"); -(include $ROOT . "/include/PhDBuildOptions.class.php") +(include $ROOT . "/include/PhDRenderOptions.class.php") && is_array(PhDConfig::output_theme()) - or die("Invalid configuration.\nThis should never happen, did you edit config.php yourself?\nRe-run phd-setup.\n"); - -/* {{{ BC for PhD 0.0.* (and PHP5.2 on Windows) - i.e. `phd path/to/.manual.xml */ -if (!$optParser->docbook && $argc > 1) { - $arg = $argv[$argc-1]; - if (is_dir($arg)) { - PhDConfig::set_xml_root($arg); - PhDConfig::set_xml_file($arg . DIRECTORY_SEPARATOR . ".manual.xml"); - } elseif (is_file($arg)) { - PhDConfig::set_xml_root(dirname($arg)); - PhDConfig::set_xml_file($arg); - } -} -/* }}} */ + or trigger_error("Invalid configuration. This should never happen, was config.php edited manually? Please re-run phd-setup.", E_USER_ERROR); -/* {{{ If no docbook file was passed, ask for it - This loop should be removed in PhD 0.3.0, and replaced with a fatal errormsg */ -while (!is_dir(PhDConfig::xml_root()) || !is_file(PhDConfig::xml_file())) { - print "I need to know where you keep your '.manual.xml' file (I didn't find it in " . PhDConfig::xml_root() . "): "; - $root = trim(fgets(STDIN)); - if (is_file($root)) { - PhDConfig::set_xml_file($root); - PhDConfig::set_xml_root(dirname($root)); - } else { - PhDConfig::set_xml_file($root . "/.manual.xml"); - PhDConfig::set_xml_root($root); - } +/* If no docbook file was passed, die */ +if (!is_dir(PhDConfig::xml_root()) || !is_file(PhDConfig::xml_file())) { + trigger_error("No '.manual.xml' file was given. Specify it on the command line with --docbook.", E_USER_ERROR); } -/* }}} */ /* This needs to be done in *all* cases! */ PhDConfig::set_output_dir(realpath(PhDConfig::output_dir()) . DIRECTORY_SEPARATOR); @@ -332,8 +307,4 @@ } // foreach(PhDConfig::output_themes()) -/* -* vim600: sw=4 ts=4 syntax=php et -* vim<600: sw=4 ts=4 -*/ - +?> From 0cd25c369ed01b0bdd2d8df82cafec94999c07e6 Mon Sep 17 00:00:00 2001 From: Gwynne Raskind Date: Thu, 10 Jul 2008 12:35:59 +0000 Subject: [PATCH 05/12] added Rev tags to the program scripts, colorized version output, added Revision to version output, added compile options --- compile.php | 1 + include/PhDCommonOptions.class.php | 9 ++++++--- include/PhDCompileOptions.class.php | 11 ++++++++++- render.php | 1 + 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/compile.php b/compile.php index b7586034b..4997c9ac6 100644 --- a/compile.php +++ b/compile.php @@ -1,6 +1,7 @@ #!@php_bin@ getTitleText()); - printf("PhD version: %s\n", PHD_VERSION); - printf("Copyright (c) 2008 The PHP Documentation Group\n"); + $color = PhDConfig::phd_info_color(); + $output = PhDConfig::phd_info_output(); + $rev = preg_replace('/\$Re[v](: ([\d.]+) ?)?\$$/e', "'\\1' == '' ? '??' : '\\2'", $GLOBALS['base_revision']); + fprintf($output, "%s\n", term_color($this->getTitleText(), $color)); + fprintf($output, "%s\n", term_color("PhD Version: " . PHD_VERSION . " (" . $rev . ")", $color)); + fprintf($output, "%s\n", term_color("Copyright(c) 2008 The PHP Documentation Group", $color)); exit(0); } diff --git a/include/PhDCompileOptions.class.php b/include/PhDCompileOptions.class.php index a96ddba80..dfd2fa9db 100644 --- a/include/PhDCompileOptions.class.php +++ b/include/PhDCompileOptions.class.php @@ -8,7 +8,10 @@ class PhDCompileOptionsParser extends PhDCommonOptionsParser public function getOptionList() { return array_merge(parent::getOptionList(), array( -// "??????:" => "?:", // ????? + 'output:' => 'o:', // Output directory or file + 'source:' => 's:', // Input phpdoc checkout + 'force:' => 'f:', // Force DOM save on validation fail + 'partial:' => 'p:', // Root ID )); } @@ -22,6 +25,12 @@ protected function getHelpText() return <<<'ENDBLOB' -o --output The output directory or file (default: ./.manual.xml) + -s + --source The source documentation checkout (default: .) + -f + --force Save (true) invalid XML with errors or discard (default). + -p + --partial The root ID to render (default all). ENDBLOB; } } diff --git a/render.php b/render.php index e54397053..3b9b8a937 100644 --- a/render.php +++ b/render.php @@ -1,6 +1,7 @@ #!@php_bin@ Date: Thu, 10 Jul 2008 16:51:28 +0000 Subject: [PATCH 06/12] fixed the way configs are included, added redesign notes, start phd-setup --- README.REDESIGN | 38 +++++++++++++++++++++++++++++++ compile.php | 6 ++--- include/PhDSetupOptions.class.php | 32 ++++++++++++++++++++++++++ render.php | 6 ++--- setup.php | 18 +++++++++++++++ 5 files changed, 93 insertions(+), 7 deletions(-) create mode 100644 README.REDESIGN create mode 100644 include/PhDSetupOptions.class.php create mode 100644 setup.php diff --git a/README.REDESIGN b/README.REDESIGN new file mode 100644 index 000000000..953268cd2 --- /dev/null +++ b/README.REDESIGN @@ -0,0 +1,38 @@ +The redesign affects both PhD itself and the phpdoc/ checkout structure. The +changes in phpdoc/ and their reasons are listed here. + +- Pregenerated files like functable.xml removed from CVS + These can be one-timed from phd-setup as necessitated by the php.net theme + selection. + +- Intermediate manual.xml completely removed + phd-compile only needs this internally; generating it isn't time-consuming + enough to warrant a permanent file. Because it's changed on a per-language + basis, and language is determined by phd-compile, phd-setup should not + pregenerate it. + +- Remove install-win.xml and install-unix.xml + Easily generated by phd-compile --partial=install.windows or similar. + +- Remove htmlhelp/ + Replaced by CHM output format in PhD. + +- phpdoc-howto really should be its own CVS/SVN module + +- phpbook/ and docbook/ removed, replaced by docbook-xml/ + No longer necessary or used, especially not DSSSL or XSL. Only docbook-xml/ + is used by PhD for DTD validation of manual.xml. + +- PhD, all three phases, must support saving *all* output outside a CVS/SVN + checkout. PhD should not depend on the presence of any files inside a CVS/SVN + checkout save manual.xml, and allow manual.xml and specific output themes to + define anything else. PhD may also depend on the use of language + subdirectories according to theme settings. + +- Output format and theme should be defined and saved by phd-setup, but *not* + language! Also under phd-setup's responsibility are: + - input checkout directory (though it should not have to be a CVS/SVN + checkout!), + - output directory for build files + - list of available themes/formats + - *not* output directory for final results diff --git a/compile.php b/compile.php index 4997c9ac6..42fe1de2d 100644 --- a/compile.php +++ b/compile.php @@ -12,9 +12,7 @@ } /* }}} */ -require_once ($ROOT . "/config.php"); - -(include $ROOT . "/include/PhDCompileOptions.class.php") - or die("Invalid configuration.\nThis should never happen, did you edit config.php yourself?\nRe-run phd-setup.\n"); +require_once $ROOT . "/config.php"; +require_once $ROOT . "/include/PhDCompileOptions.class.php"; ?> diff --git a/include/PhDSetupOptions.class.php b/include/PhDSetupOptions.class.php new file mode 100644 index 000000000..54aae7ff8 --- /dev/null +++ b/include/PhDSetupOptions.class.php @@ -0,0 +1,32 @@ + 'o:', // Output directory or file + )); + } + + protected function getTitleText() + { + return "PhD Setup"; + } + + protected function getHelpText() + { + return '';/*<<<'ENDBLOB' + -o + --output The output directory or file (default: ./.manual.xml) +ENDBLOB;*/ + } +} + +$optParser = new PhDSetupOptionsParser; +$optParser->getopt(); + +?> diff --git a/render.php b/render.php index 3b9b8a937..401206d17 100644 --- a/render.php +++ b/render.php @@ -13,10 +13,10 @@ } /* }}} */ -require_once ($ROOT . "/config.php"); +require_once $ROOT . "/config.php"; +require_once $ROOT . "/include/PhDRenderOptions.class.php"; -(include $ROOT . "/include/PhDRenderOptions.class.php") - && is_array(PhDConfig::output_theme()) +is_array(PhDConfig::output_theme()) or trigger_error("Invalid configuration. This should never happen, was config.php edited manually? Please re-run phd-setup.", E_USER_ERROR); /* If no docbook file was passed, die */ diff --git a/setup.php b/setup.php new file mode 100644 index 000000000..87f6af0bb --- /dev/null +++ b/setup.php @@ -0,0 +1,18 @@ +#!@php_bin@ + From ecb9be6ee9f3174472172bacef0f01616744a01b Mon Sep 17 00:00:00 2001 From: Gwynne Raskind Date: Thu, 10 Jul 2008 16:56:45 +0000 Subject: [PATCH 07/12] My face is red. $ only works in SVN. $ works in both. --- compile.php | 2 +- include/PhDCommonOptions.class.php | 2 +- render.php | 2 +- setup.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compile.php b/compile.php index 42fe1de2d..e7eefa0b0 100644 --- a/compile.php +++ b/compile.php @@ -1,7 +1,7 @@ #!@php_bin@ getTitleText(), $color)); fprintf($output, "%s\n", term_color("PhD Version: " . PHD_VERSION . " (" . $rev . ")", $color)); fprintf($output, "%s\n", term_color("Copyright(c) 2008 The PHP Documentation Group", $color)); diff --git a/render.php b/render.php index 401206d17..a939e5409 100644 --- a/render.php +++ b/render.php @@ -1,7 +1,7 @@ #!@php_bin@ Date: Thu, 10 Jul 2008 17:06:58 +0000 Subject: [PATCH 08/12] several options that belong to setup moved there. and let's keep our quote styles straight --- include/PhDCompileOptions.class.php | 10 +- include/PhDRenderOptions.class.php | 109 +--------------------- include/PhDSetupOptions.class.php | 136 +++++++++++++++++++++++++++- 3 files changed, 134 insertions(+), 121 deletions(-) diff --git a/include/PhDCompileOptions.class.php b/include/PhDCompileOptions.class.php index dfd2fa9db..cc7ba05b2 100644 --- a/include/PhDCompileOptions.class.php +++ b/include/PhDCompileOptions.class.php @@ -8,10 +8,8 @@ class PhDCompileOptionsParser extends PhDCommonOptionsParser public function getOptionList() { return array_merge(parent::getOptionList(), array( - 'output:' => 'o:', // Output directory or file - 'source:' => 's:', // Input phpdoc checkout - 'force:' => 'f:', // Force DOM save on validation fail - 'partial:' => 'p:', // Root ID + "force:" => "f:", // Force DOM save on validation fail + "partial:" => "p:", // Root ID )); } @@ -23,10 +21,6 @@ protected function getTitleText() protected function getHelpText() { return <<<'ENDBLOB' - -o - --output The output directory or file (default: ./.manual.xml) - -s - --source The source documentation checkout (default: .) -f --force Save (true) invalid XML with errors or discard (default). -p diff --git a/include/PhDRenderOptions.class.php b/include/PhDRenderOptions.class.php index 0430491b4..214210a43 100644 --- a/include/PhDRenderOptions.class.php +++ b/include/PhDRenderOptions.class.php @@ -10,55 +10,14 @@ class PhDRenderOptionsParser extends PhDCommonOptionsParser public function getOptionList() { return array_merge(parent::getOptionList(), array( - "format:" => "f:", // The format to render (xhtml, pdf...) - "theme:" => "t:", // The theme to render (phpweb, bightml..) "index:" => "i:", // Re-index or load from cache "docbook:" => "d:", // The Docbook XML file to render from (.manual.xml) "output:" => "o:", // The output directory "partial:" => "p:", // The ID to render (optionally ignoring its children) "skip:" => "s:", // The ID to skip (optionally skipping its children too) - "list::" => "l::", // List supported themes/formats )); } - public function option_f($k, $v) - { - $this->option_format($k, $v); - } - public function option_format($k, $v) - { - if ($v != "xhtml") { - trigger_error("Only xhtml is supported at this time", E_USER_ERROR); - } - } - - public function option_t($k, $v) - { - $this->option_theme($k, $v); - } - public function option_theme($k, $v) - { - /* Remove the default themes */ - $themes = PhDConfig::output_theme(); - $themes['xhtml']['php'] = array(); - - foreach((array)$v as $i => $val) { - switch($val) { - case "phpweb": - case "chunkedhtml": - case "bightml": - case "chmsource": - if (!in_array($val, $themes["xhtml"]["php"])) { - $themes["xhtml"]["php"][] = $val; - } - break; - default: - trigger_error(sprintf("Unknown theme '%s'", $val), E_USER_ERROR); - } - } - PhDConfig::set_output_theme($themes); - } - public function option_i($k, $v) { $this->option_index($k, $v); @@ -153,66 +112,6 @@ public function option_skip($k, $v) PhDConfig::set_skip_ids($skip_ids); } - public function option_l($k, $v) - { - $this->option_list($k, $v); - } - public function option_list($k, $v) - { - static $formatList = NULL; - static $themeList = NULL; - - if (is_null($formatList)) { - $formatList = array(); - foreach (glob($GLOBALS['ROOT'] . "/formats/*.php") as $item) { - $formatList[] = substr(basename($item), 0, -4); - } - } - if (is_null($themeList)) { - $themeList = array(); - foreach (glob($GLOBALS['ROOT'] . "/themes/*", GLOB_ONLYDIR) as $item) { - if (!in_array(basename($item), array('CVS', '.', '..'))) { - $maintheme = basename($item); - $subthemes = array(); - foreach (glob($item . "/*.php") as $subitem) { - $subthemes[] = substr(basename($subitem), 0, -4); - } - $themeList[$maintheme] = $subthemes; - } - } - } - - if ($v === false) { - $v = array('f', 't'); - } - - foreach((array)$v as $val) { - switch($val) { - case "f": - case "format": - case "formats": { - echo "Supported formats:\n"; - echo "\t" . implode("\n\t", $formatList) . "\n"; - break; - } - - case "t": - case "theme": - case "themes": - echo "Supported themes:\n"; - foreach ($themeList as $theme => $subthemes) { - echo "\t" . $theme . "\n\t\t" . implode("\n\t\t", $subthemes) . "\n"; - } - break; - - default: - echo "Unknown list type '$val'\n"; - break; - } - } - exit(0); - } - protected function getTitleText() { return "PhD Renderer"; @@ -221,10 +120,6 @@ protected function getTitleText() protected function getHelpText() { return <<<'ENDBLOB' - -f - --format The build format to use - -t - --theme The theme to use -i --index Index before rendering (default) or load from cache (false) -d @@ -233,10 +128,8 @@ protected function getHelpText() --partial The ID to render, optionally skipping its children chunks (default to true; render children) -s --skip The ID to skip, optionally skipping its children chunks (default to true; skip children) - -l - --list Print out the supported formats/themes (default: both) -o - --output The output directory (default: .) + --output The output directory for final generated files (default: .) ENDBLOB; } } diff --git a/include/PhDSetupOptions.class.php b/include/PhDSetupOptions.class.php index 54aae7ff8..681145d37 100644 --- a/include/PhDSetupOptions.class.php +++ b/include/PhDSetupOptions.class.php @@ -8,10 +8,128 @@ class PhDSetupOptionsParser extends PhDCommonOptionsParser public function getOptionList() { return array_merge(parent::getOptionList(), array( -// 'output:' => 'o:', // Output directory or file + "format:" => "f:", // The format to render (xhtml, pdf...) + "theme:" => "t:", // The theme to render (phpweb, bightml..) + "list::" => "l::", // List supported themes/formats + "source:" => "s:", // Input phpdoc checkout + "output:" => "o:", // Output directory or file )); } + public function option_o($k, $v) + { + $this->option_output($k, $v); + } + public function option_output($k, $v) + { + if (is_array($v)) { + trigger_error("Only a single output location can be supplied", E_USER_ERROR); + } + @mkdir($v, 0777, true); + if (!is_dir($v) || !is_readable($v)) { + trigger_error(sprintf("'%s' is not a valid directory", $v), E_USER_ERROR); + } + PhDConfig::set_intermediate_output_dir($v); + } + + public function option_f($k, $v) + { + $this->option_format($k, $v); + } + public function option_format($k, $v) + { + if ($v != "xhtml") { + trigger_error("Only xhtml is supported at this time", E_USER_ERROR); + } + } + + public function option_t($k, $v) + { + $this->option_theme($k, $v); + } + public function option_theme($k, $v) + { + /* Remove the default themes */ + $themes = PhDConfig::output_theme(); + $themes['xhtml']['php'] = array(); + + foreach((array)$v as $i => $val) { + switch($val) { + case "phpweb": + case "chunkedhtml": + case "bightml": + case "chmsource": + if (!in_array($val, $themes["xhtml"]["php"])) { + $themes["xhtml"]["php"][] = $val; + } + break; + default: + trigger_error(sprintf("Unknown theme '%s'", $val), E_USER_ERROR); + } + } + PhDConfig::set_output_theme($themes); + } + + public function option_l($k, $v) + { + $this->option_list($k, $v); + } + public function option_list($k, $v) + { + static $formatList = NULL; + static $themeList = NULL; + + if (is_null($formatList)) { + $formatList = array(); + foreach (glob($GLOBALS['ROOT'] . "/formats/*.php") as $item) { + $formatList[] = substr(basename($item), 0, -4); + } + } + if (is_null($themeList)) { + $themeList = array(); + foreach (glob($GLOBALS['ROOT'] . "/themes/*", GLOB_ONLYDIR) as $item) { + if (!in_array(basename($item), array('CVS', '.', '..'))) { + $maintheme = basename($item); + $subthemes = array(); + foreach (glob($item . "/*.php") as $subitem) { + $subthemes[] = substr(basename($subitem), 0, -4); + } + $themeList[$maintheme] = $subthemes; + } + } + } + + if ($v === false) { + $v = array('f', 't'); + } + + foreach((array)$v as $val) { + switch($val) { + case "f": + case "format": + case "formats": { + echo "Supported formats:\n"; + echo "\t" . implode("\n\t", $formatList) . "\n"; + break; + } + + case "t": + case "theme": + case "themes": + echo "Supported themes:\n"; + foreach ($themeList as $theme => $subthemes) { + echo "\t" . $theme . "\n\t\t" . implode("\n\t\t", $subthemes) . "\n"; + } + break; + + default: + echo "Unknown list type '$val'\n"; + break; + } + } + exit(0); + } + protected function getTitleText() { return "PhD Setup"; @@ -19,10 +137,18 @@ protected function getTitleText() protected function getHelpText() { - return '';/*<<<'ENDBLOB' - -o - --output The output directory or file (default: ./.manual.xml) -ENDBLOB;*/ + return <<<'ENDBLOB' + -s + --source The source documentation checkout (default: .) + -o + --output The output directory for intermediate build files (default: .) + -f + --format The output format to use + -t + --theme The theme to use + -l + --list Print out the supported formats/themes (default: both) +ENDBLOB; } } From e273f9584213025c195bdfc97d4c476a1572f8b5 Mon Sep 17 00:00:00 2001 From: Gwynne Raskind Date: Tue, 15 Jul 2008 12:36:24 +0000 Subject: [PATCH 09/12] added defaults for -s and -o, deleted more 5.3 BC, finish preliminary setup.php, make -s a common option for input files, change error handling for more verbose and better defining of new verbosity levels, check that output directory is writeable, fix naming conflicts between options --- config.php | 14 +----- include/PhDCommonOptions.class.php | 18 ++++++++ include/PhDErrors.php | 68 ++++++++++++++---------------- include/PhDRenderOptions.class.php | 4 +- include/PhDSetupOptions.class.php | 7 +-- phpdotnet/phd/Config.php | 14 +----- phpdotnet/phd/functions.php | 68 ++++++++++++++---------------- setup.php | 40 ++++++++++++++++++ 8 files changed, 128 insertions(+), 105 deletions(-) diff --git a/config.php b/config.php index 046d5b4d2..6ed030a7b 100644 --- a/config.php +++ b/config.php @@ -35,7 +35,9 @@ class PhDConfig 'skip_ids' => array( ), 'color_output' => false, + 'source_dir' => '.', 'output_dir' => '.', + 'intermediate_output_dir' => '.', 'php_error_output' => NULL, 'php_error_color' => false, 'user_error_output' => NULL, @@ -66,18 +68,6 @@ public static function __callStatic($name, $params) PhDConfig::set_user_error_output(STDERR); PhDConfig::set_phd_info_output(STDOUT); -/* {{{ Workaround/fix for Windows prior to PHP5.3 */ -if (!function_exists("getopt")) { - function getopt($short, $long) { - global $argv; - printf("I'm sorry, you are running an operating system that does not support getopt()\n"); - printf("Please either upgrade to PHP5.3 or try '%s /path/to/your/docbook.xml'\n", $argv[0]); - - return array(); - } -} -/* }}} */ - /* {{{ phd_bool($var) Returns boolean true/false on success, null on failure */ function phd_bool($val) { if (!is_string($val)) { diff --git a/include/PhDCommonOptions.class.php b/include/PhDCommonOptions.class.php index 16d2f57da..b469e064e 100644 --- a/include/PhDCommonOptions.class.php +++ b/include/PhDCommonOptions.class.php @@ -11,6 +11,7 @@ abstract protected function getHelpText(); public function getOptionList() { return array( + "source:" => "s:", // Input data "color:" => "c:", // Use color output if possible "verbose:" => "v", // Adjust the verbosity level "version" => "V", // Print out version information @@ -18,6 +19,21 @@ public function getOptionList() ); } + public function option_s($k, $v) + { + $this->option_source($k, $v); + } + public function option_source($k, $v) + { + if (is_array($v)) { + trigger_error("Only a single input location can be supplied", E_USER_ERROR); + } + if (!is_dir($v) || !is_readable($v)) { + trigger_error(sprintf("'%s' is not a valid directory", $v), E_USER_ERROR); + } + PhDConfig::set_source_dir($v); + } + public function option_v($k, $v) { if ($k[0] === 'V') { @@ -101,6 +117,8 @@ public function option_help($k, $v) Copyright (c) 2008 The PHP Documentation Group {$this->getHelpText()} + -s + --source The source documentation checkout or build area (default: .) -v --verbose Adjusts the verbosity level -c diff --git a/include/PhDErrors.php b/include/PhDErrors.php index 43dcdfccb..4b0cf4317 100644 --- a/include/PhDErrors.php +++ b/include/PhDErrors.php @@ -3,24 +3,38 @@ /* {{{ PhD error & message handler */ -// FC For PHP5.3 -if (!defined("E_DEPRECATED")) { - define("E_DEPRECATED", E_RECOVERABLE_ERROR << 1); +$error_map = array( + E_RECOVERABLE_ERROR => 'PHP Error', + E_WARNING => 'PHP Warning', + E_NOTICE => 'PHP Notice', + E_STRICT => 'PHP Strict Standards Warning', + E_DEPRECATED => 'PHP Deprecated Construct Warning', + E_USER_ERROR => 'User Error', + E_USER_WARNING => 'User Warning', + E_USER_NOTICE => 'User Notice', +); + +function define_error($name, $explanation) { + static $lastErrorValue = E_DEPRECATED; + + define($name, $lastErrorValue <<= 1); + $GLOBALS['error_map'][$lastErrorValue] = $explanation; } // PhD verbose flags -define('VERBOSE_INDEXING', E_DEPRECATED << 1); -define('VERBOSE_FORMAT_RENDERING', VERBOSE_INDEXING << 1); -define('VERBOSE_THEME_RENDERING', VERBOSE_FORMAT_RENDERING << 1); -define('VERBOSE_RENDER_STYLE', VERBOSE_THEME_RENDERING << 1); -define('VERBOSE_PARTIAL_READING', VERBOSE_RENDER_STYLE << 1); -define('VERBOSE_PARTIAL_CHILD_READING', VERBOSE_PARTIAL_READING << 1); -define('VERBOSE_TOC_WRITING', VERBOSE_PARTIAL_CHILD_READING << 1); -define('VERBOSE_CHUNK_WRITING', VERBOSE_TOC_WRITING << 1); -define('VERBOSE_NOVERSION', VERBOSE_CHUNK_WRITING << 1); - -define('VERBOSE_ALL', (VERBOSE_NOVERSION << 1)-1); -define('VERBOSE_DEFAULT', (VERBOSE_ALL^(VERBOSE_PARTIAL_CHILD_READING|VERBOSE_CHUNK_WRITING|VERBOSE_NOVERSION))); +define_error('VERBOSE_INDEXING', 'PhD Indexer'); +define_error('VERBOSE_FORMAT_RENDERING', 'PhD Output Format'); +define_error('VERBOSE_THEME_RENDERING', 'PhD Output Theme'); +define_error('VERBOSE_RENDER_STYLE', 'PhD Rendering Style'); +define_error('VERBOSE_PARTIAL_READING', 'PhD Partial Reader'); +define_error('VERBOSE_PARTIAL_CHILD_READING', 'PhD Partial Child Reader'); +define_error('VERBOSE_TOC_WRITING', 'PhD TOC Writer'); +define_error('VERBOSE_CHUNK_WRITING', 'PhD Chunk Writer'); +define_error('VERBOSE_NOVERSION', 'Missing Version Information'); +define_error('VERBOSE_DONE', 'PhD Processing Completion'); + +define('VERBOSE_ALL', (VERBOSE_NOVERSION << 1)-1); +define('VERBOSE_DEFAULT', (VERBOSE_ALL^(VERBOSE_PARTIAL_CHILD_READING|VERBOSE_CHUNK_WRITING|VERBOSE_NOVERSION|VERBOSE_DONE))); $olderrrep = error_reporting(); error_reporting($olderrrep | VERBOSE_DEFAULT); @@ -47,27 +61,6 @@ function term_color($text, $color) /* {{{ The PhD errorhandler */ function errh($errno, $msg, $file, $line, $ctx = null) { - static $err = array( - E_DEPRECATED => 'E_DEPRECATED', - E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR', - E_STRICT => 'E_STRICT', - E_WARNING => 'E_WARNING', - E_NOTICE => 'E_NOTICE', - - E_USER_ERROR => 'E_USER_ERROR', - E_USER_WARNING => 'E_USER_WARNING', - E_USER_NOTICE => 'E_USER_NOTICE', - - VERBOSE_INDEXING => 'VERBOSE_INDEXING', - VERBOSE_FORMAT_RENDERING => 'VERBOSE_FORMAT_RENDERING', - VERBOSE_THEME_RENDERING => 'VERBOSE_THEME_RENDERING', - VERBOSE_RENDER_STYLE => 'VERBOSE_RENDER_STYLE', - VERBOSE_PARTIAL_READING => 'VERBOSE_PARTIAL_READING', - VERBOSE_PARTIAL_CHILD_READING => 'VERBOSE_PARTIAL_CHILD_READING', - VERBOSE_TOC_WRITING => 'VERBOSE_TOC_WRITING', - VERBOSE_CHUNK_WRITING => 'VERBOSE_CHUNK_WRITING', - VERBOSE_NOVERSION => 'VERBOSE_NOVERSION', - ); static $recursive = false; // Respect the error_reporting setting @@ -93,6 +86,7 @@ function errh($errno, $msg, $file, $line, $ctx = null) { case VERBOSE_TOC_WRITING: case VERBOSE_CHUNK_WRITING: case VERBOSE_NOVERSION: + case VERBOSE_DONE: $color = PhDConfig::phd_info_color(); $output = PhDConfig::phd_info_output(); $data = $msg; @@ -123,7 +117,7 @@ function errh($errno, $msg, $file, $line, $ctx = null) { return false; } - $timestamp = term_color(sprintf("[%s - %s]", $time, $err[$errno]), $color); + $timestamp = term_color(sprintf("[%s - %s]", $time, $GLOBALS['error_map'][$errno]), $color); fprintf($output, "%s %s\n", $timestamp, $data); // Abort on fatal errors diff --git a/include/PhDRenderOptions.class.php b/include/PhDRenderOptions.class.php index 214210a43..b30a481c4 100644 --- a/include/PhDRenderOptions.class.php +++ b/include/PhDRenderOptions.class.php @@ -14,7 +14,7 @@ public function getOptionList() "docbook:" => "d:", // The Docbook XML file to render from (.manual.xml) "output:" => "o:", // The output directory "partial:" => "p:", // The ID to render (optionally ignoring its children) - "skip:" => "s:", // The ID to skip (optionally skipping its children too) + "skip:" => "k:", // The ID to skip (optionally skipping its children too) )); } @@ -90,7 +90,7 @@ public function option_partial($k, $v) PhDConfig::set_render_ids($render_ids); } - public function option_s($k, $v) + public function option_k($k, $v) { $this->option_skip($k, $v); } diff --git a/include/PhDSetupOptions.class.php b/include/PhDSetupOptions.class.php index 681145d37..b1d25b4a4 100644 --- a/include/PhDSetupOptions.class.php +++ b/include/PhDSetupOptions.class.php @@ -11,8 +11,7 @@ public function getOptionList() "format:" => "f:", // The format to render (xhtml, pdf...) "theme:" => "t:", // The theme to render (phpweb, bightml..) "list::" => "l::", // List supported themes/formats - "source:" => "s:", // Input phpdoc checkout - "output:" => "o:", // Output directory or file + "output:" => "o:", // Intermediate output directory )); } @@ -26,7 +25,7 @@ public function option_output($k, $v) trigger_error("Only a single output location can be supplied", E_USER_ERROR); } @mkdir($v, 0777, true); - if (!is_dir($v) || !is_readable($v)) { + if (!is_dir($v) || !is_readable($v) || !is_writable($v)) { trigger_error(sprintf("'%s' is not a valid directory", $v), E_USER_ERROR); } PhDConfig::set_intermediate_output_dir($v); @@ -138,8 +137,6 @@ protected function getTitleText() protected function getHelpText() { return <<<'ENDBLOB' - -s - --source The source documentation checkout (default: .) -o --output The output directory for intermediate build files (default: .) -f diff --git a/phpdotnet/phd/Config.php b/phpdotnet/phd/Config.php index 046d5b4d2..6ed030a7b 100644 --- a/phpdotnet/phd/Config.php +++ b/phpdotnet/phd/Config.php @@ -35,7 +35,9 @@ class PhDConfig 'skip_ids' => array( ), 'color_output' => false, + 'source_dir' => '.', 'output_dir' => '.', + 'intermediate_output_dir' => '.', 'php_error_output' => NULL, 'php_error_color' => false, 'user_error_output' => NULL, @@ -66,18 +68,6 @@ public static function __callStatic($name, $params) PhDConfig::set_user_error_output(STDERR); PhDConfig::set_phd_info_output(STDOUT); -/* {{{ Workaround/fix for Windows prior to PHP5.3 */ -if (!function_exists("getopt")) { - function getopt($short, $long) { - global $argv; - printf("I'm sorry, you are running an operating system that does not support getopt()\n"); - printf("Please either upgrade to PHP5.3 or try '%s /path/to/your/docbook.xml'\n", $argv[0]); - - return array(); - } -} -/* }}} */ - /* {{{ phd_bool($var) Returns boolean true/false on success, null on failure */ function phd_bool($val) { if (!is_string($val)) { diff --git a/phpdotnet/phd/functions.php b/phpdotnet/phd/functions.php index 43dcdfccb..4b0cf4317 100644 --- a/phpdotnet/phd/functions.php +++ b/phpdotnet/phd/functions.php @@ -3,24 +3,38 @@ /* {{{ PhD error & message handler */ -// FC For PHP5.3 -if (!defined("E_DEPRECATED")) { - define("E_DEPRECATED", E_RECOVERABLE_ERROR << 1); +$error_map = array( + E_RECOVERABLE_ERROR => 'PHP Error', + E_WARNING => 'PHP Warning', + E_NOTICE => 'PHP Notice', + E_STRICT => 'PHP Strict Standards Warning', + E_DEPRECATED => 'PHP Deprecated Construct Warning', + E_USER_ERROR => 'User Error', + E_USER_WARNING => 'User Warning', + E_USER_NOTICE => 'User Notice', +); + +function define_error($name, $explanation) { + static $lastErrorValue = E_DEPRECATED; + + define($name, $lastErrorValue <<= 1); + $GLOBALS['error_map'][$lastErrorValue] = $explanation; } // PhD verbose flags -define('VERBOSE_INDEXING', E_DEPRECATED << 1); -define('VERBOSE_FORMAT_RENDERING', VERBOSE_INDEXING << 1); -define('VERBOSE_THEME_RENDERING', VERBOSE_FORMAT_RENDERING << 1); -define('VERBOSE_RENDER_STYLE', VERBOSE_THEME_RENDERING << 1); -define('VERBOSE_PARTIAL_READING', VERBOSE_RENDER_STYLE << 1); -define('VERBOSE_PARTIAL_CHILD_READING', VERBOSE_PARTIAL_READING << 1); -define('VERBOSE_TOC_WRITING', VERBOSE_PARTIAL_CHILD_READING << 1); -define('VERBOSE_CHUNK_WRITING', VERBOSE_TOC_WRITING << 1); -define('VERBOSE_NOVERSION', VERBOSE_CHUNK_WRITING << 1); - -define('VERBOSE_ALL', (VERBOSE_NOVERSION << 1)-1); -define('VERBOSE_DEFAULT', (VERBOSE_ALL^(VERBOSE_PARTIAL_CHILD_READING|VERBOSE_CHUNK_WRITING|VERBOSE_NOVERSION))); +define_error('VERBOSE_INDEXING', 'PhD Indexer'); +define_error('VERBOSE_FORMAT_RENDERING', 'PhD Output Format'); +define_error('VERBOSE_THEME_RENDERING', 'PhD Output Theme'); +define_error('VERBOSE_RENDER_STYLE', 'PhD Rendering Style'); +define_error('VERBOSE_PARTIAL_READING', 'PhD Partial Reader'); +define_error('VERBOSE_PARTIAL_CHILD_READING', 'PhD Partial Child Reader'); +define_error('VERBOSE_TOC_WRITING', 'PhD TOC Writer'); +define_error('VERBOSE_CHUNK_WRITING', 'PhD Chunk Writer'); +define_error('VERBOSE_NOVERSION', 'Missing Version Information'); +define_error('VERBOSE_DONE', 'PhD Processing Completion'); + +define('VERBOSE_ALL', (VERBOSE_NOVERSION << 1)-1); +define('VERBOSE_DEFAULT', (VERBOSE_ALL^(VERBOSE_PARTIAL_CHILD_READING|VERBOSE_CHUNK_WRITING|VERBOSE_NOVERSION|VERBOSE_DONE))); $olderrrep = error_reporting(); error_reporting($olderrrep | VERBOSE_DEFAULT); @@ -47,27 +61,6 @@ function term_color($text, $color) /* {{{ The PhD errorhandler */ function errh($errno, $msg, $file, $line, $ctx = null) { - static $err = array( - E_DEPRECATED => 'E_DEPRECATED', - E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR', - E_STRICT => 'E_STRICT', - E_WARNING => 'E_WARNING', - E_NOTICE => 'E_NOTICE', - - E_USER_ERROR => 'E_USER_ERROR', - E_USER_WARNING => 'E_USER_WARNING', - E_USER_NOTICE => 'E_USER_NOTICE', - - VERBOSE_INDEXING => 'VERBOSE_INDEXING', - VERBOSE_FORMAT_RENDERING => 'VERBOSE_FORMAT_RENDERING', - VERBOSE_THEME_RENDERING => 'VERBOSE_THEME_RENDERING', - VERBOSE_RENDER_STYLE => 'VERBOSE_RENDER_STYLE', - VERBOSE_PARTIAL_READING => 'VERBOSE_PARTIAL_READING', - VERBOSE_PARTIAL_CHILD_READING => 'VERBOSE_PARTIAL_CHILD_READING', - VERBOSE_TOC_WRITING => 'VERBOSE_TOC_WRITING', - VERBOSE_CHUNK_WRITING => 'VERBOSE_CHUNK_WRITING', - VERBOSE_NOVERSION => 'VERBOSE_NOVERSION', - ); static $recursive = false; // Respect the error_reporting setting @@ -93,6 +86,7 @@ function errh($errno, $msg, $file, $line, $ctx = null) { case VERBOSE_TOC_WRITING: case VERBOSE_CHUNK_WRITING: case VERBOSE_NOVERSION: + case VERBOSE_DONE: $color = PhDConfig::phd_info_color(); $output = PhDConfig::phd_info_output(); $data = $msg; @@ -123,7 +117,7 @@ function errh($errno, $msg, $file, $line, $ctx = null) { return false; } - $timestamp = term_color(sprintf("[%s - %s]", $time, $err[$errno]), $color); + $timestamp = term_color(sprintf("[%s - %s]", $time, $GLOBALS['error_map'][$errno]), $color); fprintf($output, "%s %s\n", $timestamp, $data); // Abort on fatal errors diff --git a/setup.php b/setup.php index 3fa7a6723..aaa58bde7 100644 --- a/setup.php +++ b/setup.php @@ -15,4 +15,44 @@ require_once $ROOT . "/config.php"; require_once $ROOT . "/include/PhDSetupOptions.class.php"; +// We assume that the code in the option processors has checked for most of the obvious crap +if (!file_exists(PhDConfig::source_dir() . DIRECTORY_SEPARATOR . "manual.xml")) { + trigger_error("The source directory has no manual.xml file. It can not be used with PhD.", E_USER_ERROR); +} + +$saved_options = array( + 'output_format' => PhDConfig::output_format(), + 'output_theme' => PhDConfig::output_theme(), + 'intermediate_output_dir' => realpath(PhDConfig::intermediate_output_dir()), + 'source_dir' => realpath(PhDConfig::source_dir()), + 'date_format' => PhDConfig::date_format(), +); +$now = date(DATE_RFC2822); + +$options_file = << $option_value) { + $v = var_export($option_value, 1); + $options_file .= << +BLOB; + +$config_file_path = PhDConfig::intermediate_output_dir() . DIRECTORY_SEPARATOR . "phd-config.php"; + +if (file_put_contents($config_file_path, $options_file) === FALSE) { + trigger_error("Unable to write the configuration file to the output directory.", E_USER_ERROR); +} + +v("Configuration successfully written to " . $config_file_path, VERBOSE_DONE); + ?> From 86054d0ffd9470e5f4e481dd853ef9cff4b7ac20 Mon Sep 17 00:00:00 2001 From: Gwynne Raskind Date: Tue, 15 Jul 2008 12:38:14 +0000 Subject: [PATCH 10/12] none of this should be ignored by CVS From 3f64725725c2c9bb2fbffc9f41e79a4b31a2e440 Mon Sep 17 00:00:00 2001 From: Gwynne Raskind Date: Mon, 13 Jul 2009 12:15:13 +0000 Subject: [PATCH 11/12] fix a huge number of wrong MIME types. UGH. From 647f4e68e4730ed7c9b66258e933e64ecdc5dc77 Mon Sep 17 00:00:00 2001 From: Gwynne Raskind Date: Thu, 16 Jul 2009 08:10:50 +0000 Subject: [PATCH 12/12] one more attempt at ridding us of some of those annoying mime types