svn: /phd/trunk/ phpdotnet/phd/BuildOptionsParser.php phpdotnet/phd/Config.php phpdotnet/phd/Format/Factory.php render.php
| From: | Hannes Magnusson | Date: | Fri, 31 Jul 2009 12:35:28 +0000 |
| Subject: | svn: /phd/trunk/ phpdotnet/phd/BuildOptionsParser.php phpdotnet/phd/Config.php phpdotnet/phd/Format/Factory.php render.php | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-4583@lists.php.net to get a copy of this message | ||
bjori Fri, 31 Jul 2009 12:35:28 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=286593
Log:
Allow rendering multiple packages in one go
Changed paths:
U phd/trunk/phpdotnet/phd/BuildOptionsParser.php
U phd/trunk/phpdotnet/phd/Config.php
U phd/trunk/phpdotnet/phd/Format/Factory.php
U phd/trunk/render.php
Modified: phd/trunk/phpdotnet/phd/BuildOptionsParser.php
===================================================================
--- phd/trunk/phpdotnet/phd/BuildOptionsParser.php 2009-07-31 12:21:15 UTC (rev 286592)
+++ phd/trunk/phpdotnet/phd/BuildOptionsParser.php 2009-07-31 12:35:28 UTC (rev 286593)
@@ -121,11 +121,12 @@
public function option_package($k, $v) {
- if (in_array($v, Config::getSupportedPackages())) {
- Config::set_package($v);
- } else {
- trigger_error("Invalid Package", E_USER_ERROR);
+ foreach((array)$v as $package) {
+ if (!in_array($package, Config::getSupportedPackages())) {
+ trigger_error("Invalid Package", E_USER_ERROR);
+ }
}
+ Config::set_package($v);
}
public function option_s($k, $v)
Modified: phd/trunk/phpdotnet/phd/Config.php
===================================================================
--- phd/trunk/phpdotnet/phd/Config.php 2009-07-31 12:21:15 UTC (rev 286592)
+++ phd/trunk/phpdotnet/phd/Config.php 2009-07-31 12:35:28 UTC (rev 286593)
@@ -33,7 +33,9 @@
'phd_info_output' => NULL,
'phd_info_color' => "01;32",
'highlighter' => "phpdotnet\\phd\\Highlighter",
- 'package' => 'Default',
+ "package" => array(
+ "Default",
+ ),
);
public static function init(array $a) {
Modified: phd/trunk/phpdotnet/phd/Format/Factory.php
===================================================================
--- phd/trunk/phpdotnet/phd/Format/Factory.php 2009-07-31 12:21:15 UTC (rev 286592)
+++ phd/trunk/phpdotnet/phd/Format/Factory.php 2009-07-31 12:35:28 UTC (rev 286593)
@@ -37,11 +37,11 @@
trigger_error("This format is not supported by this package", E_USER_ERROR);
}
- public static final function createFactory($package = null) {
+ public static final function createFactory($package) {
static $factories = array();
- if ($package === null) {
- $package = Config::package();
+ if (!is_string($package)) {
+ throw new \Exception("Package name must be string..");
}
if (!isset($factories[$package])) {
Modified: phd/trunk/render.php
===================================================================
--- phd/trunk/render.php 2009-07-31 12:21:15 UTC (rev 286592)
+++ phd/trunk/render.php 2009-07-31 12:35:28 UTC (rev 286593)
@@ -41,35 +41,38 @@
$render = new Render();
$reader = new Reader();
-$factory = Format_Factory::createFactory();
-// Indexing & registering formats
-foreach(range(0, 0) as $i) {
- if (Index::requireIndexing()) {
- v("Indexing...", VERBOSE_INDEXING);
- // Create indexer
- $format = $render->attach(new Index);
+// Indexing
+if (Index::requireIndexing()) {
+ v("Indexing...", VERBOSE_INDEXING);
+ // Create indexer
+ $format = $render->attach(new Index);
- $reader->open(Config::xml_file());
- $render->render($reader);
+ $reader->open(Config::xml_file());
+ $render->render($reader);
- $render->detach($format);
+ $render->detach($format);
- v("Indexing done", VERBOSE_INDEXING);
- } else {
- v("Skipping indexing", VERBOSE_INDEXING);
- }
+ v("Indexing done", VERBOSE_INDEXING);
+} else {
+ v("Skipping indexing", VERBOSE_INDEXING);
+}
+foreach((array)Config::package() as $package) {
+ $factory = Format_Factory::createFactory($package);
+
+ // Default to all output formats specified by the package
if (count(Config::output_format()) == 0) {
- Config::set_output_format($factory->getOutputFormats());
+ Config::set_output_format((array)$factory->getOutputFormats());
}
+ // Register the formats
foreach (Config::output_format() as $format) {
$render->attach($factory->createFormat($format));
}
}
-// Rendering formats
+// Render formats
foreach(range(0, 0) as $i) {
$reader->open(Config::xml_file());
foreach($render as $format) {