cvs: php-gtk-doc /scripts .cvsignore cleanup.sh copy_images.php distribute_html.php gen_chapterents.php gen_docs_from_source.sh gen_manual.sh
gen_manualxml.php gen_name_to_id.xsl genchapterents.php.in highlight.php manual.xml.in merge_updates.php mtoc.xml.in testclasses.xml.in
testmanual.xml.in
| From: | Steph Fox | Date: | Sun, 26 Mar 2006 02:44:13 +0000 |
| Subject: | cvs: php-gtk-doc /scripts .cvsignore cleanup.sh copy_images.php distribute_html.php gen_chapterents.php gen_docs_from_source.sh gen_manual.sh gen_manualxml.php gen_name_to_id.xsl genchapterents.php.in highlight.php manual.xml.in merge_updates.php mtoc.xml.in testclasses.xml.in testmanual.xml.in |
||
| Groups: | php.gtk.doc | ||
| Request: | Send a blank email to php-gtk-doc+get-1966@lists.php.net to get a copy of this message | ||
sfox Sun Mar 26 02:44:13 2006 UTC
Added files:
/php-gtk-doc/scripts cleanup.sh copy_images.php distribute_html.php
gen_chapterents.php gen_docs_from_source.sh
gen_manual.sh gen_manualxml.php
gen_name_to_id.xsl manual.xml.in
merge_updates.php mtoc.xml.in
testclasses.xml.in testmanual.xml.in
Modified files:
/php-gtk-doc/scripts .cvsignore genchapterents.php.in highlight.php
Log:
Scripts incoming....
http://cvs.php.net/viewcvs.cgi/php-gtk-doc/scripts/.cvsignore?r1=1.4&r2=1.5&diff_format=u Index: php-gtk-doc/scripts/.cvsignore diff -u /dev/null php-gtk-doc/scripts/.cvsignore:1.5 --- /dev/null Sun Mar 26 02:44:13 2006 +++ php-gtk-doc/scripts/.cvsignore Sun Mar 26 02:44:13 2006 @@ -0,0 +1,5 @@ +genchapterents.php +manual.xml +mtoc.xml +testclasses.xml +testmanual.xml http://cvs.php.net/viewcvs.cgi/php-gtk-doc/scripts/genchapterents.php.in?r1=1.20&r2=1.21&diff_format=u Index: php-gtk-doc/scripts/genchapterents.php.in diff -u /dev/null php-gtk-doc/scripts/genchapterents.php.in:1.21 --- /dev/null Sun Mar 26 02:44:13 2006 +++ php-gtk-doc/scripts/genchapterents.php.in Sun Mar 26 02:44:13 2006 @@ -0,0 +1,84 @@ +<?php + +$lang = '@LANG@'; +$langdir = '@LANGDIR@'; +$default = '@MANUAL@/en'; +$entities = array(); +$origlang = '@LANG@'; +$origentities = array(); + +function gen_ent($path, $file, $lang) +{ + global $langdir; + + $path = substr($path, strlen($langdir) + 1); + if ($path) $path .= "/"; + $ent = preg_replace("%[\\/]%", ".", preg_replace("%^(?:manual[\\/])?en[\\/]((userguide|reference)[\\/])?(.*)\.xml$%",'\\3', $path.$file)); + $ent = ltrim($ent, '.'); + $ent = substr($ent, 0, -4); + + return "<!ENTITY $ent SYSTEM \"".preg_replace('%^(?:[\\/])?en([\\/](userguide|reference)[\\/])?%', "$lang\\1", "$lang/$path$file")."\">"; + +} + +function gen_dir_ents($langdir) +{ + global $entities, $lang; + $dir_handle = opendir($langdir); + while($file = readdir($dir_handle)) + { + if (($file != "CVS") && ($file != ".cvsignore") && ($file != ".") && ($file != "..")) + { + if(is_dir($langdir."/".$file)) + { + gen_dir_ents($langdir."/".$file); + } + else + { + if(substr($file, -4) == ".xml") + { + if(($lang != "en") and (file_exists(preg_replace("%^([\\/])?en(/?|$)%", "\\1".$lang."\\2", $langdir)."/".$file))) + { + $entities[] = gen_ent($langdir, $file, $lang); + } + else + { + $entities[] = gen_ent($langdir, $file, "en"); + } + } + } + } + } + closedir($dir_handle); +} + +if (is_dir($langdir)) { + + gen_dir_ents($langdir); + + if ($lang != "en") { + $origentities = $entities; + $lang = "en"; + $langdir = $default; + $entities = array(); + gen_dir_ents($langdir); + } + +} else { + die("\nPlease run configure from the top dir of php-gtk-doc checkout.\n"); +} + +sort($entities, SORT_STRING); + +while(list(,$val) = each($entities)) { + /* check for uniqueness */ + if ($lang != $origlang) { + $check = str_replace("en/", "$origlang/", $val); + if (in_array($check, $origentities)) { + $val = $check; + } + } + echo $val."\n"; +} + +?> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/scripts/highlight.php?r1=1.1&r2=1.2&diff_format=u Index: php-gtk-doc/scripts/highlight.php diff -u php-gtk-doc/scripts/highlight.php:1.1 php-gtk-doc/scripts/highlight.php:1.2 --- php-gtk-doc/scripts/highlight.php:1.1 Wed Dec 28 14:10:57 2005 +++ php-gtk-doc/scripts/highlight.php Sun Mar 26 02:44:13 2006 @@ -19,11 +19,12 @@ */ if ($_SERVER["argc"] < 3) { - exit("Purpose: Syntax highlight PHP examples in XSLT generated HTML manual.\r\n" + exit("Purpose: Syntax highlight PHP examples in XSLT generated manual.\r\n" .'Usage: highlight.php [ "xml" | "php" ] [ filename.ext | dir | wildcard ] ...' ."\r\n" ); } set_time_limit(5*60); // can run long, but not more than 5 minutes +ini_set("error_reporting", E_ALL); // kill the E_STRICT warnings in GeSHi under PHP 5 require dirname(__FILE__).'/geshi/geshi.php'; $geshi = new GeSHi('', 'php', dirname(__FILE__).'/geshi/geshi'); @@ -42,14 +43,14 @@ $geshi->set_regexps_style(0, 'color: #004090', true); // use this to get updated stylesheet info if changed via abovementioned API -// $styles = $geshi->get_stylesheet();_ +// $styles = $geshi->get_stylesheet(); function callback_html_number_entities_decode($matches) { return chr($matches[1]); } function callback_highlight_php($matches) { - $with_tags = trim( html_entity_decode( $matches[1])); + $with_tags = trim(html_entity_decode($matches[1])); global $geshi; $geshi->set_language('php'); $geshi->set_source($with_tags); @@ -57,21 +58,23 @@ } function callback_highlight_xml($matches) { - $with_tags = trim( html_entity_decode( $matches[1])); + $with_tags = trim(html_entity_decode($matches[1])); global $geshi; $geshi->set_language('xml'); $geshi->set_source($with_tags); - $strCode = $geshi->parse_code(); + $strCode = $geshi->parse_code(); return $strCode; } -echo "Highlighting files "; +echo "Highlighting files.."; $files = $_SERVER["argv"]; array_shift($files);// $argv[0] - script filename $TYPE = array_shift($files);//"xml" or "php" + while (($file = array_shift($files)) !== null) { + if (is_file($file)) { $process = array($file); } elseif (is_dir($file)) { @@ -79,28 +82,27 @@ $process = glob($file . ($lastchar == "/" || $lastchar == "\\" ? "*" : "/*")); } else { // should be wildcard //please tell me how to prevent wildcard escaping in the shell - //then I can remove this $file = str_replace('\\*', '*', $file); $process = glob($file); } + foreach ($process as $filename) { if (!is_file($filename)) { // do not recurse continue; } -// echo "highlighting $filename ...\n"; + $original = file_get_contents($filename); $highlighted = preg_replace_callback("!<pre class=\"phpcode\">(.*)</pre>!sU", "callback_highlight_php", $original); $highlighted = preg_replace_callback("!<pre class=\"xml\">(.*)</pre>!sU", "callback_highlight_xml", $highlighted); + if ($original != $highlighted) { - // file_put_contents is only in PHP >= 5 $fp = fopen( $filename, "wb"); fwrite($fp, $highlighted); fclose($fp); } echo "."; } -// echo "done highlighting.\r\n"; } -echo " done\r\n"; +echo "\nhighlighting complete\n"; ?> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/scripts/cleanup.sh?view=markup&rev=1.1 Index: php-gtk-doc/scripts/cleanup.sh +++ php-gtk-doc/scripts/cleanup.sh #!/bin/sh # cleans up a bit # Note: doesn't clean up the reference (which would be silly) cd "`dirname "$0"`" if [ ! -d ../manual ]; then echo "Please go to the scripts directory before running this script" echo "Usage: cleanup.sh" exit 1 fi rm ../manual/*/chapters.ent rm manual.xml http://cvs.php.net/viewcvs.cgi/php-gtk-doc/scripts/copy_images.php?view=markup&rev=1.1 Index: php-gtk-doc/scripts/copy_images.php +++ php-gtk-doc/scripts/copy_images.php <?php /* Copies images to somewhere the various manual builds can 'see' them */ if ($GLOBALS['argc'] < 1) { exit("Purpose: Copy images to a local dir for use of the XSLT generated manual.\r\n" .'Usage: copy_images.php [ dest ] ...' ."\r\n"); } $dest = $GLOBALS['argv'][1]; $imagedir = realpath('images'); chdir($dest); function copy_images($src, $dest, &$count) { if (is_dir($src)) { if ($handle = opendir($src)) { chdir($src); while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && $file != "CVS") { $fulldest = $dest.substr(getcwd(), strpos(getcwd(), 'images')-1)."/$file"; if (is_dir($file)) { mkdir($fulldest, 0777); copy_images(realpath($file), $dest, $count); } else { copy($file, $fulldest); $count++; echo '>>'; } } } chdir("../"); } closedir($handle); } return $count; } /* avoid the file permissions crisis */ mkdir('images', 0777); // explicitly create dest dir at current level echo "copying image files\n"; $count = 0; $total = copy_images($imagedir, realpath('.'), $count); echo "\n$total image files copied\n"; ?> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/scripts/distribute_html.php?view=markup&rev=1.1 Index: php-gtk-doc/scripts/distribute_html.php +++ php-gtk-doc/scripts/distribute_html.php <?php /** * Distributes the generated HTML files in multiple subdirectories * so that you can browse them without having to load 1800+ files * * subdirs for: atk, gdk, gtk, pango, tutorials */ $prefixes = array('atk','gdk','gtk','pango','tutorials'); if ($GLOBALS['argc'] < 1) { exit("Purpose: Distribute the HTML files in the XSLT generated manual.\r\n" .'Usage: distribute_html.php [ dest ] ...' ."\r\n"); } $dest = $GLOBALS['argv'][1]; chdir($dest); //create directories foreach ($prefixes as $prefix) { if (!file_exists($prefix)) { mkdir($prefix, 0755); } } //move files $hdl = dir('.'); while (false !== ($file = $hdl->read())) { foreach ($prefixes as $prefix) { if (substr($file, 0, strlen($prefix) + 1) == $prefix . '.') { rename($file, $prefix. '/' . $file); } } } //base directory $basefiles = glob('*.html'); $searches = array(); $replacements = array(); foreach ($prefixes as $prefix) { $searches[] = '%href="' . $prefix . '\\.%'; $replacements[] = 'href="' . $prefix . '/' . $prefix . '.'; } foreach ($basefiles as $file) { $content = preg_replace($searches, $replacements, file_get_contents($file)); $hdl = fopen($file, "w+"); fwrite($hdl,$content); fclose($hdl); } //prefixed directories foreach ($prefixes as $prefix) { $basefiles = glob($prefix . '/*.html'); $searches = array('%((img src|href)\s*=\s*("|\'))(?!http|ftp|mailto|\.\.)(\.\/|\/|)%i'); $replacements = array('\1../'); foreach ($prefixes as $prefix2) { if ($prefix2 != $prefix) { $searches[] = '%href="../'.$prefix2.'\\.%'; $replacements[] = 'href="../'.$prefix2.'/'.$prefix2.'.'; } else { $searches[] = '%href="../'.$prefix2.'\\.%'; $replacements[] = 'href="'.$prefix2.'.'; } } foreach ($basefiles as $file) { $content = preg_replace($searches, $replacements, file_get_contents($file)); $hdl = fopen($file, "w+"); fwrite($hdl,$content); fclose($hdl); } }//foreach prefix ?> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/scripts/gen_chapterents.php?view=markup&rev=1.1 Index: php-gtk-doc/scripts/gen_chapterents.php +++ php-gtk-doc/scripts/gen_chapterents.php <?php /** * generates a "chapters.ent" file from the existing * xml documentation files * * the chapters.ent is part of the manual DTD used for * linking to the single xml files so that their contents * can be accessed from within the xml tree */ function gen_ent($path, $file, $lang) { global $base_dir; $relpath = substr($path . '/' . $file, strlen($base_dir)); $ent = preg_replace("%[\\/]%",".", preg_replace("%^(?:..[\\/])?en[\\/]((userguide|reference)[\\/])?(.*)\.xml$%",'\\3', substr($relpath, strlen($lang) + 1, -4))); return "<!ENTITY $ent SYSTEM \"".preg_replace('%^(?:..[\\/])?en([\\/](userguide|reference)[\\/])?%', "$lang\\1", $relpath)."\">"; }//function gen_ent($path, $file, $lang) function gen_dir_ents($path) { global $entities, $lang; $dir_handle = opendir($path); while ($file = readdir($dir_handle)) { if (($file != "CVS") && ($file != ".cvsignore") && ($file != ".") && ($file != "..")) { if (is_dir($path."/".$file)) { gen_dir_ents($path."/".$file); } else { if (substr($file, -4) == ".xml") { if ($lang != "UTF8dir/en" && file_exists(preg_replace("%^(..[\\/])?en(/?|$)%", "\\1".$lang."\\2", $path)."/".$file)) { $entities[] = gen_ent($path, $file, $lang); } else { $entities[] = gen_ent($path, $file, "UTF8dir/en"); } } } } } closedir($dir_handle); }//function gen_dir_ents($path) if ($GLOBALS['argc'] < 2 || strlen($GLOBALS['argv'][1]) != 2) { die("\r\nError: Pass the desired language as only parameter\r\n"); } $lang = $GLOBALS['argv'][1]; $entities = array(); if (!is_dir('manual/' . $lang)) { die("\r\nPlease run configure from the top dir of php-gtk-doc checkout.\r\n"); } $base_dir = 'manual/'; gen_dir_ents('manual/' . $lang); sort($entities, SORT_STRING); //write it into manual/$lang/chapters.ent $chapfile = $base_dir . 'chapters.ent'; $hdl = fopen($chapfile, 'w+'); fwrite($hdl, "<!-- DO NOT EDIT THIS FILE! IT IS GENERATED AUTOMATICALLY BY gen_chapterents.php -->\r\n"); foreach ($entities as $val) { fwrite($hdl, $val . "\r\n"); } fclose($hdl); echo 'wrote ' . count($entities) . ' entities into file ' . $chapfile . "\r\n"; ?> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/scripts/gen_docs_from_source.sh?view=markup&rev=1.1 Index: php-gtk-doc/scripts/gen_docs_from_source.sh +++ php-gtk-doc/scripts/gen_docs_from_source.sh #!/bin/sh #generates the php-gtk docs from the sources #note: the docgen does a chdir to its directory, so the paths have to be relative to php-gtk/generator/ #there are two parameters: "classonly" and "enumonly" php=php gen_enum=1 gen_class=1 if [ ! $1 ]; then language='en' else language="$1" fi if [ ! -d scripts ]; then echo "Please run this script from the toplevel php-gtk-doc directory." echo "Usage: scripts/gen_docs_from_source.sh [lang][classonly|enumonly]" exit 1 fi if [ ! -d ../php-gtk ]; then echo "Please checkout php-gtk first and make sure that" echo "the directory ../php-gtk is reachable" exit 1 fi #goto here cd "`dirname "$0"`" if [ ! -d ../manual/$language/reference ]; then mkdir ../manual mkdir ../manual/$language mkdir ../manual/$language/reference mkdir ../manual/$language/reference/atk mkdir ../manual/$language/reference/gdk mkdir ../manual/$language/reference/gtk mkdir ../manual/$language/reference/pango fi if [ $# -gt 1 ]; then if [ $2 == "enumonly" ]; then gen_class=0 elif [ $2 == "classonly" ]; then gen_enum=0 fi fi #generate the docs if [ $gen_class -eq 1 ]; then echo "Generating class docs" $php -q ../../php-gtk/generator/docgen.php -p atk -d ../../php-gtk-doc/manual/$language/reference/atk -s ../../php-gtk-doc/manual/$language/reference/atk ../ext/gtk+/atk.defs $php -q ../../php-gtk/generator/docgen.php -p gdk -d ../../php-gtk-doc/manual/$language/reference/gdk -s ../../php-gtk-doc/manual/$language/reference/gdk ../ext/gtk+/gdk.defs $php -q ../../php-gtk/generator/docgen.php -p gtk -d ../../php-gtk-doc/manual/$language/reference/gtk -s ../../php-gtk-doc/manual/$language/reference/gtk ../ext/gtk+/gtk.defs $php -q ../../php-gtk/generator/docgen.php -p pango -d ../../php-gtk-doc/manual/$language/reference/pango -s ../../php-gtk-doc/manual/$language/reference/pango ../ext/gtk+/pango.defs fi #generate enums if [ $gen_enum -eq 1 ]; then echo "Generating enumeration docs" $php -q ../../php-gtk/generator/docgen_enum.php atk manual/$language/reference/atk/atkenum.xml $php -q ../../php-gtk/generator/docgen_enum.php gdk manual/$language/reference/gdk/gdkenum.xml $php -q ../../php-gtk/generator/docgen_enum.php gtk manual/$language/reference/gtk/gtkenum.xml $php -q ../../php-gtk/generator/docgen_enum.php pango manual/$language/reference/pango/pangoenum.xml fi echo "done" http://cvs.php.net/viewcvs.cgi/php-gtk-doc/scripts/gen_manual.sh?view=markup&rev=1.1 Index: php-gtk-doc/scripts/gen_manual.sh +++ php-gtk-doc/scripts/gen_manual.sh #!/bin/sh #just for testing! cd "`dirname "$0"`" if [ $# -lt 2 ]; then echo "Usage: scripts/gen_manual.sh <language> <type>" echo "type: html phpweb test demo" exit 1 fi language=$1 type=$2 realtype=$type stylesheetdir=../stylesheets php=php manualfile=manual.xml test=0 if [ ! -d ../manual/$language ]; then echo "There is no manual for language $language" exit 2 fi if [ ! -d ../build ]; then mkdir ../build fi if [ ! -d ../build/$language ]; then mkdir ../build/$language fi if [ $type == "test" ]; then if [ $# -lt 3 ]; then echo "Please pass the id as third parameter" exit 4 fi test=1 manualfile=test_manual.xml type=html #generate the file $php -q liveGen.php $3 fi build_dir=../build/$language/$type manualpath=../scripts/$manualfile if [ $type == "html" ]; then xslfile=$stylesheetdir/html/chunk.xsl elif [ $type == "phpweb" ]; then xslfile=$stylesheetdir/html/phpweb.xsl elif [ $type == "demo" ]; then xslfile=$stylesheetdir/html/chunk.xsl manualpath=../manual/demo_manual.xml else echo "There is no type $type." exit 3 fi if [ $test == "1" ]; then build_dir=../build/$language/test fi # # we've got all necessary data; generate the manual # if [ ! -d $build_dir ]; then mkdir $build_dir else #empty the dir rm -R $build_dir/* fi xsltproc --param base.dir "'$build_dir/'" --xinclude $xslfile $manualpath #highlight php sources #we need to escape the wildcard, because php doesn't allow enough # parameters - and could someone please tell me how to prevent # wildcard escaping? That "\\*" is a hack which is only understood # by highlight.php $php ../scripts/highlight.php php "../build/$language/$realtype/\\*.html" #distribute over several files if [ $type == "html" ] && [ $test == "0" ] && [ ! $type == "demo" ]; then $php -q ../scripts/distribute_html.php "../build/$language/html" $php -q ../scripts/copy_images.php "../build/$language/html" fi http://cvs.php.net/viewcvs.cgi/php-gtk-doc/scripts/gen_manualxml.php?view=markup&rev=1.1 Index: php-gtk-doc/scripts/gen_manualxml.php +++ php-gtk-doc/scripts/gen_manualxml.php <?php /** * generates manual.xml for a specific language from the manual.xml.in template */ $template = 'scripts/manual.xml.in'; if (!file_exists($template)) { die("\r\nRun the script from the base php-gtk-doc directory\r\n"); } if ($GLOBALS['argc'] < 2 || strlen($GLOBALS['argv'][1]) != 2) { die("\r\nError: Pass the desired language as only parameter\r\n"); } $lang = $GLOBALS['argv'][1]; if (!is_dir('manual/' . $lang)) { die("\r\nThere is no directory for language $lang\r\n"); } $outputfile = 'scripts/manual.xml'; $hdl = fopen($outputfile, "w+"); fwrite($hdl, str_replace('@PHP_GTK2_DOC_BUILD_DATE@', date('r'), str_replace('@LANG@', $lang, str_replace('@LANGDIR@', "manual/$lang", str_replace('@MANUAL@', "manual", str_replace('<!DOCTYPE', "<!-- DO NOT EDIT THIS FILE! IT IS GENERATED AUTOMATICALLY BY gen_manualxml.php -->\r\n<!DOCTYPE", str_replace('@DOCBOOK_DOCTYPE@', '-//PHP Group//DTD DocBk XML V3.1.7-Based Extension//EN', file_get_contents($template) )))))) ); fclose($hdl); ?> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/scripts/gen_name_to_id.xsl?view=markup&rev=1.1 Index: php-gtk-doc/scripts/gen_name_to_id.xsl +++ php-gtk-doc/scripts/gen_name_to_id.xsl <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:doc="http://nwlash.com/xsl/documentation/1.0" version="1.0"> <xsl:output method="text" encoding="UTF-8" indent="no"/> <xsl:template match="*" /> <xsl:template match="classentry|refentry"> <xsl:variable name="id" select="@id"/> <xsl:variable name="classname" > <xsl:choose> <xsl:when test="count(self::classentry)!='0'"> <xsl:value-of select="./classmeta/classtitle"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="./refmeta/refentrytitle"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:text disable-output-escaping="yes"><xsl:when test="$classname='</xsl:text> <xsl:value-of select="$classname"/> <xsl:text disable-output-escaping="yes">'"><xsl:text></xsl:text> <xsl:value-of select="$id" /> <xsl:text disable-output-escaping="yes"></xsl:text></xsl:when></xsl:text> </xsl:template> <xsl:template match="method|constructor"> <xsl:variable name="id" select="@id"/> <xsl:variable name="funcname" > <xsl:value-of select="./funcsynopsis/funcprototype/funcdef/function"/> </xsl:variable> <xsl:text disable-output-escaping="yes"><xsl:when test="$funcname='</xsl:text> <xsl:value-of select="$funcname"/> <xsl:text disable-output-escaping="yes">' and $class='</xsl:text> <xsl:choose> <xsl:when test="count(ancestor::classentry)!='0'"> <xsl:value-of select="ancestor-or-self::classentry/classmeta/classtitle"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="ancestor-or-self::refentry/refmeta/refentrytitle"/> </xsl:otherwise> </xsl:choose> <xsl:text disable-output-escaping="yes">'"><xsl:text></xsl:text> <xsl:value-of select="$id" /> <xsl:text disable-output-escaping="yes"></xsl:text></xsl:when></xsl:text> </xsl:template> <!-- <xsl:template match="attribute"> <xsl:variable name="id" select="@id"/> <xsl:variable name="attrname" > <xsl:value-of select="./attributename"/> </xsl:variable> <xsl:text disable-output-escaping="yes"><xsl:when test="$attrname='</xsl:text> <xsl:value-of select="$attrname"/> <xsl:text disable-output-escaping="yes">'"><xsl:text></xsl:text> <xsl:value-of select="$id" /> <xsl:text disable-output-escaping="yes"></xsl:text></xsl:when></xsl:text> </xsl:template> --> <xsl:template match="prop"> <xsl:variable name="id" select="@id"/> <xsl:variable name="propname" > <xsl:value-of select="./propname"/> </xsl:variable> <xsl:text disable-output-escaping="yes"><xsl:when test="$propname='</xsl:text> <xsl:value-of select="$propname"/> <xsl:text disable-output-escaping="yes">' and $class='</xsl:text> <xsl:choose> <xsl:when test="count(ancestor::classentry)!='0'"> <xsl:value-of select="ancestor-or-self::classentry/classmeta/classtitle"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="ancestor-or-self::refentry/refmeta/refentrytitle"/> </xsl:otherwise> </xsl:choose> <xsl:text disable-output-escaping="yes">'"><xsl:text></xsl:text> <xsl:value-of select="$id" /> <xsl:text disable-output-escaping="yes"></xsl:text></xsl:when></xsl:text> </xsl:template> <xsl:template match="field"> <xsl:variable name="id" select="@id"/> <xsl:variable name="fieldname" > <xsl:value-of select="./fieldname"/> </xsl:variable> <xsl:text disable-output-escaping="yes"><xsl:when test="$fieldname='</xsl:text> <xsl:value-of select="$fieldname"/> <xsl:text disable-output-escaping="yes">' and $class='</xsl:text> <xsl:choose> <xsl:when test="count(ancestor::classentry)!='0'"> <xsl:value-of select="ancestor-or-self::classentry/classmeta/classtitle"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="ancestor-or-self::refentry/refmeta/refentrytitle"/> </xsl:otherwise> </xsl:choose> <xsl:text disable-output-escaping="yes">'"><xsl:text></xsl:text> <xsl:value-of select="$id" /> <xsl:text disable-output-escaping="yes"></xsl:text></xsl:when></xsl:text> </xsl:template> <xsl:template match="signal"> <xsl:variable name="id" select="@id"/> <xsl:variable name="signame" > <xsl:value-of select="./signalname"/> </xsl:variable> <xsl:text disable-output-escaping="yes"><xsl:when test="$signame='</xsl:text> <xsl:value-of select="$signame"/> <xsl:text disable-output-escaping="yes">'"><xsl:text></xsl:text> <xsl:value-of select="$id" /> <xsl:text disable-output-escaping="yes"></xsl:text></xsl:when></xsl:text> </xsl:template> <xsl:template match="/"> <xsl:text disable-output-escaping="yes"> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:doc="http://nwlash.com/xsl/documentation/1.0" version="1.0"> <xsl:template name="get_id_from_name"> <xsl:param name="classname" /> <xsl:choose> </xsl:text> <xsl:apply-templates select=".//classentry" /> <xsl:text disable-output-escaping="yes"> <xsl:otherwise> <xsl:text>no</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:text> <xsl:text disable-output-escaping="yes"> <xsl:template name="get_func_id_from_name"> <xsl:param name="funcname" /> <xsl:param name="class" select="'no'" /> <xsl:choose> </xsl:text> <xsl:apply-templates select=".//method|.//constructor" /> <xsl:text disable-output-escaping="yes"> <xsl:otherwise> <xsl:text>no</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:text> <xsl:if test="count(.//prop)>0"> <xsl:text disable-output-escaping="yes"> <xsl:template name="get_prop_id_from_name"> <xsl:param name="propname" /> <xsl:param name="class" select="no" /> <xsl:choose> </xsl:text> <xsl:apply-templates select=".//prop" /> <xsl:text disable-output-escaping="yes"> <xsl:otherwise> <xsl:text>no</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:text> </xsl:if> <xsl:if test="count(.//field)>0"> <xsl:text disable-output-escaping="yes"> <xsl:template name="get_field_id_from_name"> <xsl:param name="fieldname" /> <xsl:param name="class" select="no" /> <xsl:choose> </xsl:text> <xsl:apply-templates select=".//field" /> <xsl:text disable-output-escaping="yes"> <xsl:otherwise> <xsl:text>no</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:text> </xsl:if> <xsl:text disable-output-escaping="yes"> <xsl:template name="get_sig_id_from_name"> <xsl:param name="signame" /> </xsl:text> <xsl:text disable-output-escaping="yes"> <xsl:choose> </xsl:text> <xsl:apply-templates select=".//signal" /> <xsl:text disable-output-escaping="yes"> <xsl:otherwise> </xsl:text> <xsl:text disable-output-escaping="yes"> <xsl:text>no</xsl:text> </xsl:text> <xsl:text disable-output-escaping="yes"> </xsl:otherwise> </xsl:choose> </xsl:text> <xsl:text> </xsl:template> </xsl:stylesheet> </xsl:text> </xsl:template> </xsl:stylesheet> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/scripts/manual.xml.in?view=markup&rev=1.1 Index: php-gtk-doc/scripts/manual.xml.in +++ php-gtk-doc/scripts/manual.xml.in <?xml version='1.0' encoding='utf-8'?> <!DOCTYPE book PUBLIC "@DOCBOOK_DOCTYPE@" "../dbxml/phpgtkdoc.dtd"[ <!-- Defaults for entities that should be defined in language-defs --> <!ENTITY % language-defs SYSTEM "../@LANGDIR@/language-defs.ent"> %language-defs; <!-- These are language independent --> <!ENTITY phpgtk2doc.build-date "@PHP_GTK2_DOC_BUILD_DATE@"> <!ENTITY % global.entities SYSTEM "../@MANUAL@/global.ent"> <!ENTITY % global.chapters SYSTEM "../@MANUAL@/chapters.ent"> <!ENTITY % global.contribs SYSTEM "../@MANUAL@/contributors.ent"> %global.entities; %global.chapters; %global.contribs; <!ENTITY tutorials SYSTEM "../@MANUAL@/tutorials.xml"> <!ENTITY reference SYSTEM "../@MANUAL@/reference.xml"> <!ENTITY appendix SYSTEM "../@MANUAL@/appendix.xml"> ]> <set id="phpgtk.docs" lang="@LANG@"> &bookinfo; &preface; &tutorials; &reference; &appendix; </set> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/scripts/merge_updates.php?view=markup&rev=1.1 Index: php-gtk-doc/scripts/merge_updates.php +++ php-gtk-doc/scripts/merge_updates.php #!/usr/local/bin/php <?php /** * Class for combining a current list of manual file * updates with an existing list. * * Updated files should be listed as a set of HTML * links. The resulting file is an HTML fragment * that consists of precisely that, and nothing more. * * @original author Scott Mattocks * @altered by Steph Fox to accommodate XSLT changes */ // Check number of args if ($GLOBALS["argc"] != 3) { exit("Purpose: Merge pre-formatted contents of new updates file into pre-existing updates file.\r\n" .'Usage: merge-updates.php [ newupdatesfile ] [ outfile ] ' ."\r\n" ); } // Not really max. It can be overridden by // very busy scribblers: see mergeUpdates() define ('MAX_UPDATES_TO_SHOW', 15); class ManualUpdates { /** * File containing the new update data. * @var string */ var $newfile; /** * Pre-existing updates file; used for output. * @var string */ var $outfile; /** * Array that will contain the new update data. * @var array */ var $newarray = array(); /** * Array that will contain the current data. * @var array */ var $oldarray = array(); /** * Array that will carry the merged info. * @var array */ var $output = array(); var $maximum; /** * PHP 4 constructor. * Sets files name and content variables * * @param string updatesfile, string outputfile * @return void */ function ManualUpdates($newupdates, $outupdates) { $this->newfile = $newupdates; $this->outfile = $outupdates; $this->newarray = $this->_getUpdates($this->newfile); $this->oldarray = $this->_getUpdates($this->outfile); } /** * Value checking. * Picks up file contents. * * @param string filename * @return array filecontents */ function _getUpdates($filename) { if (!is_readable($filename)) { trigger_error('Cannot get updates from ' . $filename, E_USER_WARNING); trigger_error($filename . ' does not exist or is not readable by this user.', E_USER_ERROR); exit; } return file($filename); } /** * Merges and sorts the arrays without array_intersect_key() or even a useful timestamp <sigh /> * Rewrite this function when we get PHP 5 and/or `date %s` * Sets output array * * @param none * @return void */ function mergeUpdates() { // We want to show MAX_UPDATES_TO_SHOW or the total of // tonight's updates, whichever is the greater. Apparently. $this->maximum = max(MAX_UPDATES_TO_SHOW, sizeof($this->newarray)); $merged = array_merge($this->newarray, $this->oldarray); // Lines aren't unique. Titles are... foreach ($merged as $line) { $stripped = strip_tags($line); $titles[] = substr($stripped, strpos($stripped, ' ')); } $unique = array_unique($titles); for ($i = 0; $i < sizeof($merged); $i++) { if (array_key_exists($i, $unique) && sizeof($this->output) < $this->maximum) { $this->output[] = $merged[$i]; } else { unset($merged[$i]); } } } /** * Writes the updated output array to file, the old-fashioned way * * @param none * @return void */ function writeUpdatesToFile() { $fp = fopen($this->outfile, 'w'); foreach ($this->output as $line) { fwrite($fp, $line); } fclose($fp); } } // Set the parameter vars $newupdates = $argv[1]; $outupdates = $argv[2]; // Create the current list of updates. $mu =& new ManualUpdates($newupdates, $outupdates); $mu->mergeUpdates(); $mu->writeUpdatesToFile(); ?> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/scripts/mtoc.xml.in?view=markup&rev=1.1 Index: php-gtk-doc/scripts/mtoc.xml.in +++ php-gtk-doc/scripts/mtoc.xml.in <?xml version='1.0' encoding='utf-8' ?> <!DOCTYPE book PUBLIC "@DOCBOOK_DOCTYPE@" "@srcdir@/dbxml/phpgtkdoc.dtd"[ <!-- Defaults for entities that should be defined in language-defs --> <!ENTITY % language-defs SYSTEM "@UTF8LANG@/language-defs.ent"> %language-defs; <!-- These are language independent --> <!ENTITY phpgtk.build-date "@PHP_GTK_DOC_BUILD_DATE@"> <!ENTITY % global.entities SYSTEM "global.ent"> <!ENTITY % global.chapters SYSTEM "chapters.ent"> %global.entities; %global.chapters; <!ENTITY userguide SYSTEM "userguide.xml"> <!ENTITY tutorials SYSTEM "tutorials.xml"> <!ENTITY reference SYSTEM "reference.xml"> <!ENTITY appendix SYSTEM "appendix.xml"> <!ENTITY keysyms SYSTEM "keysyms.xml"> <!ENTITY license SYSTEM "license.xml"> ]> <mtoc> &bookinfo; &preface; &userguide; &tutorials; &reference; &appendix; </mtoc> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/scripts/testclasses.xml.in?view=markup&rev=1.1 Index: php-gtk-doc/scripts/testclasses.xml.in +++ php-gtk-doc/scripts/testclasses.xml.in <?xml version="1.0" encoding='utf-8' ?> <book id="testclasses"> <title>Test classes</title> <classset id="testclasslist"> <title>Classes to test</title> <partintro>This is a list of classes which have recently been changed</partintro> @TEST_REFERENCES@ </classset> </book> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/scripts/testmanual.xml.in?view=markup&rev=1.1 Index: php-gtk-doc/scripts/testmanual.xml.in +++ php-gtk-doc/scripts/testmanual.xml.in <?xml version='1.0' encoding='utf-8' ?> <!DOCTYPE book PUBLIC "@DOCBOOK_DOCTYPE@" "../dbxml/phpgtkdoc.dtd"[ <!-- Defaults for entities that should be defined in language-defs --> <!ENTITY % language-defs SYSTEM "../@LANGDIR@/language-defs.ent"> %language-defs; <!-- These are language independent --> <!ENTITY phpgtk2doc.build-date "@PHP_GTK2_DOC_BUILD_DATE@"> <!ENTITY % global.entities SYSTEM "../@MANUAL@/global.ent"> <!ENTITY % global.chapters SYSTEM "../@MANUAL@/chapters.ent"> <!ENTITY % global.contribs SYSTEM "../@MANUAL@/contributors.ent"> %global.entities; %global.chapters; %global.contribs; <!ENTITY testclasses SYSTEM "testclasses.xml"> ]> <set id="phpgtk.docs" lang="@LANG@"> &testclasses; </set>
http://cvs.php.net/viewcvs.cgi/php-gtk-doc/scripts/.cvsignore?r1=1.4&r2=1.5&diff_format=u Index: php-gtk-doc/scripts/.cvsignore diff -u /dev/null php-gtk-doc/scripts/.cvsignore:1.5 --- /dev/null Sun Mar 26 02:44:13 2006 +++ php-gtk-doc/scripts/.cvsignore Sun Mar 26 02:44:13 2006 @@ -0,0 +1,5 @@ +genchapterents.php +manual.xml +mtoc.xml +testclasses.xml +testmanual.xml http://cvs.php.net/viewcvs.cgi/php-gtk-doc/scripts/genchapterents.php.in?r1=1.20&r2=1.21&diff_format=u Index: php-gtk-doc/scripts/genchapterents.php.in diff -u /dev/null php-gtk-doc/scripts/genchapterents.php.in:1.21 --- /dev/null Sun Mar 26 02:44:13 2006 +++ php-gtk-doc/scripts/genchapterents.php.in Sun Mar 26 02:44:13 2006 @@ -0,0 +1,84 @@ +<?php + +$lang = '@LANG@'; +$langdir = '@LANGDIR@'; +$default = '@MANUAL@/en'; +$entities = array(); +$origlang = '@LANG@'; +$origentities = array(); + +function gen_ent($path, $file, $lang) +{ + global $langdir; + + $path = substr($path, strlen($langdir) + 1); + if ($path) $path .= "/"; + $ent = preg_replace("%[\\/]%", ".", preg_replace("%^(?:manual[\\/])?en[\\/]((userguide|reference)[\\/])?(.*)\.xml$%",'\\3', $path.$file)); + $ent = ltrim($ent, '.'); + $ent = substr($ent, 0, -4); + + return "<!ENTITY $ent SYSTEM \"".preg_replace('%^(?:[\\/])?en([\\/](userguide|reference)[\\/])?%', "$lang\\1", "$lang/$path$file")."\">"; + +} + +function gen_dir_ents($langdir) +{ + global $entities, $lang; + $dir_handle = opendir($langdir); + while($file = readdir($dir_handle)) + { + if (($file != "CVS") && ($file != ".cvsignore") && ($file != ".") && ($file != "..")) + { + if(is_dir($langdir."/".$file)) + { + gen_dir_ents($langdir."/".$file); + } + else + { + if(substr($file, -4) == ".xml") + { + if(($lang != "en") and (file_exists(preg_replace("%^([\\/])?en(/?|$)%", "\\1".$lang."\\2", $langdir)."/".$file))) + { + $entities[] = gen_ent($langdir, $file, $lang); + } + else + { + $entities[] = gen_ent($langdir, $file, "en"); + } + } + } + } + } + closedir($dir_handle); +} + +if (is_dir($langdir)) { + + gen_dir_ents($langdir); + + if ($lang != "en") { + $origentities = $entities; + $lang = "en"; + $langdir = $default; + $entities = array(); + gen_dir_ents($langdir); + } + +} else { + die("\nPlease run configure from the top dir of php-gtk-doc checkout.\n"); +} + +sort($entities, SORT_STRING); + +while(list(,$val) = each($entities)) { + /* check for uniqueness */ + if ($lang != $origlang) { + $check = str_replace("en/", "$origlang/", $val); + if (in_array($check, $origentities)) { + $val = $check; + } + } + echo $val."\n"; +} + +?> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/scripts/highlight.php?r1=1.1&r2=1.2&diff_format=u Index: php-gtk-doc/scripts/highlight.php diff -u php-gtk-doc/scripts/highlight.php:1.1 php-gtk-doc/scripts/highlight.php:1.2 --- php-gtk-doc/scripts/highlight.php:1.1 Wed Dec 28 14:10:57 2005 +++ php-gtk-doc/scripts/highlight.php Sun Mar 26 02:44:13 2006 @@ -19,11 +19,12 @@ */ if ($_SERVER["argc"] < 3) { - exit("Purpose: Syntax highlight PHP examples in XSLT generated HTML manual.\r\n" + exit("Purpose: Syntax highlight PHP examples in XSLT generated manual.\r\n" .'Usage: highlight.php [ "xml" | "php" ] [ filename.ext | dir | wildcard ] ...' ."\r\n" ); } set_time_limit(5*60); // can run long, but not more than 5 minutes +ini_set("error_reporting", E_ALL); // kill the E_STRICT warnings in GeSHi under PHP 5 require dirname(__FILE__).'/geshi/geshi.php'; $geshi = new GeSHi('', 'php', dirname(__FILE__).'/geshi/geshi'); @@ -42,14 +43,14 @@ $geshi->set_regexps_style(0, 'color: #004090', true); // use this to get updated stylesheet info if changed via abovementioned API -// $styles = $geshi->get_stylesheet();_ +// $styles = $geshi->get_stylesheet(); function callback_html_number_entities_decode($matches) { return chr($matches[1]); } function callback_highlight_php($matches) { - $with_tags = trim( html_entity_decode( $matches[1])); + $with_tags = trim(html_entity_decode($matches[1])); global $geshi; $geshi->set_language('php'); $geshi->set_source($with_tags); @@ -57,21 +58,23 @@ } function callback_highlight_xml($matches) { - $with_tags = trim( html_entity_decode( $matches[1])); + $with_tags = trim(html_entity_decode($matches[1])); global $geshi; $geshi->set_language('xml'); $geshi->set_source($with_tags); - $strCode = $geshi->parse_code(); + $strCode = $geshi->parse_code(); return $strCode; } -echo "Highlighting files "; +echo "Highlighting files.."; $files = $_SERVER["argv"]; array_shift($files);// $argv[0] - script filename $TYPE = array_shift($files);//"xml" or "php" + while (($file = array_shift($files)) !== null) { + if (is_file($file)) { $process = array($file); } elseif (is_dir($file)) { @@ -79,28 +82,27 @@ $process = glob($file . ($lastchar == "/" || $lastchar == "\\" ? "*" : "/*")); } else { // should be wildcard //please tell me how to prevent wildcard escaping in the shell - //then I can remove this $file = str_replace('\\*', '*', $file); $process = glob($file); } + foreach ($process as $filename) { if (!is_file($filename)) { // do not recurse continue; } -// echo "highlighting $filename ...\n"; + $original = file_get_contents($filename); $highlighted = preg_replace_callback("!<pre class=\"phpcode\">(.*)</pre>!sU", "callback_highlight_php", $original); $highlighted = preg_replace_callback("!<pre class=\"xml\">(.*)</pre>!sU", "callback_highlight_xml", $highlighted); + if ($original != $highlighted) { - // file_put_contents is only in PHP >= 5 $fp = fopen( $filename, "wb"); fwrite($fp, $highlighted); fclose($fp); } echo "."; } -// echo "done highlighting.\r\n"; } -echo " done\r\n"; +echo "\nhighlighting complete\n"; ?> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/scripts/cleanup.sh?view=markup&rev=1.1 Index: php-gtk-doc/scripts/cleanup.sh +++ php-gtk-doc/scripts/cleanup.sh #!/bin/sh # cleans up a bit # Note: doesn't clean up the reference (which would be silly) cd "`dirname "$0"`" if [ ! -d ../manual ]; then echo "Please go to the scripts directory before running this script" echo "Usage: cleanup.sh" exit 1 fi rm ../manual/*/chapters.ent rm manual.xml http://cvs.php.net/viewcvs.cgi/php-gtk-doc/scripts/copy_images.php?view=markup&rev=1.1 Index: php-gtk-doc/scripts/copy_images.php +++ php-gtk-doc/scripts/copy_images.php <?php /* Copies images to somewhere the various manual builds can 'see' them */ if ($GLOBALS['argc'] < 1) { exit("Purpose: Copy images to a local dir for use of the XSLT generated manual.\r\n" .'Usage: copy_images.php [ dest ] ...' ."\r\n"); } $dest = $GLOBALS['argv'][1]; $imagedir = realpath('images'); chdir($dest); function copy_images($src, $dest, &$count) { if (is_dir($src)) { if ($handle = opendir($src)) { chdir($src); while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && $file != "CVS") { $fulldest = $dest.substr(getcwd(), strpos(getcwd(), 'images')-1)."/$file"; if (is_dir($file)) { mkdir($fulldest, 0777); copy_images(realpath($file), $dest, $count); } else { copy($file, $fulldest); $count++; echo '>>'; } } } chdir("../"); } closedir($handle); } return $count; } /* avoid the file permissions crisis */ mkdir('images', 0777); // explicitly create dest dir at current level echo "copying image files\n"; $count = 0; $total = copy_images($imagedir, realpath('.'), $count); echo "\n$total image files copied\n"; ?> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/scripts/distribute_html.php?view=markup&rev=1.1 Index: php-gtk-doc/scripts/distribute_html.php +++ php-gtk-doc/scripts/distribute_html.php <?php /** * Distributes the generated HTML files in multiple subdirectories * so that you can browse them without having to load 1800+ files * * subdirs for: atk, gdk, gtk, pango, tutorials */ $prefixes = array('atk','gdk','gtk','pango','tutorials'); if ($GLOBALS['argc'] < 1) { exit("Purpose: Distribute the HTML files in the XSLT generated manual.\r\n" .'Usage: distribute_html.php [ dest ] ...' ."\r\n"); } $dest = $GLOBALS['argv'][1]; chdir($dest); //create directories foreach ($prefixes as $prefix) { if (!file_exists($prefix)) { mkdir($prefix, 0755); } } //move files $hdl = dir('.'); while (false !== ($file = $hdl->read())) { foreach ($prefixes as $prefix) { if (substr($file, 0, strlen($prefix) + 1) == $prefix . '.') { rename($file, $prefix. '/' . $file); } } } //base directory $basefiles = glob('*.html'); $searches = array(); $replacements = array(); foreach ($prefixes as $prefix) { $searches[] = '%href="' . $prefix . '\\.%'; $replacements[] = 'href="' . $prefix . '/' . $prefix . '.'; } foreach ($basefiles as $file) { $content = preg_replace($searches, $replacements, file_get_contents($file)); $hdl = fopen($file, "w+"); fwrite($hdl,$content); fclose($hdl); } //prefixed directories foreach ($prefixes as $prefix) { $basefiles = glob($prefix . '/*.html'); $searches = array('%((img src|href)\s*=\s*("|\'))(?!http|ftp|mailto|\.\.)(\.\/|\/|)%i'); $replacements = array('\1../'); foreach ($prefixes as $prefix2) { if ($prefix2 != $prefix) { $searches[] = '%href="../'.$prefix2.'\\.%'; $replacements[] = 'href="../'.$prefix2.'/'.$prefix2.'.'; } else { $searches[] = '%href="../'.$prefix2.'\\.%'; $replacements[] = 'href="'.$prefix2.'.'; } } foreach ($basefiles as $file) { $content = preg_replace($searches, $replacements, file_get_contents($file)); $hdl = fopen($file, "w+"); fwrite($hdl,$content); fclose($hdl); } }//foreach prefix ?> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/scripts/gen_chapterents.php?view=markup&rev=1.1 Index: php-gtk-doc/scripts/gen_chapterents.php +++ php-gtk-doc/scripts/gen_chapterents.php <?php /** * generates a "chapters.ent" file from the existing * xml documentation files * * the chapters.ent is part of the manual DTD used for * linking to the single xml files so that their contents * can be accessed from within the xml tree */ function gen_ent($path, $file, $lang) { global $base_dir; $relpath = substr($path . '/' . $file, strlen($base_dir)); $ent = preg_replace("%[\\/]%",".", preg_replace("%^(?:..[\\/])?en[\\/]((userguide|reference)[\\/])?(.*)\.xml$%",'\\3', substr($relpath, strlen($lang) + 1, -4))); return "<!ENTITY $ent SYSTEM \"".preg_replace('%^(?:..[\\/])?en([\\/](userguide|reference)[\\/])?%', "$lang\\1", $relpath)."\">"; }//function gen_ent($path, $file, $lang) function gen_dir_ents($path) { global $entities, $lang; $dir_handle = opendir($path); while ($file = readdir($dir_handle)) { if (($file != "CVS") && ($file != ".cvsignore") && ($file != ".") && ($file != "..")) { if (is_dir($path."/".$file)) { gen_dir_ents($path."/".$file); } else { if (substr($file, -4) == ".xml") { if ($lang != "UTF8dir/en" && file_exists(preg_replace("%^(..[\\/])?en(/?|$)%", "\\1".$lang."\\2", $path)."/".$file)) { $entities[] = gen_ent($path, $file, $lang); } else { $entities[] = gen_ent($path, $file, "UTF8dir/en"); } } } } } closedir($dir_handle); }//function gen_dir_ents($path) if ($GLOBALS['argc'] < 2 || strlen($GLOBALS['argv'][1]) != 2) { die("\r\nError: Pass the desired language as only parameter\r\n"); } $lang = $GLOBALS['argv'][1]; $entities = array(); if (!is_dir('manual/' . $lang)) { die("\r\nPlease run configure from the top dir of php-gtk-doc checkout.\r\n"); } $base_dir = 'manual/'; gen_dir_ents('manual/' . $lang); sort($entities, SORT_STRING); //write it into manual/$lang/chapters.ent $chapfile = $base_dir . 'chapters.ent'; $hdl = fopen($chapfile, 'w+'); fwrite($hdl, "<!-- DO NOT EDIT THIS FILE! IT IS GENERATED AUTOMATICALLY BY gen_chapterents.php -->\r\n"); foreach ($entities as $val) { fwrite($hdl, $val . "\r\n"); } fclose($hdl); echo 'wrote ' . count($entities) . ' entities into file ' . $chapfile . "\r\n"; ?> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/scripts/gen_docs_from_source.sh?view=markup&rev=1.1 Index: php-gtk-doc/scripts/gen_docs_from_source.sh +++ php-gtk-doc/scripts/gen_docs_from_source.sh #!/bin/sh #generates the php-gtk docs from the sources #note: the docgen does a chdir to its directory, so the paths have to be relative to php-gtk/generator/ #there are two parameters: "classonly" and "enumonly" php=php gen_enum=1 gen_class=1 if [ ! $1 ]; then language='en' else language="$1" fi if [ ! -d scripts ]; then echo "Please run this script from the toplevel php-gtk-doc directory." echo "Usage: scripts/gen_docs_from_source.sh [lang][classonly|enumonly]" exit 1 fi if [ ! -d ../php-gtk ]; then echo "Please checkout php-gtk first and make sure that" echo "the directory ../php-gtk is reachable" exit 1 fi #goto here cd "`dirname "$0"`" if [ ! -d ../manual/$language/reference ]; then mkdir ../manual mkdir ../manual/$language mkdir ../manual/$language/reference mkdir ../manual/$language/reference/atk mkdir ../manual/$language/reference/gdk mkdir ../manual/$language/reference/gtk mkdir ../manual/$language/reference/pango fi if [ $# -gt 1 ]; then if [ $2 == "enumonly" ]; then gen_class=0 elif [ $2 == "classonly" ]; then gen_enum=0 fi fi #generate the docs if [ $gen_class -eq 1 ]; then echo "Generating class docs" $php -q ../../php-gtk/generator/docgen.php -p atk -d ../../php-gtk-doc/manual/$language/reference/atk -s ../../php-gtk-doc/manual/$language/reference/atk ../ext/gtk+/atk.defs $php -q ../../php-gtk/generator/docgen.php -p gdk -d ../../php-gtk-doc/manual/$language/reference/gdk -s ../../php-gtk-doc/manual/$language/reference/gdk ../ext/gtk+/gdk.defs $php -q ../../php-gtk/generator/docgen.php -p gtk -d ../../php-gtk-doc/manual/$language/reference/gtk -s ../../php-gtk-doc/manual/$language/reference/gtk ../ext/gtk+/gtk.defs $php -q ../../php-gtk/generator/docgen.php -p pango -d ../../php-gtk-doc/manual/$language/reference/pango -s ../../php-gtk-doc/manual/$language/reference/pango ../ext/gtk+/pango.defs fi #generate enums if [ $gen_enum -eq 1 ]; then echo "Generating enumeration docs" $php -q ../../php-gtk/generator/docgen_enum.php atk manual/$language/reference/atk/atkenum.xml $php -q ../../php-gtk/generator/docgen_enum.php gdk manual/$language/reference/gdk/gdkenum.xml $php -q ../../php-gtk/generator/docgen_enum.php gtk manual/$language/reference/gtk/gtkenum.xml $php -q ../../php-gtk/generator/docgen_enum.php pango manual/$language/reference/pango/pangoenum.xml fi echo "done" http://cvs.php.net/viewcvs.cgi/php-gtk-doc/scripts/gen_manual.sh?view=markup&rev=1.1 Index: php-gtk-doc/scripts/gen_manual.sh +++ php-gtk-doc/scripts/gen_manual.sh #!/bin/sh #just for testing! cd "`dirname "$0"`" if [ $# -lt 2 ]; then echo "Usage: scripts/gen_manual.sh <language> <type>" echo "type: html phpweb test demo" exit 1 fi language=$1 type=$2 realtype=$type stylesheetdir=../stylesheets php=php manualfile=manual.xml test=0 if [ ! -d ../manual/$language ]; then echo "There is no manual for language $language" exit 2 fi if [ ! -d ../build ]; then mkdir ../build fi if [ ! -d ../build/$language ]; then mkdir ../build/$language fi if [ $type == "test" ]; then if [ $# -lt 3 ]; then echo "Please pass the id as third parameter" exit 4 fi test=1 manualfile=test_manual.xml type=html #generate the file $php -q liveGen.php $3 fi build_dir=../build/$language/$type manualpath=../scripts/$manualfile if [ $type == "html" ]; then xslfile=$stylesheetdir/html/chunk.xsl elif [ $type == "phpweb" ]; then xslfile=$stylesheetdir/html/phpweb.xsl elif [ $type == "demo" ]; then xslfile=$stylesheetdir/html/chunk.xsl manualpath=../manual/demo_manual.xml else echo "There is no type $type." exit 3 fi if [ $test == "1" ]; then build_dir=../build/$language/test fi # # we've got all necessary data; generate the manual # if [ ! -d $build_dir ]; then mkdir $build_dir else #empty the dir rm -R $build_dir/* fi xsltproc --param base.dir "'$build_dir/'" --xinclude $xslfile $manualpath #highlight php sources #we need to escape the wildcard, because php doesn't allow enough # parameters - and could someone please tell me how to prevent # wildcard escaping? That "\\*" is a hack which is only understood # by highlight.php $php ../scripts/highlight.php php "../build/$language/$realtype/\\*.html" #distribute over several files if [ $type == "html" ] && [ $test == "0" ] && [ ! $type == "demo" ]; then $php -q ../scripts/distribute_html.php "../build/$language/html" $php -q ../scripts/copy_images.php "../build/$language/html" fi http://cvs.php.net/viewcvs.cgi/php-gtk-doc/scripts/gen_manualxml.php?view=markup&rev=1.1 Index: php-gtk-doc/scripts/gen_manualxml.php +++ php-gtk-doc/scripts/gen_manualxml.php <?php /** * generates manual.xml for a specific language from the manual.xml.in template */ $template = 'scripts/manual.xml.in'; if (!file_exists($template)) { die("\r\nRun the script from the base php-gtk-doc directory\r\n"); } if ($GLOBALS['argc'] < 2 || strlen($GLOBALS['argv'][1]) != 2) { die("\r\nError: Pass the desired language as only parameter\r\n"); } $lang = $GLOBALS['argv'][1]; if (!is_dir('manual/' . $lang)) { die("\r\nThere is no directory for language $lang\r\n"); } $outputfile = 'scripts/manual.xml'; $hdl = fopen($outputfile, "w+"); fwrite($hdl, str_replace('@PHP_GTK2_DOC_BUILD_DATE@', date('r'), str_replace('@LANG@', $lang, str_replace('@LANGDIR@', "manual/$lang", str_replace('@MANUAL@', "manual", str_replace('<!DOCTYPE', "<!-- DO NOT EDIT THIS FILE! IT IS GENERATED AUTOMATICALLY BY gen_manualxml.php -->\r\n<!DOCTYPE", str_replace('@DOCBOOK_DOCTYPE@', '-//PHP Group//DTD DocBk XML V3.1.7-Based Extension//EN', file_get_contents($template) )))))) ); fclose($hdl); ?> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/scripts/gen_name_to_id.xsl?view=markup&rev=1.1 Index: php-gtk-doc/scripts/gen_name_to_id.xsl +++ php-gtk-doc/scripts/gen_name_to_id.xsl <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:doc="http://nwlash.com/xsl/documentation/1.0" version="1.0"> <xsl:output method="text" encoding="UTF-8" indent="no"/> <xsl:template match="*" /> <xsl:template match="classentry|refentry"> <xsl:variable name="id" select="@id"/> <xsl:variable name="classname" > <xsl:choose> <xsl:when test="count(self::classentry)!='0'"> <xsl:value-of select="./classmeta/classtitle"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="./refmeta/refentrytitle"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:text disable-output-escaping="yes"><xsl:when test="$classname='</xsl:text> <xsl:value-of select="$classname"/> <xsl:text disable-output-escaping="yes">'"><xsl:text></xsl:text> <xsl:value-of select="$id" /> <xsl:text disable-output-escaping="yes"></xsl:text></xsl:when></xsl:text> </xsl:template> <xsl:template match="method|constructor"> <xsl:variable name="id" select="@id"/> <xsl:variable name="funcname" > <xsl:value-of select="./funcsynopsis/funcprototype/funcdef/function"/> </xsl:variable> <xsl:text disable-output-escaping="yes"><xsl:when test="$funcname='</xsl:text> <xsl:value-of select="$funcname"/> <xsl:text disable-output-escaping="yes">' and $class='</xsl:text> <xsl:choose> <xsl:when test="count(ancestor::classentry)!='0'"> <xsl:value-of select="ancestor-or-self::classentry/classmeta/classtitle"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="ancestor-or-self::refentry/refmeta/refentrytitle"/> </xsl:otherwise> </xsl:choose> <xsl:text disable-output-escaping="yes">'"><xsl:text></xsl:text> <xsl:value-of select="$id" /> <xsl:text disable-output-escaping="yes"></xsl:text></xsl:when></xsl:text> </xsl:template> <!-- <xsl:template match="attribute"> <xsl:variable name="id" select="@id"/> <xsl:variable name="attrname" > <xsl:value-of select="./attributename"/> </xsl:variable> <xsl:text disable-output-escaping="yes"><xsl:when test="$attrname='</xsl:text> <xsl:value-of select="$attrname"/> <xsl:text disable-output-escaping="yes">'"><xsl:text></xsl:text> <xsl:value-of select="$id" /> <xsl:text disable-output-escaping="yes"></xsl:text></xsl:when></xsl:text> </xsl:template> --> <xsl:template match="prop"> <xsl:variable name="id" select="@id"/> <xsl:variable name="propname" > <xsl:value-of select="./propname"/> </xsl:variable> <xsl:text disable-output-escaping="yes"><xsl:when test="$propname='</xsl:text> <xsl:value-of select="$propname"/> <xsl:text disable-output-escaping="yes">' and $class='</xsl:text> <xsl:choose> <xsl:when test="count(ancestor::classentry)!='0'"> <xsl:value-of select="ancestor-or-self::classentry/classmeta/classtitle"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="ancestor-or-self::refentry/refmeta/refentrytitle"/> </xsl:otherwise> </xsl:choose> <xsl:text disable-output-escaping="yes">'"><xsl:text></xsl:text> <xsl:value-of select="$id" /> <xsl:text disable-output-escaping="yes"></xsl:text></xsl:when></xsl:text> </xsl:template> <xsl:template match="field"> <xsl:variable name="id" select="@id"/> <xsl:variable name="fieldname" > <xsl:value-of select="./fieldname"/> </xsl:variable> <xsl:text disable-output-escaping="yes"><xsl:when test="$fieldname='</xsl:text> <xsl:value-of select="$fieldname"/> <xsl:text disable-output-escaping="yes">' and $class='</xsl:text> <xsl:choose> <xsl:when test="count(ancestor::classentry)!='0'"> <xsl:value-of select="ancestor-or-self::classentry/classmeta/classtitle"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="ancestor-or-self::refentry/refmeta/refentrytitle"/> </xsl:otherwise> </xsl:choose> <xsl:text disable-output-escaping="yes">'"><xsl:text></xsl:text> <xsl:value-of select="$id" /> <xsl:text disable-output-escaping="yes"></xsl:text></xsl:when></xsl:text> </xsl:template> <xsl:template match="signal"> <xsl:variable name="id" select="@id"/> <xsl:variable name="signame" > <xsl:value-of select="./signalname"/> </xsl:variable> <xsl:text disable-output-escaping="yes"><xsl:when test="$signame='</xsl:text> <xsl:value-of select="$signame"/> <xsl:text disable-output-escaping="yes">'"><xsl:text></xsl:text> <xsl:value-of select="$id" /> <xsl:text disable-output-escaping="yes"></xsl:text></xsl:when></xsl:text> </xsl:template> <xsl:template match="/"> <xsl:text disable-output-escaping="yes"> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:doc="http://nwlash.com/xsl/documentation/1.0" version="1.0"> <xsl:template name="get_id_from_name"> <xsl:param name="classname" /> <xsl:choose> </xsl:text> <xsl:apply-templates select=".//classentry" /> <xsl:text disable-output-escaping="yes"> <xsl:otherwise> <xsl:text>no</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:text> <xsl:text disable-output-escaping="yes"> <xsl:template name="get_func_id_from_name"> <xsl:param name="funcname" /> <xsl:param name="class" select="'no'" /> <xsl:choose> </xsl:text> <xsl:apply-templates select=".//method|.//constructor" /> <xsl:text disable-output-escaping="yes"> <xsl:otherwise> <xsl:text>no</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:text> <xsl:if test="count(.//prop)>0"> <xsl:text disable-output-escaping="yes"> <xsl:template name="get_prop_id_from_name"> <xsl:param name="propname" /> <xsl:param name="class" select="no" /> <xsl:choose> </xsl:text> <xsl:apply-templates select=".//prop" /> <xsl:text disable-output-escaping="yes"> <xsl:otherwise> <xsl:text>no</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:text> </xsl:if> <xsl:if test="count(.//field)>0"> <xsl:text disable-output-escaping="yes"> <xsl:template name="get_field_id_from_name"> <xsl:param name="fieldname" /> <xsl:param name="class" select="no" /> <xsl:choose> </xsl:text> <xsl:apply-templates select=".//field" /> <xsl:text disable-output-escaping="yes"> <xsl:otherwise> <xsl:text>no</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:text> </xsl:if> <xsl:text disable-output-escaping="yes"> <xsl:template name="get_sig_id_from_name"> <xsl:param name="signame" /> </xsl:text> <xsl:text disable-output-escaping="yes"> <xsl:choose> </xsl:text> <xsl:apply-templates select=".//signal" /> <xsl:text disable-output-escaping="yes"> <xsl:otherwise> </xsl:text> <xsl:text disable-output-escaping="yes"> <xsl:text>no</xsl:text> </xsl:text> <xsl:text disable-output-escaping="yes"> </xsl:otherwise> </xsl:choose> </xsl:text> <xsl:text> </xsl:template> </xsl:stylesheet> </xsl:text> </xsl:template> </xsl:stylesheet> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/scripts/manual.xml.in?view=markup&rev=1.1 Index: php-gtk-doc/scripts/manual.xml.in +++ php-gtk-doc/scripts/manual.xml.in <?xml version='1.0' encoding='utf-8'?> <!DOCTYPE book PUBLIC "@DOCBOOK_DOCTYPE@" "../dbxml/phpgtkdoc.dtd"[ <!-- Defaults for entities that should be defined in language-defs --> <!ENTITY % language-defs SYSTEM "../@LANGDIR@/language-defs.ent"> %language-defs; <!-- These are language independent --> <!ENTITY phpgtk2doc.build-date "@PHP_GTK2_DOC_BUILD_DATE@"> <!ENTITY % global.entities SYSTEM "../@MANUAL@/global.ent"> <!ENTITY % global.chapters SYSTEM "../@MANUAL@/chapters.ent"> <!ENTITY % global.contribs SYSTEM "../@MANUAL@/contributors.ent"> %global.entities; %global.chapters; %global.contribs; <!ENTITY tutorials SYSTEM "../@MANUAL@/tutorials.xml"> <!ENTITY reference SYSTEM "../@MANUAL@/reference.xml"> <!ENTITY appendix SYSTEM "../@MANUAL@/appendix.xml"> ]> <set id="phpgtk.docs" lang="@LANG@"> &bookinfo; &preface; &tutorials; &reference; &appendix; </set> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/scripts/merge_updates.php?view=markup&rev=1.1 Index: php-gtk-doc/scripts/merge_updates.php +++ php-gtk-doc/scripts/merge_updates.php #!/usr/local/bin/php <?php /** * Class for combining a current list of manual file * updates with an existing list. * * Updated files should be listed as a set of HTML * links. The resulting file is an HTML fragment * that consists of precisely that, and nothing more. * * @original author Scott Mattocks * @altered by Steph Fox to accommodate XSLT changes */ // Check number of args if ($GLOBALS["argc"] != 3) { exit("Purpose: Merge pre-formatted contents of new updates file into pre-existing updates file.\r\n" .'Usage: merge-updates.php [ newupdatesfile ] [ outfile ] ' ."\r\n" ); } // Not really max. It can be overridden by // very busy scribblers: see mergeUpdates() define ('MAX_UPDATES_TO_SHOW', 15); class ManualUpdates { /** * File containing the new update data. * @var string */ var $newfile; /** * Pre-existing updates file; used for output. * @var string */ var $outfile; /** * Array that will contain the new update data. * @var array */ var $newarray = array(); /** * Array that will contain the current data. * @var array */ var $oldarray = array(); /** * Array that will carry the merged info. * @var array */ var $output = array(); var $maximum; /** * PHP 4 constructor. * Sets files name and content variables * * @param string updatesfile, string outputfile * @return void */ function ManualUpdates($newupdates, $outupdates) { $this->newfile = $newupdates; $this->outfile = $outupdates; $this->newarray = $this->_getUpdates($this->newfile); $this->oldarray = $this->_getUpdates($this->outfile); } /** * Value checking. * Picks up file contents. * * @param string filename * @return array filecontents */ function _getUpdates($filename) { if (!is_readable($filename)) { trigger_error('Cannot get updates from ' . $filename, E_USER_WARNING); trigger_error($filename . ' does not exist or is not readable by this user.', E_USER_ERROR); exit; } return file($filename); } /** * Merges and sorts the arrays without array_intersect_key() or even a useful timestamp <sigh /> * Rewrite this function when we get PHP 5 and/or `date %s` * Sets output array * * @param none * @return void */ function mergeUpdates() { // We want to show MAX_UPDATES_TO_SHOW or the total of // tonight's updates, whichever is the greater. Apparently. $this->maximum = max(MAX_UPDATES_TO_SHOW, sizeof($this->newarray)); $merged = array_merge($this->newarray, $this->oldarray); // Lines aren't unique. Titles are... foreach ($merged as $line) { $stripped = strip_tags($line); $titles[] = substr($stripped, strpos($stripped, ' ')); } $unique = array_unique($titles); for ($i = 0; $i < sizeof($merged); $i++) { if (array_key_exists($i, $unique) && sizeof($this->output) < $this->maximum) { $this->output[] = $merged[$i]; } else { unset($merged[$i]); } } } /** * Writes the updated output array to file, the old-fashioned way * * @param none * @return void */ function writeUpdatesToFile() { $fp = fopen($this->outfile, 'w'); foreach ($this->output as $line) { fwrite($fp, $line); } fclose($fp); } } // Set the parameter vars $newupdates = $argv[1]; $outupdates = $argv[2]; // Create the current list of updates. $mu =& new ManualUpdates($newupdates, $outupdates); $mu->mergeUpdates(); $mu->writeUpdatesToFile(); ?> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/scripts/mtoc.xml.in?view=markup&rev=1.1 Index: php-gtk-doc/scripts/mtoc.xml.in +++ php-gtk-doc/scripts/mtoc.xml.in <?xml version='1.0' encoding='utf-8' ?> <!DOCTYPE book PUBLIC "@DOCBOOK_DOCTYPE@" "@srcdir@/dbxml/phpgtkdoc.dtd"[ <!-- Defaults for entities that should be defined in language-defs --> <!ENTITY % language-defs SYSTEM "@UTF8LANG@/language-defs.ent"> %language-defs; <!-- These are language independent --> <!ENTITY phpgtk.build-date "@PHP_GTK_DOC_BUILD_DATE@"> <!ENTITY % global.entities SYSTEM "global.ent"> <!ENTITY % global.chapters SYSTEM "chapters.ent"> %global.entities; %global.chapters; <!ENTITY userguide SYSTEM "userguide.xml"> <!ENTITY tutorials SYSTEM "tutorials.xml"> <!ENTITY reference SYSTEM "reference.xml"> <!ENTITY appendix SYSTEM "appendix.xml"> <!ENTITY keysyms SYSTEM "keysyms.xml"> <!ENTITY license SYSTEM "license.xml"> ]> <mtoc> &bookinfo; &preface; &userguide; &tutorials; &reference; &appendix; </mtoc> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/scripts/testclasses.xml.in?view=markup&rev=1.1 Index: php-gtk-doc/scripts/testclasses.xml.in +++ php-gtk-doc/scripts/testclasses.xml.in <?xml version="1.0" encoding='utf-8' ?> <book id="testclasses"> <title>Test classes</title> <classset id="testclasslist"> <title>Classes to test</title> <partintro>This is a list of classes which have recently been changed</partintro> @TEST_REFERENCES@ </classset> </book> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/scripts/testmanual.xml.in?view=markup&rev=1.1 Index: php-gtk-doc/scripts/testmanual.xml.in +++ php-gtk-doc/scripts/testmanual.xml.in <?xml version='1.0' encoding='utf-8' ?> <!DOCTYPE book PUBLIC "@DOCBOOK_DOCTYPE@" "../dbxml/phpgtkdoc.dtd"[ <!-- Defaults for entities that should be defined in language-defs --> <!ENTITY % language-defs SYSTEM "../@LANGDIR@/language-defs.ent"> %language-defs; <!-- These are language independent --> <!ENTITY phpgtk2doc.build-date "@PHP_GTK2_DOC_BUILD_DATE@"> <!ENTITY % global.entities SYSTEM "../@MANUAL@/global.ent"> <!ENTITY % global.chapters SYSTEM "../@MANUAL@/chapters.ent"> <!ENTITY % global.contribs SYSTEM "../@MANUAL@/contributors.ent"> %global.entities; %global.chapters; %global.contribs; <!ENTITY testclasses SYSTEM "testclasses.xml"> ]> <set id="phpgtk.docs" lang="@LANG@"> &testclasses; </set>