Index: raydoc.php
===================================================================
--- raydoc.php	(revision 0)
+++ raydoc.php	(revision 1)
@@ -0,0 +1,256 @@
+#!/usr/bin/php
+<?
+
+// This script generates a Wiki(ni) style documentation from comments of
+// all header files of Raydium (raydium/header/*.h)
+
+$page="http://raydium.yoopla.org/wiki/RaydiumApiReference";
+
+$intro="
+======Raydium API Reference======
+
+=====CQFD Corp.=====
+
+This document is the most up-to-date version. **This is a work in progress**:
+only the core of Raydium is described here, and there's again some 
+errors and wrong informations. Try, wait, or contribute ;)
+
+\"\"<a href=$page#index>Index of all Raydium functions</a>\"\"
+
+----
+This document is autogenerated, any change will be lost,
+use RaydiumApiReferenceComments for any need.
+{DATE}, for Raydium **{VERSION}**
+----
+";
+
+
+
+function getTagLine($tag,$lines,$from=0)
+{
+for($i=$from;$i<count($lines);$i++)
+    {
+    $l=$lines[$i];
+    if(substr(trim($l),0,strlen($tag))==$tag)
+	return $i;
+    }
+return -1;
+}
+
+function getVersion()
+{
+$file="../main.c";
+$f=file($file);
+$l=getTagLine("char *raydium_version",$f);
+$v=explode('"',trim($f[$l]));
+return $v[1];
+}
+
+function getMain($filename,$offset)
+{
+$f=file($filename);
+$l=getTagLine("/*=",$f);
+if($l==-1)
+    return -1;
+$res=trim($f[$l+$offset]);
+return $res;
+}
+
+function getPriority($filename)
+{
+$res=trim(getMain($filename,2));
+if(is_numeric($res))
+    return $res;
+else
+    return -1;
+}
+
+function getTitle($filename)
+{
+return trim(getMain($filename,1));
+}
+
+
+
+function getHeaders($directory)
+{
+$res=array();
+if (is_dir($directory)) 
+    {
+	if ($dh = opendir($directory)) 
+	{
+	    while (($file = readdir($dh)) !== false) 
+	    {
+		if(substr($file,-2)==".h")
+		{
+		    $res[]=$file;
+		}
+	    }
+	closedir($dh);
+	}
+    }
+    else echo "'$directory' is not a directory";
+return $res;
+}
+
+
+function h1($str)
+{
+echo "\n=====$str:=====\n";
+}
+
+function h2($str)
+{
+echo "====$str:====\n";
+}
+
+function body($str)
+{
+echo $str."\n\n";
+}
+
+function intro($str)
+{
+$str=str_replace("{DATE}","Generated: ".date("Y-m-d H:i:s"),$str);
+$str=str_replace("{VERSION}",getVersion(),$str);
+echo $str;
+}
+
+$index=array();
+function addToIndex($f)
+{
+static $i=0;
+global $index;
+
+$p=strpos($f,"raydium_");
+if($p!==false)
+    $f=substr($f,$p);
+
+$index[$i]=$f."|$i";
+return $i++;
+}
+
+// Main
+
+$files=getHeaders(".");
+//var_dump($files);
+if($files==-1)
+    die("No header found");
+
+unset($sorted);
+for($i=0;$i<count($files);$i++)
+    {
+    $file=$files[$i];
+    $p=getPriority($file);
+    if($p==-1)
+	$p=999000+$i;
+	
+    while(isset($sorted[$p]))
+	$p++;
+    $sorted[$p]=$file;
+    }
+ksort($sorted);
+$sorted=array_values($sorted);
+//var_dump($sorted);
+
+// Files are sorted, now
+
+intro($intro);
+
+for($i=0;$i<count($sorted);$i++)
+    {
+    $file=$sorted[$i];
+    $title=getTitle($file);
+
+    if($title==-1) 
+	{
+	h1(($i+1)." no documentation for $file");
+	continue;
+	}
+    
+    h1(($i+1)." $title");
+    
+    $f=file($file);
+    $last=0;
+    $n=0;
+    while(($l=getTagLine("/**",$f,$last))!=-1)
+	{
+	$title=trim($f[$l-1]);
+	if($title=="")
+	    $title="// unknown item";
+	    
+	// types:
+	// 1 - Comment (//)
+	// 2 - Macro (#)
+	// 3 - Code (...)
+	$type=3;
+	if($title[0]=="/")
+	    {
+	    $type=1;
+	    $title=trim(substr($title,2));
+	    }
+
+	if($title[0]=="#")
+	    {
+	    $type=2;
+	    $pos=strpos($title,")");
+	    if($pos)
+		{
+		$title=substr($title,0,$pos+1);
+		}
+	    $title=trim(str_replace("#define ","",$title))." (macro)";
+	    
+	    }
+
+	if($type==3)
+	    {
+	    if(substr($title,0,7)=="extern ")
+		$title=trim(substr($title,7));
+	    if($title[strlen($title)-1]==";")
+		$title=substr($title,0,-1);
+	    $title=trim(str_replace("**","* *",$title));
+	    }
+	
+	if($type==2 || $type==3)
+	    $id=addToIndex($title);
+	
+	h2('""'."<a name=$id></a>".'""'.($i+1).".".($n+1)." $title");
+	
+	$last=$l+1;
+	$end=getTagLine("**/",$f,$last);
+	if($end==-1)
+	    die("expected '**/' (started line $l)");
+	
+	unset($body);
+/*	for($j=$l+1;$j<$end;$j++)
+	    {
+	    $lj=trim($f[$j]);
+	    if($lj=="") 
+		$lj="\n\n";
+	    else
+		$lj.=" ";
+	    $body[]=$lj;
+	    }
+	$str=implode("",$body);*/
+	for($j=$l+1;$j<$end;$j++)
+	    {
+	    $lj=trim($f[$j]);
+	    $body[]=$lj;
+	    }
+	$str=@implode("\n",$body);
+	body($str);
+	
+	$last=$end+1;
+	$n++;
+	}
+    }
+
+sort($index);
+h1('""<a name=index></a>""Index');
+for($i=0;$i<count($index);$i++)
+    {
+    $j=explode("|",$index[$i]);
+    $k=$j[0];
+    $l=$j[1];
+    echo '""'."<a href=$page#$l><tt>$k</tt></a>".'""'."\n";
+    }

Property changes on: raydoc.php
___________________________________________________________________
Added: svn:executable
\ No newline at end of property