cvs: peardoc / configure.php

[email protected] ("Christian Weiske")
Newsgroups php.pear.doc
Message-ID <cvscweiske1234247225@cvsserver>
cweiske		Tue Feb 10 06:27:05 2009 UTC

  Modified files:              
    /peardoc	configure.php 
  Log:
  Make input file configurable
  
  
http://cvs.php.net/viewvc.cgi/peardoc/configure.php?r1=1.9&r2=1.10&diff_format=u
Index: peardoc/configure.php
diff -u peardoc/configure.php:1.9 peardoc/configure.php:1.10
--- peardoc/configure.php:1.9	Wed Jan 28 22:43:49 2009
+++ peardoc/configure.php	Tue Feb 10 06:27:05 2009
@@ -14,6 +14,13 @@
 $opts = parseArgs();
 $GLOBALS['display_verbose'] = $opts['verbose'];
 $GLOBALS['errorcode']       = 0;
+if (empty($opts['manual_file'])) {
+    $opts['manual_file'] = 'manual.xml';
+}
+if (empty($opts['giant_file'])) {
+    $opts['giant_file'] = '.' . $opts['manual_file'];
+}
+
 try {
     createVersionEnt('entities/version.ent');
     createChaptersEnt(
@@ -21,7 +28,10 @@
         $opts['use_broken_translation_filename']
             ? $opts['broken_translation_filename'] : null
     );
-    createGiant($opts['giant_file'], $opts['validate'], $opts['hide_xml_errors']);
+    createGiant(
+        $opts['manual_file'], $opts['giant_file'],
+        $opts['validate'], $opts['hide_xml_errors']
+    );
     logMsg('Now call phd:');
     logMsg(' phd -f xhtml -t pearchunkedhtml'
         . ' -o build/' . $opts['language']
@@ -47,7 +57,7 @@
     require_once 'Console/CommandLine.php';
     $parser = new Console_CommandLine(array(
         'description' => 'configure the pear manual build',
-        'version'     => '$Id: configure.php,v 1.9 2009/01/28 22:43:49 cweiske Exp $'
+        'version'     => '$Id: configure.php,v 1.10 2009/02/10 06:27:05 cweiske Exp $'
     ));
 
     $parser->addOption('verbose', array(
@@ -69,7 +79,7 @@
         'long_name'   => '--output',
         'action'      => 'StoreString',
         'description' => 'File name of merged (giant) manual',
-        'default'     => '.manual.xml'
+        'default'     => null
     ));
     $parser->addOption('display_untranslated', array(
         'long_name'   => '--no-display-untranslated',
@@ -96,6 +106,11 @@
         'description' => 'Do not hide xml errors',
         'default'     => true
     ));
+    $parser->addArgument('manual_file', array(
+        'description' => 'xml manual file',
+        'optional'    => true,
+        'help_name'   => 'docbook file'
+    ));
 
     //language directories like "en" and "pt_BR"
     $langs = glob('??{,_??}', GLOB_ONLYDIR | GLOB_BRACE);
@@ -111,7 +126,7 @@
 
     try {
         $result = $parser->parse();
-        return $result->options;
+        return array_merge($result->options, $result->args);
     } catch (Exception $exc) {
         $parser->displayError($exc->getMessage());
         exit(-2);
@@ -229,6 +244,7 @@
 * Create one giant xml file by incluing every entity into manual.xml
 * and saving it as .manual.xml
 *
+* @param string  $strManual   Name of source docbook xml file
 * @param string  $strGiant    Name of merged (giant) xml file
 * @param boolean $bValidate   If the generated manual shall be validated
 * @param boolean $bHideErrors If errors loading and validating the manual shall
@@ -238,8 +254,10 @@
 *
 * @return void
 */
-function createGiant($strGiant = '.manual.xml', $bValidate = false, $bHideErrors = true)
-{
+function createGiant(
+    $strManual = 'manual.xml', $strGiant = '.manual.xml',
+    $bValidate = false, $bHideErrors = true
+) {
     logMsg('Loading manual into one giant file');
     $dom = new DOMDocument();
     $dom->formatOutput = false;
@@ -247,7 +265,7 @@
     if ($bHideErrors) {
         ob_start();
     }
-    $bLoaded = $dom->load('manual.xml', LIBXML_NOENT);
+    $bLoaded = $dom->load($strManual, LIBXML_NOENT);
     if ($bHideErrors) {
         $msg = ob_get_clean();
         if ($msg) {
@@ -274,8 +292,8 @@
     }
     if (!$bValid) {
         logMsg('  Manual has errors. Use');
-        logMsg('   xmllint --valid --noout manual.xml');
-        logMsg('   xmllint --valid --noout .manual.xml');
+        logMsg('   xmllint --valid --noout ' . $strManual);
+        logMsg('   xmllint --valid --noout ' . $strGiant);
         logMsg('  to get detailled error messages.');
         $GLOBALS['errorcode'] = 5;
     }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.