Index: build.php =================================================================== RCS file: /repository/phd/build.php,v retrieving revision 1.54.2.2 diff -u -r1.54.2.2 build.php --- build.php 1 Aug 2008 11:17:06 -0000 1.54.2.2 +++ build.php 6 Aug 2008 20:56:29 -0000 @@ -28,32 +28,40 @@ /* {{{ Build the .ser file names to allow multiple sources for PHD. */ $OPTIONS['index_location'] = $OPTIONS['xml_root'] . DIRECTORY_SEPARATOR . '.index_' . basename($OPTIONS['xml_file'], '.xml') . '.ser'; $OPTIONS['refnames_location'] = $OPTIONS['xml_root'] . DIRECTORY_SEPARATOR . '.refnames_' . basename($OPTIONS['xml_file'], '.xml') . '.ser'; +$OPTIONS['classes_location'] = $OPTIONS['xml_root'] . DIRECTORY_SEPARATOR . '.classes_' . basename($OPTIONS['xml_file'], '.xml') . '.ser'; +$OPTIONS['vars_location'] = $OPTIONS['xml_root'] . DIRECTORY_SEPARATOR . '.vars_' . basename($OPTIONS['xml_file'], '.xml') . '.ser'; /* }}} */ /* {{{ Index the DocBook file or load from .ser cache files NOTE: There are two cache files (where * is the basename of the XML source file): - index_*.ser (containing the ID infos) - refnames_*.ser (containing => File ID) */ -if (!$OPTIONS["index"] && (file_exists($OPTIONS['index_location']) && file_exists($OPTIONS['refnames_location']))) { +if (!$OPTIONS["index"] && (file_exists($OPTIONS['index_location']) && file_exists($OPTIONS['refnames_location']) && file_exists($OPTIONS['classes_location']) && file_exists($OPTIONS['vars_location']))) { /* FIXME: Load from sqlite db? */ v("Unserializing cached index files...", VERBOSE_INDEXING); $IDs = unserialize(file_get_contents($OPTIONS['index_location'])); $REFS = unserialize(file_get_contents($OPTIONS['refnames_location'])); + $CLASSES = unserialize(file_get_contents($OPTIONS['classes_location'])); + $VARS = unserialize(file_get_contents($OPTIONS['vars_location'])); v("Unserialization done", VERBOSE_INDEXING); } else { v("Indexing...", VERBOSE_INDEXING); - /* This file will "return" an $IDs & $REFS array */ + /* This file will "return" an $IDs, $REFS, $CLASSES, $VARS array */ require $ROOT. "/mktoc.php"; file_put_contents($OPTIONS['index_location'], $ids = serialize($IDs)); file_put_contents($OPTIONS['refnames_location'], $refs = serialize($REFS)); + file_put_contents($OPTIONS['classes_location'], $classes = serialize($CLASSES)); + file_put_contents($OPTIONS['vars_location'], $vars = serialize($VARS)); $IDs2 = unserialize($ids); $REFS2 = unserialize($refs); - if ($IDs !== $IDs2 || $REFS !== $REFS2) { + $CLASSES2 = unserialize($classes); + $VARS2 = unserialize($vars); + if ($IDs !== $IDs2 || $REFS !== $REFS2 || $CLASSES !== $CLASSES2 || $VARS !== $VARS2) { trigger_error("Serialized representation does not match", E_USER_WARNING); } @@ -79,7 +87,7 @@ // {{{ Initialize the output format and fetch the methodmaps require $ROOT. "/formats/$output_format.php"; - $format = new $classname(array($IDs, $REFS)); + $format = new $classname(array($IDs, $REFS, $CLASSES, $VARS)); $formatmap = $format->getElementMap(); $formattextmap = $format->getTextMap(); /* }}} */ @@ -96,7 +104,7 @@ switch($theme) { // FIXME: This is stupid and definetly does not belong in here. case "php": - $themes[$themename] = new $themename(array($IDs, $REFS), + $themes[$themename] = new $themename(array($IDs, $REFS, $CLASSES, $VARS), array( "version" => $OPTIONS["version_info"], "acronym" => $OPTIONS["acronyms_file"], @@ -104,7 +112,7 @@ ); break; default: - $themes[$themename] = new $themename(array($IDs, $REFS)); + $themes[$themename] = new $themename(array($IDs, $REFS, $CLASSES, $VARS)); } // FIXME: this needs to go away when we add support for Index: config.php =================================================================== RCS file: /repository/phd/config.php,v retrieving revision 1.45.2.10 diff -u -r1.45.2.10 config.php --- config.php 6 Aug 2008 20:30:50 -0000 1.45.2.10 +++ config.php 6 Aug 2008 20:56:29 -0000 @@ -1,5 +1,5 @@ array( "legalnotice" => true, - "phpdoc:exception" => true, + "phpdoc:exceptionref" => true, + "phpdoc:classref" => true, + "phpdoc:varentry" => true, ), 'index' => true, 'xml_root' => '.', Index: mktoc.php =================================================================== RCS file: /repository/phd/mktoc.php,v retrieving revision 1.10 diff -u -r1.10 mktoc.php --- mktoc.php 24 May 2008 14:49:14 -0000 1.10 +++ mktoc.php 6 Aug 2008 20:56:29 -0000 @@ -1,7 +1,7 @@ element in the PHP manual @@ -16,16 +16,22 @@ $IDs[$lastid]["sdesc"] = $refname = trim($r->readContent($name)); $ref = strtolower(str_replace(array("_", "::", "->"), array("-", "-", "-"), $refname)); $REFS[$ref] = $lastid; + $VARS[$refname] = $lastid; continue; } elseif($name == "titleabbrev") { - $IDs[$lastid]["sdesc"] = trim($r->readContent($name)); + $IDs[$lastid]["sdesc"] = $class = trim($r->readContent($name)); + $elm = $r->getParentTagName(); + if ($elm == "phpdoc:classref" || $elm == "phpdoc:exceptionref") { + $CLASSES[strtolower($class)] = $lastid; + } continue; } } elseif($name == "refname") { $refname = trim($r->readContent($name)); $ref = strtolower(str_replace(array("_", "::", "->"), array("-", "-", "-"), $refname)); $REFS[$ref] = $lastid; + $VARS[$refname] = $lastid; } if (empty($IDs[$lastid]["ldesc"])) { if ($name == "title" || $name == "refpurpose") { Index: package.xml =================================================================== RCS file: /repository/phd/package.xml,v retrieving revision 1.74.2.13 diff -u -r1.74.2.13 package.xml --- package.xml 1 Aug 2008 11:17:06 -0000 1.74.2.13 +++ package.xml 6 Aug 2008 20:56:29 -0000 @@ -47,6 +47,10 @@ BSD Style - Added PDF output format. (Rudy) + - Added support for phpdoc:classref. (Hannes) + - Added support for phpdoc:varentry. (Hannes) + - Added support for the phpdoc howto. (Hannes) + - Renamed phpdoc:exceptoin to phpdoc:exceptionref. (Hannes) - Fixed bug#45627 (Unix manpages using non-standard folder name). (Rudy) - Fixed bug#45626 (Unix manpages should be gzipped). (Rudy) - Fixed bug#45618 (Bad filenames in man pages). (Rudy) Index: formats/xhtml.php =================================================================== RCS file: /repository/phd/formats/xhtml.php,v retrieving revision 1.67.2.1 diff -u -r1.67.2.1 xhtml.php --- formats/xhtml.php 24 Jul 2008 10:21:06 -0000 1.67.2.1 +++ formats/xhtml.php 6 Aug 2008 20:56:29 -0000 @@ -177,6 +177,8 @@ ), 'proptype' => 'span', 'pubdate' => 'div', /* Docbook-XSL prints "published" */ + /* hack for phpdoc:varentry */ + 'phpdoc:varentry' => 'format_varentry_chunk', 'refentry' => 'format_chunk', 'refentrytitle' => 'span', 'reference' => 'format_container_chunk', @@ -509,6 +511,9 @@ return $str. ""; } + public function format_varentry_chunk($open, $name, $attrs, $props) { + return $this->format_chunk($open, "refentry", $attrs, $props); + } public function format_refsect1_para($open, $name, $attrs, $props) { if ($open) { switch ($props["sibling"]) { Index: include/PhDHelper.class.php =================================================================== RCS file: /repository/phd/include/PhDHelper.class.php,v retrieving revision 1.9 diff -u -r1.9 PhDHelper.class.php --- include/PhDHelper.class.php 27 Jan 2008 14:32:33 -0000 1.9 +++ include/PhDHelper.class.php 6 Aug 2008 20:56:29 -0000 @@ -4,6 +4,8 @@ class PhDHelper { private $IDs = array(); private $refs = array(); + private $classes = array(); + private $vars = array(); /* abstract */ protected $elementmap = array(); /* abstract */ protected $textmap = array(); private static $autogen = array(); @@ -11,6 +13,8 @@ public function __construct(array $a) { $this->IDs = $a[0]; $this->refs = $a[1]; + $this->classes = $a[2]; + $this->vars = $a[3]; } final public function getFilename($id) { return isset($this->IDs[$id]) ? $this->IDs[$id]["filename"] : false; @@ -29,6 +33,12 @@ public function getRefnameLink($ref) { return isset($this->refs[$ref]) ? $this->refs[$ref] : null; } + public function getClassnameLink($class) { + return isset($this->classes[$class]) ? $this->classes[$class] : null; + } + public function getVarnameLink($var) { + return isset($this->vars[$var]) ? $this->vars[$var] : null; + } final public function getElementMap() { return $this->elementmap; } Index: themes/php/phpdotnet.php =================================================================== RCS file: /repository/phd/themes/php/phpdotnet.php,v retrieving revision 1.53.2.1 diff -u -r1.53.2.1 phpdotnet.php --- themes/php/phpdotnet.php 23 Jul 2008 18:31:49 -0000 1.53.2.1 +++ themes/php/phpdotnet.php 6 Aug 2008 20:56:29 -0000 @@ -5,6 +5,7 @@ protected $elementmap = array( 'acronym' => 'format_suppressed_tags', 'function' => 'format_suppressed_tags', + 'classname' => 'format_suppressed_tags', 'link' => 'format_link', 'refpurpose' => 'format_refpurpose', 'title' => array( @@ -33,7 +34,7 @@ 'methodsynopsis' => false, ), 'varname' => array( - /* DEFAULT */ false, + /* DEFAULT */ 'format_suppressed_tags', 'fieldsynopsis' => 'format_fieldsynopsis_varname', ), 'xref' => 'format_link', @@ -67,8 +68,10 @@ 'part' => 'format_container_chunk', 'preface' => 'format_chunk', 'refentry' => 'format_chunk', + 'phpdoc:varentry' => 'format_varentry_chunk', 'reference' => 'format_container_chunk', - 'phpdoc:exception' => 'format_exception_chunk', + 'phpdoc:exceptionref' => 'format_exception_chunk', + 'phpdoc:classref' => 'format_class_chunk', 'sect1' => 'format_chunk', 'sect2' => 'format_chunk', 'sect3' => 'format_chunk', @@ -85,6 +88,11 @@ protected $textmap = array( 'acronym' => 'format_acronym_text', 'function' => 'format_function_text', + 'classname' => 'format_classname_text', + 'varname' => array( + /* DEFAULT */ 'format_varname_text', + 'fieldsynopsis' => false, + ), 'methodname' => array( /* DEFAULT */ 'format_function_text', 'constructorsynopsis' => array( @@ -112,7 +120,11 @@ ), 'refname' => 'format_refname_text', - 'titleabbrev' => 'format_suppressed_tags', + 'titleabbrev' => array( + /* DEFAULT */ 'format_suppressed_tags', + 'phpdoc:classref' => 'format_grep_classname_text', + 'phpdoc:exceptionref' => 'format_grep_classname_text', + ), ); private $versions = array(); private $acronyms = array(); @@ -125,6 +137,7 @@ protected $cchunk = array(); /* Default Chunk settings */ protected $dchunk = array( + "phpdoc:classref" => null, "fieldsynopsis" => array( "modifier" => "public", ), @@ -363,6 +376,19 @@ } return false; } + public function format_varentry_chunk($open, $name, $attrs, $props) { + return $this->format_chunk($open, "refentry", $attrs, $props); + } + public function format_varname_text($value, $tag) { + if (($filename = $this->getVarnameLink($value)) !== null && !in_array($value, $this->cchunk["refname"])) { + if ($this->chunked) { + return '' .$value. ''; + } + return ''.$value.''; + } + return '' .$value. ''; + + } public function format_container_chunk($open, $name, $attrs, $props) { $this->CURRENT_ID = $id = $attrs[PhDReader::XMLNS_XML]["id"]; if ($open) { @@ -410,6 +436,9 @@ public function format_exception_chunk($open, $name, $attrs, $props) { return $this->format_container_chunk($open, "reference", $attrs, $props); } + public function format_class_chunk($open, $name, $attrs, $props) { + return $this->format_container_chunk($open, "reference", $attrs, $props); + } public function format_container_chunk_title($open, $name, $attrs) { if ($open) { @@ -489,6 +518,20 @@ } return '' .$display_value.($tag == "function" ? "()" : ""). ''; } + + public function format_grep_classname_text($value, $tag) { + $this->cchunk["phpdoc:classref"] = strtolower($value); + } + public function format_classname_text($value, $tag) { + if (($filename = $this->getClassnameLink(strtolower($value))) !== null && $this->cchunk["phpdoc:classref"] !== strtolower($value)) { + if ($this->chunked) { + return '' .$value. ''; + } + return ''.$value.''; + } + return '' .$value. ''; + } + public function format_type_if_object_or_pseudo_text($type, $tagname) { if (in_array(strtolower($type), array("bool", "int", "double", "boolean", "integer", "float", "string", "array", "object", "resource", "null"))) { return false; Index: themes/php/phppdf.php =================================================================== RCS file: /repository/phd/themes/php/phppdf.php,v retrieving revision 1.7.4.2 diff -u -r1.7.4.2 phppdf.php --- themes/php/phppdf.php 1 Aug 2008 11:17:06 -0000 1.7.4.2 +++ themes/php/phppdf.php 6 Aug 2008 20:56:30 -0000 @@ -1,4 +1,5 @@ 'format_tocnode_newpage', 'part' => 'format_tocnode_newpage', - 'phpdoc:exception' => 'format_tocnode_exception', + 'phpdoc:exceptionref' => 'format_tocnode_exception', + 'phpdoc:classref' => 'format_tocnode_class', 'preface' => 'format_tocnode_newpage', 'refentry' => 'format_tocnode_newpage', 'reference' => 'format_tocnode_newpage', @@ -68,6 +70,12 @@ 'classsynopsis' => false, ), ), + 'titleabbrev' => array( + /* DEFAULT */ 'format_suppressed_tags', + 'phpdoc:classref' => 'format_grep_classname_text', + 'phpdoc:exceptionref' => 'format_grep_classname_text', + ), + ); @@ -82,6 +90,7 @@ protected $cchunk = array(); /* Default Chunk settings */ protected $dchunk = array( + "phpdoc:classref" => null, "bookname" => null, "setname" => null, "toc-root" => null, @@ -180,6 +189,14 @@ public function format_tocnode_exception($open, $name, $attrs, $props) { return $this->format_tocnode($open, "reference", $attrs, $props, true); } + + public function format_tocnode_class($open, $name, $attrs, $props) { + return $this->format_tocnode($open, "reference", $attrs, $props, true); + } + + public function format_grep_classname_text($value, $tag) { + $this->cchunk["phpdoc:classref"] = strtolower($value); + } // Convert the book name to a Unix valid filename protected function toValidName($functionName) { @@ -268,4 +285,9 @@ } return false; } + + public function format_suppressed_tags($open, $name) { + /* Ignore it */ + return ""; + } }