hholzgra Tue Feb 8 13:24:59 2005 EDT
Modified files:
/phpdoc/scripts file-entities.php.in
Log:
Generate entities and <part> files for PECL and standalone extensions
http://cvs.php.net/diff.php/phpdoc/scripts/file-entities.php.in?r1=1.24&r2=1.25&ty=u
Index: phpdoc/scripts/file-entities.php.in
diff -u phpdoc/scripts/file-entities.php.in:1.24
phpdoc/scripts/file-entities.php.in:1.25
--- phpdoc/scripts/file-entities.php.in:1.24 Tue Feb 8 06:53:14 2005
+++ phpdoc/scripts/file-entities.php.in Tue Feb 8 13:24:58 2005
@@ -17,7 +17,7 @@
| Gabor Hojtsy <[EMAIL PROTECTED]> |
+----------------------------------------------------------------------+
- $Id: file-entities.php.in,v 1.24 2005/02/08 11:53:14 hholzgra Exp $
+ $Id: file-entities.php.in,v 1.25 2005/02/08 18:24:58 hholzgra Exp $
*/
/**
@@ -31,12 +31,15 @@
* . Reserved constant part (temporary)
* . Translated language files with English ones as fallbacks
* . Global function index
+ * . additional extension documentation from PECL
+ * . additional extension documentation from standalone extensions
*
* Also take in account, that if XSLT style sheets are used,
* special file:/// prefixed path values are needed.
*
*/
+
// Always flush output
ob_implicit_flush();
// This script runs for a long time
@@ -51,7 +54,7 @@
// the below preg_replace have to be done only using binary php complied on
MSVC.
// let's find if php was complied by cygwin:
$cygwin_complied = eregi("CYGWIN",php_uname()) ? true : false;
-
+
// The output directory, which we need to parse for windows specific
// things, and correct all problems is needed.
// Also use absolute path to have meaningful error messages
@@ -60,7 +63,7 @@
// this path if used for saving the ent file:
$script_out_dir = $cygwin_complied ? "@WORKDIR@" : $out_dir;
-// The documentation source directory
+// The documentation source directory
$srcdir = abs_path("@SRCDIR@");
// The translation subdir to use
@@ -69,12 +72,103 @@
// The original directory is in the base directory, and named "en"
$orig_dir = "$srcdir/en";
+// PHP, PECL and additional extension source directories if given
+$php_source = ("@PHP_SOURCE@" === "no" ? false : abs_path("@PHP_SOURCE@"));
+$pecl_source = ("@PECL_SOURCE@" === "no" ? false : abs_path("@PECL_SOURCE@"));
+$ext_sources = array();
+foreach (explode(":", "@EXT_SOURCE@") as $path) {
+ if(!empty($path)) {
+ $ext_sources[]= abs_path($path);
+ }
+}
+
// ......:ENTITY
CREATION:......................................................
// Put all the file entitites into $entities
$entities = array();
file_entities($orig_dir, $trans_dir, $orig_dir, $entities);
+// additional documentation embedded in PECL extensions
+$pecl_extensions = array();
+
+if($pecl_source) {
+ $dh = opendir($pecl_source);
+
+ $pecl_dirs = array();
+ while($dir = readdir()) {
+ if($dir{0} === ".") continue; // ignore system dir entries and hidden
files
+ $pecl_dirs[] = $dir;
+ }
+
+ sort($pecl_dirs);
+
+ foreach ($pecl_dirs as $dir) {
+ $docdir = "$pecl_source/$dir/manual";
+
+ if (@is_dir($docdir)) {
+
+ $dirent = str_replace("_","-",$dir);
+ if(@is_dir("$docdir/en")) {
+ file_entities("$docdir/en", "$docdir/@LANGDIR@", "$docdir/en",
$entities, "reference.$dirent");
+ } else if (@is_dir("$docdir/$dir")) {
+ file_entities("$docdir/$dir", "$docdir/$dir", "$docdir/$dir",
$entities, "reference.$dirent");
+ } else if (@is_dir("$docdir/$dirent")) {
+ file_entities("$docdir/$dirent", "$docdir/$dirent",
"$docdir/$dirent", $entities, "reference.$dirent");
+ } else {
+ continue;
+ }
+ $pecl_extensions[] = "&reference.$dirent.reference;";
+ }
+ }
+ closedir($dh);
+}
+
+$fp = fopen("$srcdir/entities/pecl_extensions.xml","w");
+if(count($pecl_extensions)) {
+ fputs($fp, "<?xml version='1.0' encoding='iso-8859-1' ?>
+ <part id='pecl-funcref'>
+ <title>PECL function reference</title><!-- TODO lang entity -->
+");
+ foreach ($pecl_extensions as $ext) {
+ fputs($fp, " $ext\n");
+ }
+ fputs($fp," </part>\n");
+}
+fclose($fp);
+
+$entities[] = entstr("pecl.extensions", "entities/pecl_extensions.xml");
+
+// additional documentation embedded in external extension sources
+$addon_extensions = array();
+foreach ($ext_sources as $ext_dir) {
+ $docdir = "$ext_dir/manual";
+ $dir = basename($ext_dir);
+ $dirent = str_replace("_","-",$dir);
+ if(@is_dir("$docdir/en/reference/$dir")) {
+ file_entities("$docdir/en/reference/$dir",
"$docdir/@LANGDIR@/reference/$dir", "$docdir/en/reference/$dir", $entities,
"reference.$dirent");
+ } else if (@is_dir("$docdir/$dir")) {
+ file_entities("$docdir/$dir", "$docdir/$dir", "$docdir/$dir",
$entities, "reference.$dirent");
+ } else if (@is_dir("$docdir/$dirent")) {
+ file_entities("$docdir/$dirent", "$docdir/$dirent", "$docdir/$dirent",
$entities, "reference.$dirent");
+ } else {
+ continue;
+ }
+ $addon_extensions[] = "&reference.$dirent.reference;";
+}
+$fp = fopen("$srcdir/entities/addon_extensions.xml","w");
+if(count($addon_extensions)) {
+ fputs($fp, "<?xml version='1.0' encoding='iso-8859-1' ?>
+ <part id='addon-funcref'>
+ <title>add-on function reference</title><!-- TODO lang entity -->
+");
+ foreach ($addon_extensions as $ext) {
+ fputs($fp, " $ext\n");
+ }
+ fputs($fp," </part>\n");
+}
+fclose($fp);
+$entities[] = entstr("addon.extensions", "addon_extensions.xml");
+
// Open file for appending and write out all entitities
$fp = fopen("$script_out_dir/entities/file-entities.ent", "w");
if (!$fp) {
@@ -174,31 +268,38 @@
* @param array $entities Entities string array
* @return boolean Success signal
*/
-function file_entities($work_dir, $trans_dir, $orig_dir, &$entities) {
-
+function file_entities($work_dir, $trans_dir, $orig_dir, &$entities,
$prefix=false) {
+ // Skip the function directory not under "reference". That
+ // folder is only kept for backward compatibility and only
+ // in the English version of the docs.
+ if (!$prefix && strpos($work_dir, "functions") &&
!preg_match("!reference/.*/functions!", $work_dir)) {
+ return;
+ }
+
// Compute translated version's path
$trans_path = str_replace($orig_dir, $trans_dir, $work_dir);
// Try to open English working directory
$dh = opendir($work_dir);
- if (!$dh) { return FALSE; }
+ if (!$dh) {
+ return FALSE;
+ }
// If the working directory is a reference functions directory,
- // The start to generate a functions.xml file for that folder.
- if (preg_match("!/reference/.*/functions$!", $work_dir)) {
-
+ // then start to generate a functions.xml file for that folder.
+ if (preg_match("!/functions$!", $work_dir)) {
// Start new functions file with empty entity set
$function_entities = array();
$functions_file = "$work_dir.xml";
// Get relative file path to original directory, and form an entity
- $functions_file_entity = fname2entname(str_replace("$orig_dir/", "",
$work_dir));
+ $functions_file_entity = str_replace("$orig_dir/", "", $work_dir);
+ $functions_file_entity = fname2entname($functions_file_entity,
$prefix);
$entities[] = entstr($functions_file_entity, $functions_file);
}
// While we can read that directory
while (($file = readdir($dh)) !== FALSE) {
-
// If file name begins with . skip it
if ($file{0} == ".") { continue; }
@@ -206,7 +307,7 @@
// CVS, recursively go into it, and generate entities
if (is_dir($work_dir . "/" . $file)) {
if ($file == "CVS") { continue; }
- file_entities($work_dir . "/" . $file, $trans_dir, $orig_dir,
$entities);
+ file_entities($work_dir . "/" . $file, $trans_dir, $orig_dir,
$entities, $prefix);
}
// If the file name ends in ".xml"
@@ -218,7 +319,7 @@
"",
$work_dir . "/" . preg_replace("!\\.xml$!", "", $file)
);
- $name = fname2entname($name);
+ $name = fname2entname($name, $prefix);
// If this is a functions directory, collect it into
// the special $function_entities array
@@ -277,7 +378,7 @@
"",
$work_dir . "/" . preg_replace("!\\.xml$!", "", $file)
);
- $name = fname2entname($name);
+ $name = fname2entname($name, $prefix);
// If the file found is not in the English dir, append to
entities list
if (!file_exists("$work_dir/$file")) {
@@ -302,9 +403,13 @@
* @param string $fname File name
* @return string Entity name
*/
-function fname2entname($fname)
+function fname2entname($fname, $prefix=false)
{
- return str_replace("_", "-", str_replace("/", ".", $fname));
+ $ent = str_replace("_", "-", str_replace("/", ".", $fname));
+ if ($prefix && !strstr($ent, $prefix)) {
+ $ent = "$prefix.$ent";
+ }
+ return $ent;
}
/**
@@ -330,6 +435,6 @@
* @param string $path Orginal path
*/
function strip_cygdrive($path){
- return preg_replace("!^/cygdrive/(\\w)/!", "\\1:/", $path);
+ return preg_replace("!^/cygdrive/(\\w)/!", "\\1:/", $path);
}
?>