Author: Derick Rethans
Date: 2006-01-19 10:07:28 +0100 (Thu, 19 Jan 2006)
New Revision: 1971

Log:
- More doc generation scripts

Modified:
   scripts/build-docs.sh
   scripts/render-tutorial.php

Modified: scripts/build-docs.sh
===================================================================
--- scripts/build-docs.sh       2006-01-19 09:05:07 UTC (rev 1970)
+++ scripts/build-docs.sh       2006-01-19 09:07:28 UTC (rev 1971)
@@ -8,5 +8,14 @@
 rm -rf /home/httpd/html/components/phpdoc_gen || exit 6
 rm -rf /home/httpd/html/components/cdocs.tgz || exit 7
 /usr/local/bin/phpdoc -c ezcomponents.ini | grep -v Ignored || exit 8
-cd /home/httpd/html/components || exit 9
-tar -czf cdocs.tgz phpdoc_gen || exit 10
+cd packages
+echo "Generating Tutorials:"
+for i in *; do
+       if test -f $i/trunk/docs/tutorial.txt; then
+               echo "* $i"
+               php ../scripts/render-tutorial.php -c $i -t 
/home/httpd/html/components/phpdoc_gen/ezcomponents/1.0rc1
+       fi
+done
+cd ..
+cd /home/httpd/html/components || exit 10
+tar -czf cdocs.tgz phpdoc_gen || exit 11

Modified: scripts/render-tutorial.php
===================================================================
--- scripts/render-tutorial.php 2006-01-19 09:05:07 UTC (rev 1970)
+++ scripts/render-tutorial.php 2006-01-19 09:07:28 UTC (rev 1971)
@@ -2,7 +2,7 @@
 /**
  * Load the base package to boot strap the autoloading
  */
-require_once 'packages/Base/trunk/src/base.php';
+require_once 'Base/trunk/src/base.php';
 
 // {{{ __autoload()
 
@@ -25,6 +25,10 @@
 $componentOption->mandatory = true;
 $params->registerOption( $componentOption );
 
+$targetOption = new ezcConsoleOption( 't', 'target', 
ezcConsoleInput::TYPE_STRING );
+$targetOption->mandatory = true;
+$params->registerOption( $targetOption );
+
 // Process console parameters
 try
 {
@@ -37,17 +41,44 @@
 
 $component = $params->getOption( 'component' )->value;
 $output = getRstOutput( $component );
+$output = removeHeaderFooter( $output );
+$output = addNewHeader( $component, $output );
 $output = addLinks( $component, $output );
 
-file_put_contents( "/tmp/test.html", $output );
+$targetDir = $params->getOption( 'target' )->value;
+file_put_contents( "$targetDir/introduction_$component.html", $output );
 
 function getRstOutput( $component )
 {
-       $fileName = "packages/$component/trunk/docs/tutorial.txt";
-       $output = shell_exec( "rst2html.py $fileName" );
+       $fileName = "$component/trunk/docs/tutorial.txt";
+       $output = shell_exec( "rst2html $fileName" );
        return $output;
 }
 
+function removeHeaderFooter( $output )
+{
+    $output = preg_replace( '@.*?<body>@ms', '', $output );
+    $output = preg_replace( '@<h1 class="title">eZ components - 
[A-Za-z]+</h1>@', '', $output );
+    $output = preg_replace( '@<\/body>[EMAIL PROTECTED]', '', $output );
+    return $output;
+}
+
+function addNewHeader( $component, $output )
+{
+    $outputHeader = <<<FOO
+<div class="attribute-heading"><h1>$component</h1></div>
+
+
+<b>[ <a href="introduction_$component.html" class="menu">Introduction</a> ]</b>
+<b>[ <a href="classtrees_$component.html" class="menu">Class tree</a> ]</b>
+<b>[ <a href="elementindex_$component.html" class="menu">Element index</a> 
]</b>
+<b>[ <a href="elementindex.html" class="menu">All elements</a> ]</b>
+<h2>Introduction for Component $component</h2>
+<hr class="separator" />
+FOO;
+    return $outputHeader . $output;
+}
+
 function addLinks( $component, $output )
 {
        $base = "http://ez.no/doc/components/view/(file)/1.0rc1/$component/";

-- 
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to