Author: Derick Rethans
Date: 2006-01-19 09:22:57 +0100 (Thu, 19 Jan 2006)
New Revision: 1966
Log:
- First version of tutorial renderer.
Added:
scripts/render-tutorial.php
Added: scripts/render-tutorial.php
===================================================================
--- scripts/render-tutorial.php 2006-01-18 14:48:15 UTC (rev 1965)
+++ scripts/render-tutorial.php 2006-01-19 08:22:57 UTC (rev 1966)
@@ -0,0 +1,62 @@
+<?php
+/**
+ * Load the base package to boot strap the autoloading
+ */
+require_once 'packages/Base/trunk/src/base.php';
+
+// {{{ __autoload()
+
+/**
+ * Autoload ezc classes
+ *
+ * @param string $class_name
+ */
+function __autoload( $class_name )
+{
+ if ( ezcBase::autoload( $class_name ) )
+ {
+ return;
+ }
+}
+
+// Setup console parameters
+$params = new ezcConsoleInput();
+$componentOption = new ezcConsoleOption( 'c', 'component',
ezcConsoleInput::TYPE_STRING );
+$componentOption->mandatory = true;
+$params->registerOption( $componentOption );
+
+// Process console parameters
+try
+{
+ $params->process();
+}
+catch ( ezcConsoleOptionException $e )
+{
+ die( $e->getMessage(). "\n" );
+}
+
+$component = $params->getOption( 'component' )->value;
+$output = getRstOutput( $component );
+$output = addLinks( $component, $output );
+
+file_put_contents( "/tmp/test.html", $output );
+
+function getRstOutput( $component )
+{
+ $fileName = "packages/$component/trunk/docs/tutorial.txt";
+ $output = shell_exec( "rst2html.py $fileName" );
+ return $output;
+}
+
+function addLinks( $component, $output )
+{
+ $base = "http://ez.no/doc/components/view/(file)/1.0rc1/$component/";
+
+ $output = preg_replace( '@(ezc[A-Z][a-zA-Z]+)::\$([A-Za-z0-9]+)@', "<a
href='{$base}\\1.html#\$\\2'>\\0</a>", $output );
+ $output = preg_replace( "@(ezc[A-Z][a-zA-Z]+)::([A-Z_]+)@", "<a
href='{$base}\\1.html#const\\2'>\\0</a>", $output );
+ $output = preg_replace( "@(ezc[A-Z][a-zA-Z]+)::([A-Za-z0-9]+)\(\)@",
"<a href='{$base}\\1.html#\\2'>\\0</a>", $output );
+ $output = preg_replace( "@(ezc[A-Z][a-zA-Z]+)->([A-Za-z0-9]+)\(\)@",
"<a href='{$base}\\1.html#\\2'>\\0</a>", $output );
+ $output = preg_replace( "@(?<![/>])(ezc[A-Z][a-zA-Z]+)@", "<a
href='{$base}\\1.html'>\\0</a>", $output );
+
+ return $output;
+}
Property changes on: scripts/render-tutorial.php
___________________________________________________________________
Name: svn:eol-style
+ native
--
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components