[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pear-doc
Subject:    [PEAR-DOC] cvs: peardoc / make-partial.php
From:       "Sean Coates" <sean () php ! net>
Date:       2005-01-28 15:12:26
Message-ID: cvssean1106925146 () cvsserver
[Download RAW message or body]

sean		Fri Jan 28 10:12:26 2005 EDT

  Modified files:              
    /peardoc	make-partial.php 
  Log:
  added --include=<section> support
  
http://cvs.php.net/diff.php/peardoc/make-partial.php?r1=1.1&r2=1.2&ty=u
Index: peardoc/make-partial.php
diff -u peardoc/make-partial.php:1.1 peardoc/make-partial.php:1.2
--- peardoc/make-partial.php:1.1	Thu Jan 27 14:11:39 2005
+++ peardoc/make-partial.php	Fri Jan 28 10:12:25 2005
@@ -1,6 +1,6 @@
 #!/usr/bin/env php
 <?php
-/**
+/** vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
  * Script to trigger partial builds of the PEAR manual
  *
  * LICENSE: This source file is subject to version 3.0 of the PHP license
@@ -11,7 +11,7 @@
  *
  * @author    Martin Jansen <mj@php.net>
  * @copyright 2005 The PEAR Group
- * @version   CVS: $Id: make-partial.php,v 1.1 2005/01/27 19:11:39 mj Exp $
+ * @version   CVS: $Id: make-partial.php,v 1.2 2005/01/28 15:12:25 sean Exp $
  */
 
 require_once "Console/Getopt.php";
@@ -33,6 +33,22 @@
 copy("manual.xml.in", "manual.xml.in.partial-backup");
 register_shutdown_function("restoreFile");
 
+// {{{ gather arguments
+
+$format = "html";
+$sections = array();
+
+foreach ($args[0] as $arg) {
+    if ($arg[0] == "--format") {
+        $format = $arg[1];
+    } elseif ($arg[0] == '--include') {
+        $sections[] = $arg[1];
+    }
+}
+
+// }}}
+
+
 $newFile = "";
 $partStack = array();
 $includePart = true;
@@ -47,8 +63,17 @@
     if (preg_match("/<part id=\"([a-z-]+)\">/", $line, $matches)) {
         $inPart = true;
 
-        $include = readline("Include " . $matches[1] . "? [NO] ");
-        $includePart = evaluate($include);
+        if ($sections) {
+            echo "Including ". $matches[1] ."? ";
+            if ($includePart = in_string($sections, $matches[1])) {
+                echo "YES\n";
+            } else {
+                echo "NO\n";
+            }
+        } else {
+            $include = readline("Include " . $matches[1] . "? [NO] ");
+            $includePart = evaluate($include);
+        }
 
         if ($includePart == true) {
             $newFile .= $line;
@@ -86,7 +111,17 @@
         }
         
         if (preg_match("/(\s\t)*&([a-z0-9\.-]+);/", $line, $matches)) {
-            $include = evaluate(readline("Include " . $matches[2] . "? [NO] "));
+
+            if ($sections) {
+                echo "Including ". $matches[2] ."? ";
+                if ($include = in_string($sections, $matches[2])) {
+                    echo "YES\n";
+                } else {
+                    echo "NO\n";
+                }
+            } else {
+                $include = evaluate(readline("Include " . $matches[2] . "? [NO] "));
+            }
             
             if ($include == true) {
                 $partStack[] = $line;
@@ -101,13 +136,6 @@
 
 // {{{ Run the build scripts
 
-$format = "html";
-foreach ($args[0] as $arg) {
-    if ($arg[0] == "--format") {
-        $format = $arg[1];
-    }
-}
-
 $cmd = "make " . $format;
 passthru($cmd);
 
@@ -138,4 +166,18 @@
     return false;
 }
 
+/**
+ * $needle (array) is in $haystack?
+ *
+ */
+function in_string($needle, $haystack)
+{
+    foreach ((array) $needle AS $n) {
+        if (stripos($haystack, $n) !== false) {
+            return true;
+        }
+    }
+    return false;
+}
+
 // }}}

-- 
PEAR Documentation List Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic