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: r1093942 - /incubator/zetacomponents/website/Pakefile
Date Sat, 16 Apr 2011 07:29:26 GMT
Author: jeromer
Date: Sat Apr 16 07:29:26 2011
New Revision: 1093942

URL: http://svn.apache.org/viewvc?rev=1093942&view=rev
Log:
- Added "extractphpdoc" task
# I did not have time to test it deeply
# If anyone could try it and provide feedback on zeta-dev
# that would be great :)

Modified:
    incubator/zetacomponents/website/Pakefile

Modified: incubator/zetacomponents/website/Pakefile
URL: http://svn.apache.org/viewvc/incubator/zetacomponents/website/Pakefile?rev=1093942&r1=1093941&r2=1093942&view=diff
==============================================================================
--- incubator/zetacomponents/website/Pakefile (original)
+++ incubator/zetacomponents/website/Pakefile Sat Apr 16 07:29:26 2011
@@ -192,6 +192,101 @@ function run_tutorials( $task, $args )
     gen_tutorial_index_file( $tutorialRootDir );
 }
 
+
+pake_desc(
+    'Extract API documentation from archive and copy it to the correct location in the content
tree.'
+);
+pake_task( 'extractphpdoc', 'tutorials' );
+
+/**
+ * Extracts PHPDoc files in .index.xml
+ *
+ * This task is dependent of the "tutorials" task
+ *
+ * @param pakeTask $task
+ * @param array $args
+ * @access public
+ * @return void
+ */
+function run_extractphpdoc( $task, $args )
+{
+    $options = pakeYaml::loadFile( CONFIG_FILE );
+    $tarballRootDir = 'content/documentation/' . $options['build.name'];
+    $phpDocRootDir = "${tarballRootDir}/phpdoc";
+
+    pake_echo_comment( 'Extracting tarball' );
+
+    $tarball = ezcArchive::open(
+        "compress.bzip2://${tarballRootDir}/phpdoc.tar.bz2",
+        ezcArchive::TAR_USTAR
+    );
+    $tarball->extract( $tarballRootDir );
+
+    $rule = pakeFinder::type('dir')->name( '*' )
+                                   ->discard( 'phpdoc','design', 'Framework' )
+                                   ->maxdepth( 0 );
+
+    $components = $rule->in( $tarballRootDir );
+    sort( $components );
+
+    foreach( $components as $component )
+    {
+        $componentName = basename( $component );
+        pake_echo_comment( "Copy API docs for ${component}" );
+
+        $rule = pakeFinder::type('any')->name('*');
+
+        pake_remove( $rule, "${component}/phpdoc" );
+        pake_mkdirs( "${component}/phpdoc" );
+        $phpDocComponentDir = "${component}/phpdoc";
+
+        pake_mirror(
+            $rule, "${phpDocRootDir}/${componentName}", $phpDocComponentDir
+        );
+
+        $patterns = array( "#../#", '#"(\.\./)?([a-zA-Z]*)"#');
+
+        $replacements = array(
+             "${componentName}/",
+             '/zetacomponents/documentation/' . $options['build.name'] . '/\2/phpdoc/',
+        );
+
+        $xmlContents = '<?xml version="1.0" encoding="utf-8"?>';
+        $xmlContents .= '<index>';
+        $xmlContents .= '<site index="true"><name>Class tree</name><path>classtrees.html</path></site>';
+
+        // pake_replace_regexp is not distributed yet
+        $rule = pakeFinder::type( 'file' )->name( '*.html' )->maxdepth( 0 );
+        $phpDocFiles = $rule->in( $phpDocComponentDir );
+        foreach( $phpDocFiles as $phpDocFile )
+        {
+            pake_echo_action('tokens', $phpDocFile );
+
+            file_put_contents(
+                $phpDocFile,
+                preg_replace(
+                    $patterns,
+                    $replacements,
+                    pake_read_file( $phpDocFile )
+                )
+            );
+
+            $docFilename = basename( $phpDocFile );
+            // classtress.html is already handled above
+            if( $docFilename != 'classtrees.html' )
+            {
+                $xmlContents .= '<site display="false"><name>'.$docFilename.'</name><path>'.$docFilename.'</path></site>';
+            }
+        }
+
+        $xmlContents .= '</index>';
+
+        pake_write_file(
+            "${phpDocComponentDir}/.index.xml", $xmlContents, $overwrite = true
+        );
+    }
+}
+
 /* ------ "Private" functions ----------- */
 
 function gen_tutorial_index_file( $tutorialRootDir )



Mime
View raw message