incubator-zeta-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject [zeta-commits] svn commit: r1035736 - /incubator/zetacomponents/website/var/scripts/highlight_source.php
Date Tue, 16 Nov 2010 18:40:30 GMT
Author: toby
Date: Tue Nov 16 18:40:30 2010
New Revision: 1035736

URL: http://svn.apache.org/viewvc?rev=1035736&view=rev
Log:
- Fixed: Make highlight source script scan all versions.

Modified:
    incubator/zetacomponents/website/var/scripts/highlight_source.php

Modified: incubator/zetacomponents/website/var/scripts/highlight_source.php
URL: http://svn.apache.org/viewvc/incubator/zetacomponents/website/var/scripts/highlight_source.php?rev=1035736&r1=1035735&r2=1035736&view=diff
==============================================================================
--- incubator/zetacomponents/website/var/scripts/highlight_source.php (original)
+++ incubator/zetacomponents/website/var/scripts/highlight_source.php Tue Nov 16 18:40:30
2010
@@ -1,56 +1,59 @@
 <?php
 
-if ( !isset( $argv[1] ) )
-{
-    die( "Missing doc version.\n" );
-}
+ini_set( 'highlight.string', '#335533' );
+ini_set( 'highlight.keyword', '#0000FF' );
+ini_set( 'highlight.default', '#000000' );
+ini_set( 'highlight.comment', '#007700' );
 
-$version = $argv[1];
 
-$docBase = dirname( __FILE__ ) . "/../../htdocs/documentation/";
-$docDir  = "{$docBase}/{$version}";
+$docBaseDir = dirname( __FILE__ ) . "/../../htdocs/documentation/";
+$docBaseUri = "/zetacomponents/documentation";
 
-if ( !file_exists( $docDir ) || !is_dir( $docDir ) )
+$versions = array();
+foreach ( glob( "{$docBaseDir}/*", GLOB_ONLYDIR ) as $dir )
 {
-    die( "Doc dir '{$docDir}' does not exist.\n" );
+    $version = basename( $dir );
+    if ( $version !== 'overview' )
+    {
+        $versions[] = $version;
+    }
 }
 
-$docUri = "/zetacomponents/documentation/{$version}";
+foreach ( $versions as $version )
+{
+    $docDir = "{$docBaseDir}/{$version}";
+    $docUri = "{$docBaseUri}/{$version}";
 
-ini_set( 'highlight.string', '#335533' );
-ini_set( 'highlight.keyword', '#0000FF' );
-ini_set( 'highlight.default', '#000000' );
-ini_set( 'highlight.comment', '#007700' );
+    $files = array_merge(
+        glob( "{$docDir}/*.html" ),
+        array_filter(
+            glob( "{$docDir}/*/*.html" ),
+            'isNotPhpDoc'
+        )
+    );
 
-$files = array_merge(
-    glob( "{$docDir}/*.html" ),
-    array_filter(
-        glob( "{$docDir}/*/*.html" ),
-        function ( $file )
+    foreach ( $files as $file )
+    {
+        // Extract component name
+        if ( preg_match( '(' . preg_quote( $docDir ) . '/([^\./]+))', $file, $matches ) <
1 )
         {
-            return strpos( $file, 'phpdoc' ) === false;
+            die( "Could not parse file name '{$file}'." );
         }
-    )
-);
+        $component = $matches[1];
 
-foreach ( $files as $file )
-{
-    if ( preg_match( '(' . preg_quote( $docDir ) . '/([^\./]+))', $file, $matches ) <
1 )
-    {
-        die( "Could not parse file name '{$file}'." );
-    }
-    $component = $matches[1];
+        $content = file_get_contents( $file );
 
-    $content = file_get_contents( $file );
-    $content = addExampleLineNumbers( $content );
-    $content = addLinks( $docUri, $component, $content );
+        $content = addExampleLineNumbers( $content );
+        $content = addLinks( $docUri, $component, $content );
 
-    file_put_contents( $file, $content );
+        file_put_contents( $file, $content );
+    }
 }
 
-/*
-$content = file_get_contents( $file );
-*/
+function isNotPhpDoc( $file )
+{
+    return strpos( $file, 'phpdoc' ) === false;
+}
 
 function addLinks( $docUri, $component, $output )
 {



Mime
View raw message