cvs: phd(RESTRUCTURE) / config.php setup.php /include PhDCommonOptions.class.php PhDErrors.php PhDRenderOptions.class.php PhDSetupOptions.class.php

From: Date: Tue, 15 Jul 2008 12:36:24 +0000
Subject: cvs: phd(RESTRUCTURE) / config.php setup.php /include PhDCommonOptions.class.php PhDErrors.php PhDRenderOptions.class.php PhDSetupOptions.class.php
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-1867@lists.php.net to get a copy of this message
gwynne Tue Jul 15 12:36:24 2008 UTC Modified files: (Branch: RESTRUCTURE) /phd config.php setup.php /phd/include PhDCommonOptions.class.php PhDErrors.php PhDRenderOptions.class.php PhDSetupOptions.class.php Log: 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

http://cvs.php.net/viewvc.cgi/phd/config.php?r1=1.49.2.3&r2=1.49.2.4&diff_format=u Index: phd/config.php diff -u phd/config.php:1.49.2.3 phd/config.php:1.49.2.4 --- phd/config.php:1.49.2.3 Wed Jul 9 12:14:11 2008 +++ phd/config.php Tue Jul 15 12:36:23 2008 @@ -1,5 +1,5 @@ <?php -/* $Id: config.php,v 1.49.2.3 2008/07/09 12:14:11 gwynne Exp $ */ +/* $Id: config.php,v 1.49.2.4 2008/07/15 12:36:23 gwynne Exp $ */ require $ROOT . "/include/PhDErrors.php"; @@ -35,7 +35,9 @@ '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 @@ 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)) { http://cvs.php.net/viewvc.cgi/phd/setup.php?r1=1.1.2.2&r2=1.1.2.3&diff_format=u Index: phd/setup.php diff -u phd/setup.php:1.1.2.2 phd/setup.php:1.1.2.3 --- phd/setup.php:1.1.2.2 Thu Jul 10 16:56:45 2008 +++ phd/setup.php Tue Jul 15 12:36:24 2008 @@ -1,7 +1,7 @@ #!@php_bin@ <?php -/* $Id: setup.php,v 1.1.2.2 2008/07/10 16:56:45 gwynne Exp $ */ -$base_revision = '$Revision: 1.1.2.2 $'; +/* $Id: setup.php,v 1.1.2.3 2008/07/15 12:36:24 gwynne Exp $ */ +$base_revision = '$Revision: 1.1.2.3 $'; /* {{{ Find the $ROOT directory of PhD. @php_dir@ will be replaced by the PEAR package manager. If for some reaosn this hasn't happened, fallback to the @@ -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 = <<<BLOB +<?php +/* This file was automatically generated by phd-setup at {$now}. Do not edit it by hand. */ + +BLOB; + +foreach ($saved_options as $option_name => $option_value) { + $v = var_export($option_value, 1); + $options_file .= <<<BLOB +PhDConfig::set_{$option_name}({$v}); + +BLOB; +} + +$options_file .= <<<BLOB +?> +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); + ?> http://cvs.php.net/viewvc.cgi/phd/include/PhDCommonOptions.class.php?r1=1.1.2.3&r2=1.1.2.4&diff_format=u Index: phd/include/PhDCommonOptions.class.php diff -u phd/include/PhDCommonOptions.class.php:1.1.2.3 phd/include/PhDCommonOptions.class.php:1.1.2.4 --- phd/include/PhDCommonOptions.class.php:1.1.2.3 Thu Jul 10 16:56:45 2008 +++ phd/include/PhDCommonOptions.class.php Tue Jul 15 12:36:24 2008 @@ -1,5 +1,5 @@ <?php -/* $Id: PhDCommonOptions.class.php,v 1.1.2.3 2008/07/10 16:56:45 gwynne Exp $ */ +/* $Id: PhDCommonOptions.class.php,v 1.1.2.4 2008/07/15 12:36:24 gwynne Exp $ */ abstract class PhDCommonOptionsParser extends PhDOptionParser { @@ -11,6 +11,7 @@ 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 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 @@ Copyright (c) 2008 The PHP Documentation Group {$this->getHelpText()} + -s <directory> + --source <directory> The source documentation checkout or build area (default: .) -v --verbose <int> Adjusts the verbosity level -c <bool> http://cvs.php.net/viewvc.cgi/phd/include/PhDErrors.php?r1=1.3&r2=1.3.2.1&diff_format=u Index: phd/include/PhDErrors.php diff -u phd/include/PhDErrors.php:1.3 phd/include/PhDErrors.php:1.3.2.1 --- phd/include/PhDErrors.php:1.3 Sat May 24 15:04:50 2008 +++ phd/include/PhDErrors.php Tue Jul 15 12:36:24 2008 @@ -1,26 +1,40 @@ <?php -/* $Id: PhDErrors.php,v 1.3 2008/05/24 15:04:50 gwynne Exp $ */ +/* $Id: PhDErrors.php,v 1.3.2.1 2008/07/15 12:36:24 gwynne Exp $ */ /* {{{ 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_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))); +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 @@ /* {{{ 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 @@ 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 @@ 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 http://cvs.php.net/viewvc.cgi/phd/include/PhDRenderOptions.class.php?r1=1.1.2.2&r2=1.1.2.3&diff_format=u Index: phd/include/PhDRenderOptions.class.php diff -u phd/include/PhDRenderOptions.class.php:1.1.2.2 phd/include/PhDRenderOptions.class.php:1.1.2.3 --- phd/include/PhDRenderOptions.class.php:1.1.2.2 Thu Jul 10 17:06:58 2008 +++ phd/include/PhDRenderOptions.class.php Tue Jul 15 12:36:24 2008 @@ -1,5 +1,5 @@ <?php -/* $Id: PhDRenderOptions.class.php,v 1.1.2.2 2008/07/10 17:06:58 gwynne Exp $ */ +/* $Id: PhDRenderOptions.class.php,v 1.1.2.3 2008/07/15 12:36:24 gwynne Exp $ */ require 'PhDCommonOptions.class.php'; @@ -14,7 +14,7 @@ "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 @@ PhDConfig::set_render_ids($render_ids); } - public function option_s($k, $v) + public function option_k($k, $v) { $this->option_skip($k, $v); } http://cvs.php.net/viewvc.cgi/phd/include/PhDSetupOptions.class.php?r1=1.1.2.2&r2=1.1.2.3&diff_format=u Index: phd/include/PhDSetupOptions.class.php diff -u phd/include/PhDSetupOptions.class.php:1.1.2.2 phd/include/PhDSetupOptions.class.php:1.1.2.3 --- phd/include/PhDSetupOptions.class.php:1.1.2.2 Thu Jul 10 17:06:58 2008 +++ phd/include/PhDSetupOptions.class.php Tue Jul 15 12:36:24 2008 @@ -1,5 +1,5 @@ <?php -/* $Id: PhDSetupOptions.class.php,v 1.1.2.2 2008/07/10 17:06:58 gwynne Exp $ */ +/* $Id: PhDSetupOptions.class.php,v 1.1.2.3 2008/07/15 12:36:24 gwynne Exp $ */ require 'PhDCommonOptions.class.php'; @@ -11,8 +11,7 @@ "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 @@ 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 getHelpText() { return <<<'ENDBLOB' - -s <directory> - --source <directory> The source documentation checkout (default: .) -o <directory> --output <directory> The output directory for intermediate build files (default: .) -f <formatname>
« previous php.doc.cvs (#1867) next »