cvs: phd(PHD_0_4) / mktoc.php

From: Date: Sun, 19 Oct 2008 14:07:13 +0000
Subject: cvs: phd(PHD_0_4) / mktoc.php
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-2259@lists.php.net to get a copy of this message
bjori Sun Oct 19 14:07:13 2008 UTC Modified files: (Branch: PHD_0_4) /phd mktoc.php Log: MFH: Comments, CS & WS http://cvs.php.net/viewvc.cgi/phd/mktoc.php?r1=1.10.2.1.2.1&r2=1.10.2.1.2.2&diff_format=u Index: phd/mktoc.php diff -u phd/mktoc.php:1.10.2.1.2.1 phd/mktoc.php:1.10.2.1.2.2 --- phd/mktoc.php:1.10.2.1.2.1 Sun Oct 19 14:02:49 2008 +++ phd/mktoc.php Sun Oct 19 14:07:13 2008 @@ -1,5 +1,37 @@ <?php -/* $Id: mktoc.php,v 1.10.2.1.2.1 2008/10/19 14:02:49 bjori Exp $ */ +/** +* Creates the internal table of contents array. +* It is used to look up referenced ids and referenced names. +* +* The TOC is stored in the $ID variable. It is not saved, just generated. +* Generation works by using PhDReader to iterate over each tag, stopping at +* title (or similar) tags and chunk elements. +* Chunk element names are defined in PhDReader::OPEN_CHUNK and +* PhDReader::CLOSE_CHUNK. +* Title tags are title, titleabbrev, refname and refpurpose. +* +* IDs are taken from the xml:id="" attributes of the tags. +* +* It has the following format: +* array( +* '$id' => array( +* 'sdesc' => 'Short description (e.g. title)', +* 'ldesc' => 'Long description (e.g. titleabbrev)', +* 'children' => array('array', 'of', 'children', 'ids'), +* 'parent' => 'parent_id', +* 'filename' => 'filename for chunk' +* ), +* [..more..] +* ) +* +* This script also creates the associative $REFS array, using the normalized +* <refname> value as key and its xml:id as value. This is used in +* PhDHelper::getRefnameLink(), and allows easy refname->link resolution. +* +* @package PhD +* @version CVS: $Id: mktoc.php,v 1.10.2.1.2.2 2008/10/19 14:07:13 bjori Exp $ +*/ + $r = new PhDReader($OPTIONS); $VARS = $CLASSES = $REFS = $FILENAMES = array(); $CURRENT_FILENAME = $LAST_CHUNK = ""; @@ -8,7 +40,7 @@ $PARENTS = array(-1 => "ROOT", 1 => "manual", 2 => "manual"); $lastid = 0; -while($r->read()) { +while ($r->read()) { if (!($id = $r->getID())) { $name = $r->name; if (empty($IDs[$lastid]["sdesc"])) { @@ -19,7 +51,7 @@ $VARS[$refname] = $lastid; continue; } - elseif($name == "titleabbrev") { + else if($name == "titleabbrev") { $IDs[$lastid]["sdesc"] = $class = trim($r->readContent($name)); $elm = $r->getParentTagName(); if ($elm == "phpdoc:classref" || $elm == "phpdoc:exceptionref") { @@ -27,7 +59,7 @@ } continue; } - } elseif($name == "refname") { + } else if ($name == "refname") { $refname = trim($r->readContent($name)); $ref = strtolower(str_replace(array("_", "::", "->"), array("-", "-", "-"), $refname)); $REFS[$ref] = $lastid; @@ -41,7 +73,8 @@ continue; } - switch($r->isChunk) { + + switch ($r->isChunk) { case PhDReader::OPEN_CHUNK: $CURRENT_FILENAME = $FILENAMES[] = $PARENTS[$r->depth] = $id; break; @@ -62,7 +95,12 @@ $IDs[$id] = array( "filename" => $CURRENT_FILENAME, - "parent" => $r->isChunk ? (isset($PARENTS[$r->depth-1]) ? $PARENTS[$r->depth-1] : $PARENTS[$r->depth-2]) : $CURRENT_FILENAME, + "parent" => $r->isChunk + ? (isset($PARENTS[$r->depth-1]) + ? $PARENTS[$r->depth-1] + : $PARENTS[$r->depth-2] + ) + : $CURRENT_FILENAME, "sdesc" => null, "ldesc" => null, "children" => array(), @@ -75,4 +113,3 @@ * vim600: sw=4 ts=4 fdm=syntax syntax=php et * vim<600: sw=4 ts=4 */ -

« previous php.doc.cvs (#2259) next »