Wez Furlong wrote:
Your patch seems to be missing a $this->last_id somewhere, but I can't
test nothing now :(
Should be fixed now; thanks :)
Great, it's perfect now :)
I also have a patch to exclude some unwanted dockbook ids, like
missing-stuff (see BUGS). I implmented it with a $banned_ids array
in the mk_XXX.php files et a if(in_array()) in mktoc.php. Do this
sounds good to you or should I change something ?
Let's see the patch :)
Attached !
didou
? b.sh
? log.txt
? patch_banned.txt
? themes/didou
Index: BUGS
===================================================================
RCS file: /repository/livedocs/BUGS,v
retrieving revision 1.6
diff -u -r1.6 BUGS
--- BUGS 1 May 2004 10:08:22 -0000 1.6
+++ BUGS 24 May 2004 16:02:08 -0000
@@ -1,8 +1,7 @@
KNOWN BUGS
==========
- - The reserved constants and the missing stuff section are not working,
- the later would be better left out from the livedocs output.
+ - The reserved constants are not working.
- The ref.pcre page does not link properly to the pattern modifiers and
pattern syntax docs (it thinks that those are functions but this is
Index: build.sh
===================================================================
RCS file: /repository/livedocs/build.sh,v
retrieving revision 1.24
diff -u -r1.24 build.sh
--- build.sh 5 May 2004 01:37:02 -0000 1.24
+++ build.sh 24 May 2004 16:02:08 -0000
@@ -42,7 +42,7 @@
#Just for debuging
#xmllint --format ${GENDIR}/toc-ugly.xml > ${GENDIR}/toc.xml
- ${PHP} ${LIVEDOCSFORPHP}/mktoc.php ${GENDIRFORPHP}/toc-ugly.xml >
${GENDIR}/toc-insert.sql
+ ${PHP} ${LIVEDOCSFORPHP}/mktoc.php ${GENDIRFORPHP}/toc-ugly.xml
${BUILDTYPE} > ${GENDIR}/toc-insert.sql
fi
echo -n "Making index for $i: "
Index: mk_peardoc.php
===================================================================
RCS file: /repository/livedocs/mk_peardoc.php,v
retrieving revision 1.7
diff -u -r1.7 mk_peardoc.php
--- mk_peardoc.php 1 May 2004 11:34:50 -0000 1.7
+++ mk_peardoc.php 24 May 2004 16:02:08 -0000
@@ -29,6 +29,8 @@
$entities_dir = '.';
+$banned_ids = array();
+
function search_parse_dir($path, $section)
{
global $idx, $toca, $tocd;
Index: mk_phpdoc.php
===================================================================
RCS file: /repository/livedocs/mk_phpdoc.php,v
retrieving revision 1.10
diff -u -r1.10 mk_phpdoc.php
--- mk_phpdoc.php 24 May 2004 12:19:39 -0000 1.10
+++ mk_phpdoc.php 24 May 2004 16:02:08 -0000
@@ -29,6 +29,8 @@
$entities_dir = 'entities';
+$banned_ids = array('missing-stuff');
+
function search_parse_dir($path, $section) {
global $idx, $toca, $tocd;
Index: mk_smarty.php
===================================================================
RCS file: /repository/livedocs/mk_smarty.php,v
retrieving revision 1.7
diff -u -r1.7 mk_smarty.php
--- mk_smarty.php 1 May 2004 11:34:50 -0000 1.7
+++ mk_smarty.php 24 May 2004 16:02:08 -0000
@@ -29,6 +29,8 @@
$entities_dir = 'entities';
+$banned_ids = array();
+
function search_parse_dir($path, $section) {
global $idx, $toca, $tocd;
Index: mktoc.php
===================================================================
RCS file: /repository/livedocs/mktoc.php,v
retrieving revision 1.9
diff -u -r1.9 mktoc.php
--- mktoc.php 23 May 2004 08:58:01 -0000 1.9
+++ mktoc.php 24 May 2004 16:02:09 -0000
@@ -23,6 +23,24 @@
// $Id: mktoc.php,v 1.9 2004/05/23 08:58:01 wez Exp $
set_magic_quotes_runtime(0);
+
+$TOC = $argv[1];
+$BUILD_TYPE = $argv[2];
+$BUILD_FILE = dirname($argv[0]) . '/mk_' . $BUILD_TYPE . '.php';
+
+if (!strlen($TOC) || !strlen($BUILD_TYPE)) {
+ echo "Usage: mktoc.php tocfile.xml build-type\n";
+ exit(1);
+} elseif (!is_file($TOC)) {
+ echo "Error: $TOC cannot be found or is not a file\n";
+ exit(1);
+} elseif (!is_file($BUILD_FILE)) {
+ echo "Error: $BUILD_TYPE is not a supported build type\n";
+ exit(1);
+}
+
+include $BUILD_FILE;
+
class DocBookTOCParser {
var $cdata = null;
var $id_stack = array();
@@ -45,31 +63,33 @@
}
function start_elem($parser, $name, $attrs) {
- global $idx;
+ global $idx, $banned_ids;
/* if there is an ID attribute, record it */
$docbook_id = sqlite_escape_string($attrs['ID']);
- $title = sqlite_escape_string($attrs['TITLE']);
+ if (!in_array($docbook_id, $banned_ids)) {
+ $title = sqlite_escape_string($attrs['TITLE']);
- $level = sizeof($this->id_stack) - 1;
- if (isset($this->id_stack[$level])) {
- $parent_id = (int) $this->id_stack[$level];
- } else {
- $parent_id = 0;
- }
- $level = sizeof($this->docbook_id_stack) - 1;
- if (isset($this->docbook_id_stack[$level])) {
- $docbook_parent_id =
sqlite_escape_string($this->docbook_id_stack[$level]);
- } else {
- $docbook_parent_id = '';
- }
- $path = sqlite_escape_string(implode(",", $this->docbook_id_stack));
+ $level = sizeof($this->id_stack) - 1;
+ if (isset($this->id_stack[$level])) {
+ $parent_id = (int) $this->id_stack[$level];
+ } else {
+ $parent_id = 0;
+ }
+ $level = sizeof($this->docbook_id_stack) - 1;
+ if (isset($this->docbook_id_stack[$level])) {
+ $docbook_parent_id =
sqlite_escape_string($this->docbook_id_stack[$level]);
+ } else {
+ $docbook_parent_id = '';
+ }
+ $path = sqlite_escape_string(implode(",",
$this->docbook_id_stack));
- array_push($this->id_stack, $this->last_id);
- array_push($this->docbook_id_stack, $docbook_id);
+ array_push($this->id_stack, $this->last_id);
+ array_push($this->docbook_id_stack, $docbook_id);
- echo "INSERT INTO toc VALUES ({$this->last_id}, {$level},
{$parent_id}, '" . strtolower($docbook_id) . "', '{$docbook_parent_id}', '{$path}',
'{$title}', '{$title}');\n";
- $this->last_id++;
+ echo "INSERT INTO toc VALUES ({$this->last_id}, {$level},
{$parent_id}, '" . strtolower($docbook_id) . "', '{$docbook_parent_id}', '{$path}',
'{$title}', '{$title}');\n";
+ $this->last_id++;
+ }
}
function end_elem($parser, $name) {
@@ -78,18 +98,6 @@
}
}
-
-$TOC = $argv[1];
-
-if (!strlen($TOC)) {
- echo "Usage: mktoc.php tocfile.xml\n";
- exit(1);
-}
-elseif (!is_file($TOC)) {
- echo "Error: $TOC cannot be found or is not a file\n";
- exit(1);
-}
-
parse_file($TOC);
exit;