cvs: phd / build.php config.php package.xml /include PhDPartialReader.class.php PhDReader.class.php /themes/php phpweb.php
| From: | Hannes Magnusson | Date: | Sun, 21 Oct 2007 17:08:44 +0000 |
| Subject: | cvs: phd / build.php config.php package.xml /include PhDPartialReader.class.php PhDReader.class.php /themes/php phpweb.php | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-255@lists.php.net to get a copy of this message | ||
bjori Sun Oct 21 17:08:44 2007 UTC
Modified files:
/phd build.php config.php package.xml
/phd/include PhDPartialReader.class.php PhDReader.class.php
/phd/themes/php phpweb.php
Log:
Added various verbosity levels
http://cvs.php.net/viewvc.cgi/phd/build.php?r1=1.35&r2=1.36&diff_format=u Index: phd/build.php diff -u phd/build.php:1.35 phd/build.php:1.36 --- phd/build.php:1.35 Sun Oct 21 11:57:20 2007 +++ phd/build.php Sun Oct 21 17:08:44 2007 @@ -1,6 +1,6 @@ #!@php_bin@ <?php -/* $Id: build.php,v 1.35 2007/10/21 11:57:20 bjori Exp $ */ +/* $Id: build.php,v 1.36 2007/10/21 17:08:44 bjori Exp $ */ function err($no, $str, $file, $line) { global $notify; @@ -43,7 +43,13 @@ require $ROOT. "/include/PhDFormat.class.php"; if ($OPTIONS["index"]) { + if ($OPTIONS["verbose"] & VERBOSE_INDEXING) { + v("Indexing...\n"); + } require $ROOT. "/mktoc.php"; + if ($OPTIONS["verbose"] & VERBOSE_INDEXING) { + v("Indexing done\n"); + } if ($err) { $mktoc = microtime(true); @@ -56,6 +62,9 @@ } foreach($OPTIONS["output_format"] as $output_format) { + if ($OPTIONS["verbose"] & VERBOSE_FORMAT_RENDERING) { + v("Starting %s rendering\n", $output_format); + } switch($output_format) { case "xhtml": $classname = "XHTMLPhDFormat"; @@ -70,6 +79,9 @@ $themes = $elementmaps = $textmaps = array(); foreach($OPTIONS["output_theme"][$output_format] as $theme => $array) { is_dir($ROOT. "/themes/$theme") or die("Can't find the '$theme' theme"); + if ($OPTIONS["verbose"] & VERBOSE_THEME_RENDERING) { + v("Using the %s theme (%s)\n", $theme, join(", ", $array)); + } /* Maybe other themes will need additional includes? */ switch($theme) { @@ -105,11 +117,18 @@ $textmaps[$themename] = $tmp; } } + } if (!empty($OPTIONS["render_ids"])) { + if ($OPTIONS["verbose"] & VERBOSE_RENDER_STYLE) { + v("Running partial build\n"); + } $reader = new PhDPartialReader($OPTIONS); } else { + if ($OPTIONS["verbose"] & VERBOSE_RENDER_STYLE) { + v("Running full build\n"); + } $reader = new PhDReader($OPTIONS); } @@ -255,6 +274,9 @@ } $reader->close(); + if ($OPTIONS["verbose"] & VERBOSE_FORMAT_RENDERING) { + v("Finished rendering\n"); + } if ($err) { $end = microtime(true); http://cvs.php.net/viewvc.cgi/phd/config.php?r1=1.5&r2=1.6&diff_format=u Index: phd/config.php diff -u phd/config.php:1.5 phd/config.php:1.6 --- phd/config.php:1.5 Sun Oct 21 11:58:53 2007 +++ phd/config.php Sun Oct 21 17:08:44 2007 @@ -1,5 +1,22 @@ <?php -/* Generated by PhD $Id: config.php,v 1.5 2007/10/21 11:58:53 bjori Exp $ at Thu, 09 Aug 2007 15:10:10 +0200. */ +function v($msg) { + $args = func_get_args(); + $args[0] = date($GLOBALS["OPTIONS"]["date_format"]); + vfprintf(STDERR, "[%s] $msg", $args); +} + +define('VERBOSE_INDEXING', 0x01); +define('VERBOSE_FORMAT_RENDERING', 0x02); +define('VERBOSE_THEME_RENDERING', 0x04); +define('VERBOSE_RENDER_STYLE', 0x08); +define('VERBOSE_PARTIAL_READING', 0x10); +define('VERBOSE_PARTIAL_CHILD_READING', 0x20); +define('VERBOSE_TOC_WRITING', 0x40); +define('VERBOSE_CHUNK_WRITING', 0x80); + +define('VERBOSE_ALL',VERBOSE_INDEXING|VERBOSE_FORMAT_RENDERING|VERBOSE_THEME_RENDERING|VERBOSE_RENDER_STYLE|VERBOSE_PARTIAL_READING|VERBOSE_PARTIAL_CHILD_READING|VERBOSE_TOC_WRITING|VERBOSE_CHUNK_WRITING); + +/* Generated by PhD $Id: config.php,v 1.6 2007/10/21 17:08:44 bjori Exp $ at Thu, 09 Aug 2007 15:10:10 +0200. */ $OPTIONS = array ( 'output_format' => array('xhtml'), @@ -20,6 +37,8 @@ 'compatibility_mode' => true, 'build_log_file' => 'none', 'debug' => true, + 'verbose' => VERBOSE_INDEXING|VERBOSE_FORMAT_RENDERING|VERBOSE_THEME_RENDERING|VERBOSE_RENDER_STYLE|VERBOSE_PARTIAL_READING|VERBOSE_TOC_WRITING, + 'date_format' => "H:i:s", 'render_ids' => array( /* "manual" => false, http://cvs.php.net/viewvc.cgi/phd/package.xml?r1=1.8&r2=1.9&diff_format=u Index: phd/package.xml diff -u phd/package.xml:1.8 phd/package.xml:1.9 --- phd/package.xml:1.8 Sun Oct 21 11:50:27 2007 +++ phd/package.xml Sun Oct 21 17:08:44 2007 @@ -25,6 +25,7 @@ <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD Style</license> <notes> - Added partial rendering + - Added various verbosity levels </notes> <contents> <dir baseinstalldir="phd" name="/"> http://cvs.php.net/viewvc.cgi/phd/include/PhDPartialReader.class.php?r1=1.1&r2=1.2&diff_format=u Index: phd/include/PhDPartialReader.class.php diff -u phd/include/PhDPartialReader.class.php:1.1 phd/include/PhDPartialReader.class.php:1.2 --- phd/include/PhDPartialReader.class.php:1.1 Sun Oct 21 11:42:33 2007 +++ phd/include/PhDPartialReader.class.php Sun Oct 21 17:08:44 2007 @@ -1,5 +1,5 @@ <?php -/* $Id: PhDPartialReader.class.php,v 1.1 2007/10/21 11:42:33 bjori Exp $ */ +/* $Id: PhDPartialReader.class.php,v 1.2 2007/10/21 17:08:44 bjori Exp $ */ class PhDPartialReader extends PhDReader { protected $partial = array(); @@ -28,15 +28,28 @@ $id = $this->getAttributeNs("id", PhDReader::XMLNS_XML); if (isset($this->partial[$id])) { if ($this->isChunk == PhDReader::CLOSE_CHUNK) { + if ($this->opts["verbose"] & VERBOSE_PARTIAL_READING) { + v("%s done\n", $id); + } unset($this->partial[$id]); --$seeked; $currently_reading = false; } else { + if ($this->opts["verbose"] & VERBOSE_PARTIAL_READING) { + v("Starting %s...\n", $id); + } $currently_reading = $id; ++$seeked; } return $ret; } elseif ($currently_reading && $this->partial[$currently_reading]) { + if ($this->opts["verbose"] & VERBOSE_PARTIAL_CHILD_READING) { + if ($this->isChunk == PhDReader::OPEN_CHUNK) { + v("Rendering child of %s, %s\n", $currently_reading, $id); + } else { + v("%s done\n", $id); + } + } return $ret; } else { $ignore = true; http://cvs.php.net/viewvc.cgi/phd/include/PhDReader.class.php?r1=1.11&r2=1.12&diff_format=u Index: phd/include/PhDReader.class.php diff -u phd/include/PhDReader.class.php:1.11 phd/include/PhDReader.class.php:1.12 --- phd/include/PhDReader.class.php:1.11 Sun Oct 21 11:57:43 2007 +++ phd/include/PhDReader.class.php Sun Oct 21 17:08:44 2007 @@ -1,5 +1,5 @@ <?php -/* $Id: PhDReader.class.php,v 1.11 2007/10/21 11:57:43 bjori Exp $ */ +/* $Id: PhDReader.class.php,v 1.12 2007/10/21 17:08:44 bjori Exp $ */ //6271 class PhDReader extends XMLReader { @@ -56,6 +56,7 @@ 'set' => true, 'setindex' => true, ); /* }}} */ + protected $opts = array(); public function __construct($opts, $encoding = "UTF-8", $xml_opts = NULL) { if (!XMLReader::open($opts["xml_file"], $encoding, $xml_opts)) { @@ -66,6 +67,7 @@ $this->CHUNK_ME[$el] = $v; } } + $this->opts = $opts; } public function notXPath($tag, $depth = 0) { http://cvs.php.net/viewvc.cgi/phd/themes/php/phpweb.php?r1=1.16&r2=1.17&diff_format=u Index: phd/themes/php/phpweb.php diff -u phd/themes/php/phpweb.php:1.16 phd/themes/php/phpweb.php:1.17 --- phd/themes/php/phpweb.php:1.16 Sun Oct 21 11:50:27 2007 +++ phd/themes/php/phpweb.php Sun Oct 21 17:08:44 2007 @@ -1,5 +1,5 @@ <?php -/* $Id: phpweb.php,v 1.16 2007/10/21 11:50:27 bjori Exp $ */ +/* $Id: phpweb.php,v 1.17 2007/10/21 17:08:44 bjori Exp $ */ class phpweb extends phpdotnet implements PhDTheme { protected $streams = array(); @@ -13,9 +13,13 @@ } public function writeChunk($id, $stream) { rewind($stream); - file_put_contents($this->ext."/$id.".$this->ext, $this->header($id)); - file_put_contents($this->ext."/$id.".$this->ext, $stream, FILE_APPEND); - file_put_contents($this->ext."/$id.".$this->ext, $this->footer($id), FILE_APPEND); + $filename = $this->ext."/$id.".$this->ext; + file_put_contents($filename, $this->header($id)); + file_put_contents($filename, $stream, FILE_APPEND); + file_put_contents($filename, $this->footer($id), FILE_APPEND); + if ($GLOBALS["OPTIONS"]["verbose"] & VERBOSE_CHUNK_WRITING) { + v("Wrote %s\n", $filename); + } } public function appendData($data, $isChunk) { switch($isChunk) { @@ -53,7 +57,6 @@ * section. */ if (!file_exists($filename)) { - echo "Creating $filename...\n"; foreach($siblings as $sid => $array) { $toc[] = array($sid.$ext, empty($array["sdesc"]) ? $array["ldesc"] : $array["sdesc"]); @@ -70,6 +73,10 @@ $PARENTS = ' . var_export($parents, true) . ';'; file_put_contents($filename, $content); + + if ($GLOBALS["OPTIONS"]["verbose"] & VERBOSE_TOC_WRITING) { + v("Wrote TOC (%s)\n", $filename); + } } $incl = 'include_once dirname(__FILE__) ."/toc/' .$parent. '.inc";';
http://cvs.php.net/viewvc.cgi/phd/build.php?r1=1.35&r2=1.36&diff_format=u Index: phd/build.php diff -u phd/build.php:1.35 phd/build.php:1.36 --- phd/build.php:1.35 Sun Oct 21 11:57:20 2007 +++ phd/build.php Sun Oct 21 17:08:44 2007 @@ -1,6 +1,6 @@ #!@php_bin@ <?php -/* $Id: build.php,v 1.35 2007/10/21 11:57:20 bjori Exp $ */ +/* $Id: build.php,v 1.36 2007/10/21 17:08:44 bjori Exp $ */ function err($no, $str, $file, $line) { global $notify; @@ -43,7 +43,13 @@ require $ROOT. "/include/PhDFormat.class.php"; if ($OPTIONS["index"]) { + if ($OPTIONS["verbose"] & VERBOSE_INDEXING) { + v("Indexing...\n"); + } require $ROOT. "/mktoc.php"; + if ($OPTIONS["verbose"] & VERBOSE_INDEXING) { + v("Indexing done\n"); + } if ($err) { $mktoc = microtime(true); @@ -56,6 +62,9 @@ } foreach($OPTIONS["output_format"] as $output_format) { + if ($OPTIONS["verbose"] & VERBOSE_FORMAT_RENDERING) { + v("Starting %s rendering\n", $output_format); + } switch($output_format) { case "xhtml": $classname = "XHTMLPhDFormat"; @@ -70,6 +79,9 @@ $themes = $elementmaps = $textmaps = array(); foreach($OPTIONS["output_theme"][$output_format] as $theme => $array) { is_dir($ROOT. "/themes/$theme") or die("Can't find the '$theme' theme"); + if ($OPTIONS["verbose"] & VERBOSE_THEME_RENDERING) { + v("Using the %s theme (%s)\n", $theme, join(", ", $array)); + } /* Maybe other themes will need additional includes? */ switch($theme) { @@ -105,11 +117,18 @@ $textmaps[$themename] = $tmp; } } + } if (!empty($OPTIONS["render_ids"])) { + if ($OPTIONS["verbose"] & VERBOSE_RENDER_STYLE) { + v("Running partial build\n"); + } $reader = new PhDPartialReader($OPTIONS); } else { + if ($OPTIONS["verbose"] & VERBOSE_RENDER_STYLE) { + v("Running full build\n"); + } $reader = new PhDReader($OPTIONS); } @@ -255,6 +274,9 @@ } $reader->close(); + if ($OPTIONS["verbose"] & VERBOSE_FORMAT_RENDERING) { + v("Finished rendering\n"); + } if ($err) { $end = microtime(true); http://cvs.php.net/viewvc.cgi/phd/config.php?r1=1.5&r2=1.6&diff_format=u Index: phd/config.php diff -u phd/config.php:1.5 phd/config.php:1.6 --- phd/config.php:1.5 Sun Oct 21 11:58:53 2007 +++ phd/config.php Sun Oct 21 17:08:44 2007 @@ -1,5 +1,22 @@ <?php -/* Generated by PhD $Id: config.php,v 1.5 2007/10/21 11:58:53 bjori Exp $ at Thu, 09 Aug 2007 15:10:10 +0200. */ +function v($msg) { + $args = func_get_args(); + $args[0] = date($GLOBALS["OPTIONS"]["date_format"]); + vfprintf(STDERR, "[%s] $msg", $args); +} + +define('VERBOSE_INDEXING', 0x01); +define('VERBOSE_FORMAT_RENDERING', 0x02); +define('VERBOSE_THEME_RENDERING', 0x04); +define('VERBOSE_RENDER_STYLE', 0x08); +define('VERBOSE_PARTIAL_READING', 0x10); +define('VERBOSE_PARTIAL_CHILD_READING', 0x20); +define('VERBOSE_TOC_WRITING', 0x40); +define('VERBOSE_CHUNK_WRITING', 0x80); + +define('VERBOSE_ALL',VERBOSE_INDEXING|VERBOSE_FORMAT_RENDERING|VERBOSE_THEME_RENDERING|VERBOSE_RENDER_STYLE|VERBOSE_PARTIAL_READING|VERBOSE_PARTIAL_CHILD_READING|VERBOSE_TOC_WRITING|VERBOSE_CHUNK_WRITING); + +/* Generated by PhD $Id: config.php,v 1.6 2007/10/21 17:08:44 bjori Exp $ at Thu, 09 Aug 2007 15:10:10 +0200. */ $OPTIONS = array ( 'output_format' => array('xhtml'), @@ -20,6 +37,8 @@ 'compatibility_mode' => true, 'build_log_file' => 'none', 'debug' => true, + 'verbose' => VERBOSE_INDEXING|VERBOSE_FORMAT_RENDERING|VERBOSE_THEME_RENDERING|VERBOSE_RENDER_STYLE|VERBOSE_PARTIAL_READING|VERBOSE_TOC_WRITING, + 'date_format' => "H:i:s", 'render_ids' => array( /* "manual" => false, http://cvs.php.net/viewvc.cgi/phd/package.xml?r1=1.8&r2=1.9&diff_format=u Index: phd/package.xml diff -u phd/package.xml:1.8 phd/package.xml:1.9 --- phd/package.xml:1.8 Sun Oct 21 11:50:27 2007 +++ phd/package.xml Sun Oct 21 17:08:44 2007 @@ -25,6 +25,7 @@ <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD Style</license> <notes> - Added partial rendering + - Added various verbosity levels </notes> <contents> <dir baseinstalldir="phd" name="/"> http://cvs.php.net/viewvc.cgi/phd/include/PhDPartialReader.class.php?r1=1.1&r2=1.2&diff_format=u Index: phd/include/PhDPartialReader.class.php diff -u phd/include/PhDPartialReader.class.php:1.1 phd/include/PhDPartialReader.class.php:1.2 --- phd/include/PhDPartialReader.class.php:1.1 Sun Oct 21 11:42:33 2007 +++ phd/include/PhDPartialReader.class.php Sun Oct 21 17:08:44 2007 @@ -1,5 +1,5 @@ <?php -/* $Id: PhDPartialReader.class.php,v 1.1 2007/10/21 11:42:33 bjori Exp $ */ +/* $Id: PhDPartialReader.class.php,v 1.2 2007/10/21 17:08:44 bjori Exp $ */ class PhDPartialReader extends PhDReader { protected $partial = array(); @@ -28,15 +28,28 @@ $id = $this->getAttributeNs("id", PhDReader::XMLNS_XML); if (isset($this->partial[$id])) { if ($this->isChunk == PhDReader::CLOSE_CHUNK) { + if ($this->opts["verbose"] & VERBOSE_PARTIAL_READING) { + v("%s done\n", $id); + } unset($this->partial[$id]); --$seeked; $currently_reading = false; } else { + if ($this->opts["verbose"] & VERBOSE_PARTIAL_READING) { + v("Starting %s...\n", $id); + } $currently_reading = $id; ++$seeked; } return $ret; } elseif ($currently_reading && $this->partial[$currently_reading]) { + if ($this->opts["verbose"] & VERBOSE_PARTIAL_CHILD_READING) { + if ($this->isChunk == PhDReader::OPEN_CHUNK) { + v("Rendering child of %s, %s\n", $currently_reading, $id); + } else { + v("%s done\n", $id); + } + } return $ret; } else { $ignore = true; http://cvs.php.net/viewvc.cgi/phd/include/PhDReader.class.php?r1=1.11&r2=1.12&diff_format=u Index: phd/include/PhDReader.class.php diff -u phd/include/PhDReader.class.php:1.11 phd/include/PhDReader.class.php:1.12 --- phd/include/PhDReader.class.php:1.11 Sun Oct 21 11:57:43 2007 +++ phd/include/PhDReader.class.php Sun Oct 21 17:08:44 2007 @@ -1,5 +1,5 @@ <?php -/* $Id: PhDReader.class.php,v 1.11 2007/10/21 11:57:43 bjori Exp $ */ +/* $Id: PhDReader.class.php,v 1.12 2007/10/21 17:08:44 bjori Exp $ */ //6271 class PhDReader extends XMLReader { @@ -56,6 +56,7 @@ 'set' => true, 'setindex' => true, ); /* }}} */ + protected $opts = array(); public function __construct($opts, $encoding = "UTF-8", $xml_opts = NULL) { if (!XMLReader::open($opts["xml_file"], $encoding, $xml_opts)) { @@ -66,6 +67,7 @@ $this->CHUNK_ME[$el] = $v; } } + $this->opts = $opts; } public function notXPath($tag, $depth = 0) { http://cvs.php.net/viewvc.cgi/phd/themes/php/phpweb.php?r1=1.16&r2=1.17&diff_format=u Index: phd/themes/php/phpweb.php diff -u phd/themes/php/phpweb.php:1.16 phd/themes/php/phpweb.php:1.17 --- phd/themes/php/phpweb.php:1.16 Sun Oct 21 11:50:27 2007 +++ phd/themes/php/phpweb.php Sun Oct 21 17:08:44 2007 @@ -1,5 +1,5 @@ <?php -/* $Id: phpweb.php,v 1.16 2007/10/21 11:50:27 bjori Exp $ */ +/* $Id: phpweb.php,v 1.17 2007/10/21 17:08:44 bjori Exp $ */ class phpweb extends phpdotnet implements PhDTheme { protected $streams = array(); @@ -13,9 +13,13 @@ } public function writeChunk($id, $stream) { rewind($stream); - file_put_contents($this->ext."/$id.".$this->ext, $this->header($id)); - file_put_contents($this->ext."/$id.".$this->ext, $stream, FILE_APPEND); - file_put_contents($this->ext."/$id.".$this->ext, $this->footer($id), FILE_APPEND); + $filename = $this->ext."/$id.".$this->ext; + file_put_contents($filename, $this->header($id)); + file_put_contents($filename, $stream, FILE_APPEND); + file_put_contents($filename, $this->footer($id), FILE_APPEND); + if ($GLOBALS["OPTIONS"]["verbose"] & VERBOSE_CHUNK_WRITING) { + v("Wrote %s\n", $filename); + } } public function appendData($data, $isChunk) { switch($isChunk) { @@ -53,7 +57,6 @@ * section. */ if (!file_exists($filename)) { - echo "Creating $filename...\n"; foreach($siblings as $sid => $array) { $toc[] = array($sid.$ext, empty($array["sdesc"]) ? $array["ldesc"] : $array["sdesc"]); @@ -70,6 +73,10 @@ $PARENTS = ' . var_export($parents, true) . ';'; file_put_contents($filename, $content); + + if ($GLOBALS["OPTIONS"]["verbose"] & VERBOSE_TOC_WRITING) { + v("Wrote TOC (%s)\n", $filename); + } } $incl = 'include_once dirname(__FILE__) ."/toc/' .$parent. '.inc";';