cvs: peardoc / make-partial.php
| From: | Martin Jansen | Date: | Sat, 11 Jun 2005 16:11:43 +0000 |
| Subject: | cvs: peardoc / make-partial.php | ||
| Groups: | php.pear.doc | ||
| Request: | Send a blank email to pear-doc+get-6294@lists.php.net to get a copy of this message | ||
mj Sat Jun 11 12:11:43 2005 EDT
Modified files:
/peardoc make-partial.php
Log:
* Partial builds can now also be done without the readline extension.
In this case one must specify the sections using the --include
option.
* Added an option --help which (surprise, surprise) prints a help text.
# I bet that someone is maintaining a version of this script for the
# PHP documentation. Could this person please take care of synching
# the changes there? Thanks.
http://cvs.php.net/diff.php/peardoc/make-partial.php?r1=1.3&r2=1.4&ty=u
Index: peardoc/make-partial.php
diff -u peardoc/make-partial.php:1.3 peardoc/make-partial.php:1.4
--- peardoc/make-partial.php:1.3 Tue Feb 15 11:52:01 2005
+++ peardoc/make-partial.php Sat Jun 11 12:11:43 2005
@@ -12,27 +12,13 @@
*
* @author Martin Jansen <mj@php.net>
* @copyright 2005 The PEAR Group
- * @version CVS: $Id: make-partial.php,v 1.3 2005/02/15 16:52:01 mj Exp $
+ * @version CVS: $Id: make-partial.php,v 1.4 2005/06/11 16:11:43 mj Exp $
*/
require_once "Console/Getopt.php";
$console = new Console_Getopt;
$args = $console->getopt($console->readPHPArgv(), array(),
- array("format=", "include="));
-
-if (!function_exists("readline")) {
- echo "Error: The readline extension could not be found!";
- exit(1);
-}
-
-$file = file("manual.xml.in");
-if (!$file) {
- echo "Error: Unable to read manual.xml.in!";
- exit(1);
-}
-
-copy("manual.xml.in", "manual.xml.in.partial-backup");
-register_shutdown_function("restoreFile");
+ array("format=", "include=", "help"));
// {{{ gather arguments
@@ -40,7 +26,10 @@
$sections = array();
foreach ($args[0] as $arg) {
- if ($arg[0] == "--format") {
+ if ($arg[0] == "--help") {
+ showHelp();
+ exit(0);
+ } elseif ($arg[0] == "--format") {
$format = $arg[1];
} elseif ($arg[0] == '--include') {
$sections[] = $arg[1];
@@ -49,6 +38,24 @@
// }}}
+$hasReadline = true;
+if (!function_exists("readline")) {
+ $hasReadline = false;
+ echo "Warning: The readline extension could not be found!\n";
+ if (count($sections) == 0) {
+ echo "Exiting because no --include parameters were specified.\n";
+ exit(1);
+ }
+}
+
+$file = file("manual.xml.in");
+if (!$file) {
+ echo "Error: Unable to read manual.xml.in!";
+ exit(1);
+}
+
+copy("manual.xml.in", "manual.xml.in.partial-backup");
+register_shutdown_function("restoreFile");
$newFile = "";
$partStack = array();
@@ -71,7 +78,7 @@
} else {
echo "NO\n";
}
- } else {
+ } else if ($hasReadline) {
$include = readline("Include " . $matches[1] . "? [NO] ");
$includePart = evaluate($include);
}
@@ -120,7 +127,7 @@
} else {
echo "NO\n";
}
- } else {
+ } else if ($hasReadline) {
$include = evaluate(readline("Include " . $matches[2] . "? [NO]
"));
}
@@ -185,4 +192,22 @@
return false;
}
+/**
+ * Prints a usage notice for the script
+ *
+ * @return void
+ */
+function showHelp()
+{
+ echo "Usage: make-partial.php [--format <format>] [--include <section1>]
[--include <section2>] ...\n";
+ echo " make-partial.php --help\n";
+ echo "\n";
+ echo " --format <format> Which format to build. Can be one of 'html',
'pearweb'.\n";
+ echo " Default is 'html'.\n";
+ echo " --include <section> Automatically include certain sections of the
manual\n";
+ echo " without asking for them explicitely. This also
works\n";
+ echo " on setups where the readline extension is not
available.\n";
+ echo " --help Prints this help text.\n\n";
+}
+
// }}}