incubator-zeta-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jero...@apache.org
Subject [zeta-commits] svn commit: r1094239 - /incubator/zetacomponents/website/Pakefile
Date Mon, 18 Apr 2011 06:04:56 GMT
Author: jeromer
Date: Mon Apr 18 06:04:56 2011
New Revision: 1094239

URL: http://svn.apache.org/viewvc?rev=1094239&view=rev
Log:
- Added write_indexxml()

Modified:
    incubator/zetacomponents/website/Pakefile

Modified: incubator/zetacomponents/website/Pakefile
URL: http://svn.apache.org/viewvc/incubator/zetacomponents/website/Pakefile?rev=1094239&r1=1094238&r2=1094239&view=diff
==============================================================================
--- incubator/zetacomponents/website/Pakefile (original)
+++ incubator/zetacomponents/website/Pakefile Mon Apr 18 06:04:56 2011
@@ -2,7 +2,6 @@
 
 /**
  * TODO:
- * - add a function to generate xml files
  * - handle command line arguments
  * - add more constants to handle recurrent paths
  */
@@ -258,8 +257,7 @@ function run_extractphpdoc( $task, $args
              '/zetacomponents/documentation/' . $options['build.name'] . '/\2/phpdoc/',
         );
 
-        $xmlContents = '<?xml version="1.0" encoding="utf-8"?>';
-        $xmlContents .= '<index>';
+        $xmlContents  = '';
         $xmlContents .= '<site index="true"><name>Class tree</name><path>classtrees.html</path></site>';
 
         // pake_replace_regexp is not distributed yet
@@ -286,11 +284,7 @@ function run_extractphpdoc( $task, $args
             }
         }
 
-        $xmlContents .= '</index>';
-
-        pake_write_file(
-            "${phpDocComponentDir}/.index.xml", $xmlContents, $overwrite = true
-        );
+        write_indexxml( $xmlContents,  "${phpDocComponentDir}/.index.xml" );
     }
 }
 
@@ -355,6 +349,26 @@ function run_docs( $task, $args )
 /* ------ "Private" functions ----------- */
 
 /**
+ * Writes an index.xml file
+ *
+ * @param string $xmlContents
+ * @param string $xmlFile
+ * @access public
+ * @return void
+ */
+function write_indexxml( $xmlContents, $xmlFile )
+{
+    $finalContents  = '<?xml version="1.0" encoding="utf-8"?>';
+    $finalContents .= '<index>';
+    $finalContents .= $xmlContents;
+    $finalContents .= '</index>';
+
+    pake_write_file(
+        $xmlFile, $finalContents, $overwrite = true
+    );
+}
+
+/**
  * Generates .index.xml files for tutorials
  *
  * @param string $tutorialRootDir
@@ -373,9 +387,7 @@ function gen_tutorial_index_file( $tutor
 
     foreach( $components as $component )
     {
-        // no way to use DOM for such a simple XML
-        $xmlContents = '<?xml version="1.0" encoding="utf-8"?>';
-        $xmlContents .= "<index>";
+        $xmlContents = '';
 
         if( file_exists( "${component}/tutorial.txt" ) )
         {
@@ -413,11 +425,7 @@ function gen_tutorial_index_file( $tutor
                             . $tutorialDir . '/</path></directory>';
         }
 
-        $xmlContents .= "</index>";
-
-        pake_write_file(
-            "${component}/.index.xml", $xmlContents, $overwrite = true
-        );
+        write_indexxml( $xmlContents,  "${component}/.index.xml" );
     }
 }
 



Mime
View raw message