cvs: phd(PHD_0_2) / build.php config.php mktoc.php package.xml /formats pdf.php xhtml.php /include PhDHelper.class.php /themes/php phpdotnet.php
phppdf.php
| From: | Hannes Magnusson | Date: | Sat, 23 Aug 2008 13:51:14 +0000 |
| Subject: | cvs: phd(PHD_0_2) / build.php config.php mktoc.php package.xml /formats pdf.php xhtml.php /include PhDHelper.class.php /themes/php phpdotnet.php phppdf.php |
||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-2079@lists.php.net to get a copy of this message | ||
bjori Sat Aug 23 13:51:14 2008 UTC
Modified files: (Branch: PHD_0_2)
/phd build.php config.php mktoc.php package.xml
/phd/formats pdf.php xhtml.php
/phd/include PhDHelper.class.php
/phd/themes/php phpdotnet.php phppdf.php
Log:
- Added support for phpdoc:classref
- Added support for phpdoc:varentry
- Renamed phpdoc:exception to phpdoc:exceptionref
http://cvs.php.net/viewvc.cgi/phd/build.php?r1=1.54.2.2&r2=1.54.2.3&diff_format=u Index: phd/build.php diff -u phd/build.php:1.54.2.2 phd/build.php:1.54.2.3 --- phd/build.php:1.54.2.2 Fri Aug 1 11:17:06 2008 +++ phd/build.php Sat Aug 23 13:51:11 2008 @@ -1,6 +1,6 @@ #!@php_bin@ <?php -/* $Id: build.php,v 1.54.2.2 2008/08/01 11:17:06 loudi Exp $ */ +/* $Id: build.php,v 1.54.2.3 2008/08/23 13:51:11 bjori Exp $ */ /* {{{ Find the $ROOT directory of PhD @php_dir@ will be replaced by the pear package manager @@ -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 <refname> => 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 http://cvs.php.net/viewvc.cgi/phd/config.php?r1=1.45.2.10&r2=1.45.2.11&diff_format=u Index: phd/config.php diff -u phd/config.php:1.45.2.10 phd/config.php:1.45.2.11 --- phd/config.php:1.45.2.10 Wed Aug 6 20:30:50 2008 +++ phd/config.php Sat Aug 23 13:51:11 2008 @@ -1,5 +1,5 @@ <?php -/* $Id: config.php,v 1.45.2.10 2008/08/06 20:30:50 bjori Exp $ */ +/* $Id: config.php,v 1.45.2.11 2008/08/23 13:51:11 bjori Exp $ */ /* {{{ PhD error & message handler */ @@ -152,7 +152,9 @@ ), 'chunk_extra' => array( "legalnotice" => true, - "phpdoc:exception" => true, + "phpdoc:exceptionref" => true, + "phpdoc:classref" => true, + "phpdoc:varentry" => true, ), 'index' => true, 'xml_root' => '.', http://cvs.php.net/viewvc.cgi/phd/mktoc.php?r1=1.10&r2=1.10.2.1&diff_format=u Index: phd/mktoc.php diff -u phd/mktoc.php:1.10 phd/mktoc.php:1.10.2.1 --- phd/mktoc.php:1.10 Sat May 24 14:49:14 2008 +++ phd/mktoc.php Sat Aug 23 13:51:11 2008 @@ -1,7 +1,7 @@ <?php -/* $Id: mktoc.php,v 1.10 2008/05/24 14:49:14 gwynne Exp $ */ +/* $Id: mktoc.php,v 1.10.2.1 2008/08/23 13:51:11 bjori Exp $ */ $r = new PhDReader($OPTIONS); -$REFS = $FILENAMES = array(); +$VARS = $CLASSES = $REFS = $FILENAMES = array(); $CURRENT_FILENAME = $LAST_CHUNK = ""; #FIXME: This is a workaround for the <legalnotice> 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") { http://cvs.php.net/viewvc.cgi/phd/package.xml?r1=1.74.2.13&r2=1.74.2.14&diff_format=u Index: phd/package.xml diff -u phd/package.xml:1.74.2.13 phd/package.xml:1.74.2.14 --- phd/package.xml:1.74.2.13 Fri Aug 1 11:17:06 2008 +++ phd/package.xml Sat Aug 23 13:51:11 2008 @@ -47,6 +47,9 @@ <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD Style</license> <notes> - Added PDF output format. (Rudy) + - Added support for phpdoc:classref. (Hannes) + - Added support for phpdoc:varentry. (Hannes) + - Renamed phpdoc:exception 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) http://cvs.php.net/viewvc.cgi/phd/formats/pdf.php?r1=1.7.4.2&r2=1.7.4.3&diff_format=u Index: phd/formats/pdf.php diff -u phd/formats/pdf.php:1.7.4.2 phd/formats/pdf.php:1.7.4.3 --- phd/formats/pdf.php:1.7.4.2 Fri Aug 1 11:17:06 2008 +++ phd/formats/pdf.php Sat Aug 23 13:51:11 2008 @@ -153,6 +153,8 @@ 'type' => 'format_suppressed_tags', 'userinput' => 'format_bold', 'variablelist' => 'format_suppressed_tags', + /* hack for phpdoc:varentry */ + 'phpdoc:varentry' => 'format_suppressed_tags', 'varlistentry' => 'format_newline', 'varname' => 'format_italic', 'warning' => 'format_admonition', @@ -2006,4 +2008,4 @@ } } -?> \ No newline at end of file +?> http://cvs.php.net/viewvc.cgi/phd/formats/xhtml.php?r1=1.67.2.1&r2=1.67.2.2&diff_format=u Index: phd/formats/xhtml.php diff -u phd/formats/xhtml.php:1.67.2.1 phd/formats/xhtml.php:1.67.2.2 --- phd/formats/xhtml.php:1.67.2.1 Thu Jul 24 10:21:06 2008 +++ phd/formats/xhtml.php Sat Aug 23 13:51:13 2008 @@ -1,5 +1,5 @@ <?php -/* $Id: xhtml.php,v 1.67.2.1 2008/07/24 10:21:06 loudi Exp $ */ +/* $Id: xhtml.php,v 1.67.2.2 2008/08/23 13:51:13 bjori Exp $ */ class XHTMLPhDFormat extends PhDFormat { protected $elementmap = array( /* {{{ */ @@ -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. "</div>"; } + 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"]) { http://cvs.php.net/viewvc.cgi/phd/include/PhDHelper.class.php?r1=1.9&r2=1.9.2.1&diff_format=u Index: phd/include/PhDHelper.class.php diff -u phd/include/PhDHelper.class.php:1.9 phd/include/PhDHelper.class.php:1.9.2.1 --- phd/include/PhDHelper.class.php:1.9 Sun Jan 27 14:32:33 2008 +++ phd/include/PhDHelper.class.php Sat Aug 23 13:51:14 2008 @@ -1,9 +1,11 @@ <?php -/* $Id: PhDHelper.class.php,v 1.9 2008/01/27 14:32:33 bjori Exp $ */ +/* $Id: PhDHelper.class.php,v 1.9.2.1 2008/08/23 13:51:14 bjori Exp $ */ 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; } http://cvs.php.net/viewvc.cgi/phd/themes/php/phpdotnet.php?r1=1.53.2.2&r2=1.53.2.3&diff_format=u Index: phd/themes/php/phpdotnet.php diff -u phd/themes/php/phpdotnet.php:1.53.2.2 phd/themes/php/phpdotnet.php:1.53.2.3 --- phd/themes/php/phpdotnet.php:1.53.2.2 Sun Aug 17 16:18:45 2008 +++ phd/themes/php/phpdotnet.php Sat Aug 23 13:51:14 2008 @@ -1,10 +1,11 @@ <?php -/* $Id: phpdotnet.php,v 1.53.2.2 2008/08/17 16:18:45 bjori Exp $ */ +/* $Id: phpdotnet.php,v 1.53.2.3 2008/08/23 13:51:14 bjori Exp $ */ abstract class phpdotnet extends PhDTheme { 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,23 @@ } 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) { + $var = $value; + if (($pos = strpos($value, "[")) !== false) { + $var = substr($value, 0, $pos); + } + if (($filename = $this->getVarnameLink($var)) !== null && !in_array($var, $this->cchunk["refname"])) { + if ($this->chunked) { + return '<var class="varname"><a href="'.$filename. '.' .$this->ext. '" class="classname">' .$value. '</a></var>'; + } + return '<var><a href="#'.$filename. '" class="classname">'.$value.'</a></var>'; + } + return '<var class="varname">' .$value. '</varname>'; + + } public function format_container_chunk($open, $name, $attrs, $props) { $this->CURRENT_ID = $id = $attrs[PhDReader::XMLNS_XML]["id"]; if ($open) { @@ -410,6 +440,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 +522,20 @@ } return '<b>' .$display_value.($tag == "function" ? "()" : ""). '</b>'; } + + 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 '<a href="'.$filename. '.' .$this->ext. '" class="classname">' .$value. '</a>'; + } + return '<a href="#'.$filename. '" class="classname">'.$value.'</a>'; + } + return '<b class="classname">' .$value. '</b>'; + } + 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; http://cvs.php.net/viewvc.cgi/phd/themes/php/phppdf.php?r1=1.7.4.2&r2=1.7.4.3&diff_format=u Index: phd/themes/php/phppdf.php diff -u phd/themes/php/phppdf.php:1.7.4.2 phd/themes/php/phppdf.php:1.7.4.3 --- phd/themes/php/phppdf.php:1.7.4.2 Fri Aug 1 11:17:06 2008 +++ phd/themes/php/phppdf.php Sat Aug 23 13:51:14 2008 @@ -1,4 +1,5 @@ <?php +/* $Id: phppdf.php,v 1.7.4.3 2008/08/23 13:51:14 bjori Exp $ */ class phppdf extends PhDTheme { @@ -31,10 +32,12 @@ ), 'legalnotice' => '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', + 'phpdoc:varentry' => 'format_tocnode_newpage', 'sect1' => 'format_tocnode', 'sect2' => 'format_tocnode', 'sect3' => 'format_tocnode', @@ -68,6 +71,12 @@ 'classsynopsis' => false, ), ), + 'titleabbrev' => array( + /* DEFAULT */ 'format_suppressed_tags', + 'phpdoc:classref' => 'format_grep_classname_text', + 'phpdoc:exceptionref' => 'format_grep_classname_text', + ), + ); @@ -82,6 +91,7 @@ protected $cchunk = array(); /* Default Chunk settings */ protected $dchunk = array( + "phpdoc:classref" => null, "bookname" => null, "setname" => null, "toc-root" => null, @@ -180,6 +190,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 +286,9 @@ } return false; } + + public function format_suppressed_tags($open, $name) { + /* Ignore it */ + return ""; + } }
http://cvs.php.net/viewvc.cgi/phd/build.php?r1=1.54.2.2&r2=1.54.2.3&diff_format=u Index: phd/build.php diff -u phd/build.php:1.54.2.2 phd/build.php:1.54.2.3 --- phd/build.php:1.54.2.2 Fri Aug 1 11:17:06 2008 +++ phd/build.php Sat Aug 23 13:51:11 2008 @@ -1,6 +1,6 @@ #!@php_bin@ <?php -/* $Id: build.php,v 1.54.2.2 2008/08/01 11:17:06 loudi Exp $ */ +/* $Id: build.php,v 1.54.2.3 2008/08/23 13:51:11 bjori Exp $ */ /* {{{ Find the $ROOT directory of PhD @php_dir@ will be replaced by the pear package manager @@ -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 <refname> => 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 http://cvs.php.net/viewvc.cgi/phd/config.php?r1=1.45.2.10&r2=1.45.2.11&diff_format=u Index: phd/config.php diff -u phd/config.php:1.45.2.10 phd/config.php:1.45.2.11 --- phd/config.php:1.45.2.10 Wed Aug 6 20:30:50 2008 +++ phd/config.php Sat Aug 23 13:51:11 2008 @@ -1,5 +1,5 @@ <?php -/* $Id: config.php,v 1.45.2.10 2008/08/06 20:30:50 bjori Exp $ */ +/* $Id: config.php,v 1.45.2.11 2008/08/23 13:51:11 bjori Exp $ */ /* {{{ PhD error & message handler */ @@ -152,7 +152,9 @@ ), 'chunk_extra' => array( "legalnotice" => true, - "phpdoc:exception" => true, + "phpdoc:exceptionref" => true, + "phpdoc:classref" => true, + "phpdoc:varentry" => true, ), 'index' => true, 'xml_root' => '.', http://cvs.php.net/viewvc.cgi/phd/mktoc.php?r1=1.10&r2=1.10.2.1&diff_format=u Index: phd/mktoc.php diff -u phd/mktoc.php:1.10 phd/mktoc.php:1.10.2.1 --- phd/mktoc.php:1.10 Sat May 24 14:49:14 2008 +++ phd/mktoc.php Sat Aug 23 13:51:11 2008 @@ -1,7 +1,7 @@ <?php -/* $Id: mktoc.php,v 1.10 2008/05/24 14:49:14 gwynne Exp $ */ +/* $Id: mktoc.php,v 1.10.2.1 2008/08/23 13:51:11 bjori Exp $ */ $r = new PhDReader($OPTIONS); -$REFS = $FILENAMES = array(); +$VARS = $CLASSES = $REFS = $FILENAMES = array(); $CURRENT_FILENAME = $LAST_CHUNK = ""; #FIXME: This is a workaround for the <legalnotice> 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") { http://cvs.php.net/viewvc.cgi/phd/package.xml?r1=1.74.2.13&r2=1.74.2.14&diff_format=u Index: phd/package.xml diff -u phd/package.xml:1.74.2.13 phd/package.xml:1.74.2.14 --- phd/package.xml:1.74.2.13 Fri Aug 1 11:17:06 2008 +++ phd/package.xml Sat Aug 23 13:51:11 2008 @@ -47,6 +47,9 @@ <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD Style</license> <notes> - Added PDF output format. (Rudy) + - Added support for phpdoc:classref. (Hannes) + - Added support for phpdoc:varentry. (Hannes) + - Renamed phpdoc:exception 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) http://cvs.php.net/viewvc.cgi/phd/formats/pdf.php?r1=1.7.4.2&r2=1.7.4.3&diff_format=u Index: phd/formats/pdf.php diff -u phd/formats/pdf.php:1.7.4.2 phd/formats/pdf.php:1.7.4.3 --- phd/formats/pdf.php:1.7.4.2 Fri Aug 1 11:17:06 2008 +++ phd/formats/pdf.php Sat Aug 23 13:51:11 2008 @@ -153,6 +153,8 @@ 'type' => 'format_suppressed_tags', 'userinput' => 'format_bold', 'variablelist' => 'format_suppressed_tags', + /* hack for phpdoc:varentry */ + 'phpdoc:varentry' => 'format_suppressed_tags', 'varlistentry' => 'format_newline', 'varname' => 'format_italic', 'warning' => 'format_admonition', @@ -2006,4 +2008,4 @@ } } -?> \ No newline at end of file +?> http://cvs.php.net/viewvc.cgi/phd/formats/xhtml.php?r1=1.67.2.1&r2=1.67.2.2&diff_format=u Index: phd/formats/xhtml.php diff -u phd/formats/xhtml.php:1.67.2.1 phd/formats/xhtml.php:1.67.2.2 --- phd/formats/xhtml.php:1.67.2.1 Thu Jul 24 10:21:06 2008 +++ phd/formats/xhtml.php Sat Aug 23 13:51:13 2008 @@ -1,5 +1,5 @@ <?php -/* $Id: xhtml.php,v 1.67.2.1 2008/07/24 10:21:06 loudi Exp $ */ +/* $Id: xhtml.php,v 1.67.2.2 2008/08/23 13:51:13 bjori Exp $ */ class XHTMLPhDFormat extends PhDFormat { protected $elementmap = array( /* {{{ */ @@ -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. "</div>"; } + 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"]) { http://cvs.php.net/viewvc.cgi/phd/include/PhDHelper.class.php?r1=1.9&r2=1.9.2.1&diff_format=u Index: phd/include/PhDHelper.class.php diff -u phd/include/PhDHelper.class.php:1.9 phd/include/PhDHelper.class.php:1.9.2.1 --- phd/include/PhDHelper.class.php:1.9 Sun Jan 27 14:32:33 2008 +++ phd/include/PhDHelper.class.php Sat Aug 23 13:51:14 2008 @@ -1,9 +1,11 @@ <?php -/* $Id: PhDHelper.class.php,v 1.9 2008/01/27 14:32:33 bjori Exp $ */ +/* $Id: PhDHelper.class.php,v 1.9.2.1 2008/08/23 13:51:14 bjori Exp $ */ 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; } http://cvs.php.net/viewvc.cgi/phd/themes/php/phpdotnet.php?r1=1.53.2.2&r2=1.53.2.3&diff_format=u Index: phd/themes/php/phpdotnet.php diff -u phd/themes/php/phpdotnet.php:1.53.2.2 phd/themes/php/phpdotnet.php:1.53.2.3 --- phd/themes/php/phpdotnet.php:1.53.2.2 Sun Aug 17 16:18:45 2008 +++ phd/themes/php/phpdotnet.php Sat Aug 23 13:51:14 2008 @@ -1,10 +1,11 @@ <?php -/* $Id: phpdotnet.php,v 1.53.2.2 2008/08/17 16:18:45 bjori Exp $ */ +/* $Id: phpdotnet.php,v 1.53.2.3 2008/08/23 13:51:14 bjori Exp $ */ abstract class phpdotnet extends PhDTheme { 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,23 @@ } 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) { + $var = $value; + if (($pos = strpos($value, "[")) !== false) { + $var = substr($value, 0, $pos); + } + if (($filename = $this->getVarnameLink($var)) !== null && !in_array($var, $this->cchunk["refname"])) { + if ($this->chunked) { + return '<var class="varname"><a href="'.$filename. '.' .$this->ext. '" class="classname">' .$value. '</a></var>'; + } + return '<var><a href="#'.$filename. '" class="classname">'.$value.'</a></var>'; + } + return '<var class="varname">' .$value. '</varname>'; + + } public function format_container_chunk($open, $name, $attrs, $props) { $this->CURRENT_ID = $id = $attrs[PhDReader::XMLNS_XML]["id"]; if ($open) { @@ -410,6 +440,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 +522,20 @@ } return '<b>' .$display_value.($tag == "function" ? "()" : ""). '</b>'; } + + 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 '<a href="'.$filename. '.' .$this->ext. '" class="classname">' .$value. '</a>'; + } + return '<a href="#'.$filename. '" class="classname">'.$value.'</a>'; + } + return '<b class="classname">' .$value. '</b>'; + } + 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; http://cvs.php.net/viewvc.cgi/phd/themes/php/phppdf.php?r1=1.7.4.2&r2=1.7.4.3&diff_format=u Index: phd/themes/php/phppdf.php diff -u phd/themes/php/phppdf.php:1.7.4.2 phd/themes/php/phppdf.php:1.7.4.3 --- phd/themes/php/phppdf.php:1.7.4.2 Fri Aug 1 11:17:06 2008 +++ phd/themes/php/phppdf.php Sat Aug 23 13:51:14 2008 @@ -1,4 +1,5 @@ <?php +/* $Id: phppdf.php,v 1.7.4.3 2008/08/23 13:51:14 bjori Exp $ */ class phppdf extends PhDTheme { @@ -31,10 +32,12 @@ ), 'legalnotice' => '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', + 'phpdoc:varentry' => 'format_tocnode_newpage', 'sect1' => 'format_tocnode', 'sect2' => 'format_tocnode', 'sect3' => 'format_tocnode', @@ -68,6 +71,12 @@ 'classsynopsis' => false, ), ), + 'titleabbrev' => array( + /* DEFAULT */ 'format_suppressed_tags', + 'phpdoc:classref' => 'format_grep_classname_text', + 'phpdoc:exceptionref' => 'format_grep_classname_text', + ), + ); @@ -82,6 +91,7 @@ protected $cchunk = array(); /* Default Chunk settings */ protected $dchunk = array( + "phpdoc:classref" => null, "bookname" => null, "setname" => null, "toc-root" => null, @@ -180,6 +190,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 +286,9 @@ } return false; } + + public function format_suppressed_tags($open, $name) { + /* Ignore it */ + return ""; + } }