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: r1092601 - /incubator/zetacomponents/website/Pakefile
Date Fri, 15 Apr 2011 06:54:06 GMT
Author: jeromer
Date: Fri Apr 15 06:54:06 2011
New Revision: 1092601

URL: http://svn.apache.org/viewvc?rev=1092601&view=rev
Log:
- Added "tutorials" task

Modified:
    incubator/zetacomponents/website/Pakefile

Modified: incubator/zetacomponents/website/Pakefile
URL: http://svn.apache.org/viewvc/incubator/zetacomponents/website/Pakefile?rev=1092601&r1=1092600&r2=1092601&view=diff
==============================================================================
--- incubator/zetacomponents/website/Pakefile (original)
+++ incubator/zetacomponents/website/Pakefile Fri Apr 15 06:54:06 2011
@@ -91,6 +91,7 @@ function run_phpdoc( $task, $args )
 
     pake_echo_comment( 'Building PHPDoc for ' . $options['build.name'] );
 
+    // XXX: escape shell args
     $command = $options['php.path'] . ' -d "memory_limit=2500M" -d "xdebug.default_enable=0"
'
              . $options['phpdoc.path'] . ' '
              . '--directory ' . $options['zeta.base'] . ' '
@@ -135,8 +136,115 @@ function run_phpdoc( $task, $args )
     pake_remove_dir( $options['build.dir'] . '/phpdoc/' );
 }
 
+pake_desc( 'Copies tutorials for a given release to the website directory.' );
+pake_task( 'tutorials' );
+
+function run_tutorials()
+{
+    $tutorialRootDir = 'content/documentation';
+
+    $options = pakeYaml::loadFile( CONFIG_FILE );
+
+    $rule = pakeFinder::type('dir')->name('/docs/')
+                                   ->ignore_version_control()
+                                   ->relative()
+                                   ->maxdepth( 1 )
+                                   ->discard( '/tests/' );
+
+    $docDirs = $rule->in( $options['zeta.base'] );
+
+    $token = $options['zeta.base'];
+
+    // Windows handles '/' just fine
+    // however the trailing '/' or '\' can come from the config file
+    // so a windows user will most likely write '\' instead of '/'
+    if( substr( $options['zeta.base'], -1 ) != DIRECTORY_SEPARATOR )
+    {
+        $token = $options['zeta.base'] . '/';
+    }
+
+    foreach( $docDirs as $docDir )
+    {
+        $localPath = str_replace( $token, '', $docDir );
+        $component = substr( $localPath, 0, strpos( $localPath, '/' ) );
+
+        $target = "${tutorialRootDir}/" . $options['build.name'] . "/${component}";
+
+        pake_mkdirs( $target, 0755 );
+
+        pake_mirror(
+            pakeFinder::type('any')->name('*')
+                                   ->ignore_version_control(),
+            $options['zeta.base'] . "/${docDir}",
+            $target
+        );
+    }
+
+    gen_tutorial_index_file( $tutorialRootDir );
+}
+
 /* ------ "Private" functions ----------- */
 
+function gen_tutorial_index_file( $tutorialRootDir )
+{
+    pake_echo_comment( "Generating index files" );
+
+    $rule = pakeFinder::type('dir')->name( '*' )
+                                   ->maxdepth( 0 );
+
+    $options = pakeYaml::loadFile( CONFIG_FILE );
+    $components = $rule->in( "${tutorialRootDir}/" . $options['build.name'] );
+
+    foreach( $components as $component )
+    {
+        // no way to use DOM for such a simple XML
+        $xmlContents = '<?xml version="1.0" encoding="utf-8"?>';
+        $xmlContents .= "<index>";
+
+        if( file_exists( "${component}/tutorial.txt" ) )
+        {
+            $xmlContents .= '<site index="true"><name>Tutorial</name><path>tutorial.txt</path></site>';
+        }
+
+        $xmlContents .= '<directory><name>API</name><path>phpdoc/</path></directory>';
+
+        $tutorialRule = pakeFinder::type( 'file' )->name( '*.txt' )
+                                                  ->relative()
+                                                  ->maxdepth( 0 )
+                                                  ->discard( 'tutorial.txt' );
+
+        $tutorialFiles = $tutorialRule->in( $component );
+
+        foreach( $tutorialFiles as $tutorialFile )
+        {
+            $tutorialName = ucfirst( str_replace( '.txt', '', $tutorialFile) );
+            $xmlContents .= "<site><name>${tutorialName}</name><path>${tutorialFile}</path></site>";
+        }
+
+        $tutorialRule = pakeFinder::type( 'dir' )->name( '*' )
+                                                 ->relative()
+                                                 ->maxdepth( 0 )
+                                                 ->discard(
+                                                     'design', 'phpdoc', 'tutorial', 'functions'
+                                                 );
+
+        $tutorialDirs = $tutorialRule->in( $component );
+
+        foreach( $tutorialDirs as $tutorialDir )
+        {
+            $xmlContents .= '<directory display="false"><name>'
+                            . ucfirst( $tutorialDir ). '</name><path>'
+                            . $tutorialDir . '/</path></directory>';
+        }
+
+        $xmlContents .= "</index>";
+
+        pake_write_file(
+            "${component}/.index.xml", $xmlContents, $overwrite = true
+        );
+    }
+}
+
 /**
  * Defines the path to the config file
  *



Mime
View raw message