cvs: phd / build.php config.php package.xml /formats manpage.php xhtml.php /include PhDBuildOptions.class.php /themes/php phpfunctions.php

From: Date: Wed, 09 Jul 2008 22:57:06 +0000
Subject: cvs: phd / build.php config.php package.xml /formats manpage.php xhtml.php /include PhDBuildOptions.class.php /themes/php phpfunctions.php
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-1855@lists.php.net to get a copy of this message
loudi Wed Jul 9 22:57:06 2008 UTC Added files: /phd/formats manpage.php /phd/themes/php phpfunctions.php Modified files: /phd build.php config.php package.xml /phd/formats xhtml.php /phd/include PhDBuildOptions.class.php Log: * adds manpage output & its associate theme (which renders RefEntries functions as man pages) * adds commandline modifiers actions for manpage format (-f manpage), pear themes (-t pearchunkedhtml, -t pearchm, -t pearbightml, -t pearweb, -t pearchm or -t pear to render all of them), php new themes (-t phpfunctions for manpage, -t chmsource for xhtml chm) * phd now outputs xhtml, chm & manpage (with php themes) by default * updates package.xml

http://cvs.php.net/viewvc.cgi/phd/build.php?r1=1.57&r2=1.58&diff_format=u Index: phd/build.php diff -u phd/build.php:1.57 phd/build.php:1.58 --- phd/build.php:1.57 Tue Jun 24 14:54:06 2008 +++ phd/build.php Wed Jul 9 22:57:06 2008 @@ -1,6 +1,6 @@ #!@php_bin@ <?php -/* $Id: build.php,v 1.57 2008/06/24 14:54:06 loudi Exp $ */ +/* $Id: build.php,v 1.58 2008/07/09 22:57:06 loudi Exp $ */ /* {{{ Find the $ROOT directory of PhD @php_dir@ will be replaced by the pear package manager @@ -104,6 +104,9 @@ case "xhtml": $classname = "XHTMLPhDFormat"; break; + case "manpage": + $classname = "ManpagePhDFormat"; + break; } // {{{ Initialize the output format and fetch the methodmaps http://cvs.php.net/viewvc.cgi/phd/config.php?r1=1.49&r2=1.50&diff_format=u Index: phd/config.php diff -u phd/config.php:1.49 phd/config.php:1.50 --- phd/config.php:1.49 Thu May 29 14:34:17 2008 +++ phd/config.php Wed Jul 9 22:57:06 2008 @@ -1,5 +1,5 @@ <?php -/* $Id: config.php,v 1.49 2008/05/29 14:34:17 loudi Exp $ */ +/* $Id: config.php,v 1.50 2008/07/09 22:57:06 loudi Exp $ */ require $ROOT . "/include/PhDErrors.php"; @@ -9,7 +9,8 @@ { private static $optionArray = array( 'output_format' => array( - 'xhtml' + 'xhtml', + 'manpage', ), 'output_theme' => array( 'xhtml' => array( @@ -20,6 +21,11 @@ 'chmsource', ), ), + 'manpage' => array( + 'php' => array( + 'phpfunctions', + ), + ), ), 'chunk_extra' => array( "legalnotice" => true, http://cvs.php.net/viewvc.cgi/phd/package.xml?r1=1.79&r2=1.80&diff_format=u Index: phd/package.xml diff -u phd/package.xml:1.79 phd/package.xml:1.80 --- phd/package.xml:1.79 Sat Jul 5 19:53:36 2008 +++ phd/package.xml Wed Jul 9 22:57:06 2008 @@ -49,6 +49,7 @@ <contents> <dir baseinstalldir="phd" name="/"> <file baseinstalldir="phd" name="formats/xhtml.php" role="php"/> + <file baseinstalldir="phd" name="formats/manpage.php" role="php"/> <file baseinstalldir="phd" name="include/PhDBuildOptions.class.php" role="php"/> <file baseinstalldir="phd" name="include/PhDErrors.php" role="php"/> <file baseinstalldir="phd" name="include/PhDFormat.class.php" role="php"/> @@ -74,6 +75,7 @@ <file baseinstalldir="phd" name="themes/php/chunkedhtml.php" role="php"/> <file baseinstalldir="phd" name="themes/php/phpdotnet.php" role="php"/> <file baseinstalldir="phd" name="themes/php/phpweb.php" role="php"/> + <file baseinstalldir="phd" name="themes/php/phpfunctions.php" role="php"/> <file baseinstalldir="phd" name="themes/pear/pearbightml.php" role="php"/> <file baseinstalldir="phd" name="themes/pear/pearchm.php" role="php"/> <file baseinstalldir="phd" name="themes/pear/pearchunkedhtml.php" role="php"/> http://cvs.php.net/viewvc.cgi/phd/formats/xhtml.php?r1=1.67&r2=1.68&diff_format=u Index: phd/formats/xhtml.php diff -u phd/formats/xhtml.php:1.67 phd/formats/xhtml.php:1.68 --- phd/formats/xhtml.php:1.67 Sat May 3 16:09:32 2008 +++ phd/formats/xhtml.php Wed Jul 9 22:57:06 2008 @@ -1,5 +1,5 @@ <?php -/* $Id: xhtml.php,v 1.67 2008/05/03 16:09:32 bjori Exp $ */ +/* $Id: xhtml.php,v 1.68 2008/07/09 22:57:06 loudi Exp $ */ class XHTMLPhDFormat extends PhDFormat { protected $elementmap = array( /* {{{ */ @@ -25,13 +25,21 @@ ), 'book' => 'format_container_chunk', 'chapter' => 'format_container_chunk', + 'citetitle' => 'i', 'co' => 'format_co', 'colophon' => 'format_chunk', 'copyright' => 'format_copyright', + 'date' => 'p', 'editor' => 'format_editor', + 'email' => 'format_suppressed_tags', 'firstname' => 'format_name', 'footnote' => 'format_footnote', 'footnoteref' => 'format_footnoteref', + 'funcdef' => 'format_suppressed_tags', + 'funcsynopsis' => 'div', + 'funcsynopsisinfo' => 'pre', + 'function' => 'span', + 'funcprototype' => 'code', 'surname' => 'format_name', 'othername' => 'format_name', 'optional' => 'span', @@ -45,6 +53,7 @@ 'calloutlist' => 'format_calloutlist', 'callout' => 'format_callout', 'caution' => 'format_admonition', + 'citation' => 'format_citation', 'citerefentry' => 'span', 'classname' => array( /* DEFAULT */ 'span', @@ -94,10 +103,14 @@ ), 'figure' => 'div', 'filename' => 'var', + 'glossentry' => 'li', + 'glossdef' => 'p', + 'glosslist' => 'ul', 'glossterm' => 'span', 'holder' => 'span', 'imageobject' => 'div', 'imagedata' => 'format_imagedata', + 'important' => 'format_admonition', 'index' => array( /* DEFAULT */ 'div', 'article' => 'format_chunk', @@ -119,6 +132,7 @@ /* DEFAULT */ 'li', 'varlistentry' => 'format_varlistentry_listitem', ), + 'link' => 'a', 'literal' => 'format_literal', 'literallayout' => 'pre', 'manvolnum' => 'format_manvolnum', @@ -149,6 +163,7 @@ 'footnote' => 'format_footnote_para', 'refsect1' => 'format_refsect1_para', ), + 'paramdef' => 'format_suppressed_tags', 'parameter' => array( /* DEFAULT */ 'format_parameter', 'methodparam' => 'format_methodparam_parameter', @@ -156,11 +171,14 @@ 'part' => 'format_container_chunk', 'partintro' => 'div', 'personname' => 'format_personname', + 'personblurb' => 'div', + 'phrase' => 'span', 'preface' => 'format_chunk', 'primaryie' => 'format_suppressed_tags', 'procedure' => 'format_procedure', 'productname' => 'span', 'programlisting' => 'format_programlisting', + 'prompt' => 'span', 'propname' => 'span', 'property' => array( /* DEFAULT */ 'span', @@ -177,6 +195,7 @@ 'refsynopsisdiv' => 'div', 'refname' => 'h1', 'refnamediv' => 'div', + 'releaseinfo' => 'div', 'replaceable' => 'span', 'row' => 'format_row', 'screen' => 'format_screen', @@ -201,6 +220,7 @@ 'entry' => 'span', 'example' => 'format_example_content', ), + 'spanspec' => 'format_suppressed_tags', 'step' => 'format_step', 'superscript' => 'sup', 'subscript' => 'sub', @@ -241,7 +261,8 @@ 'segmentedlist' => 'strong', 'table' => 'format_table_title', 'variablelist' => 'strong', - ), + ), + 'titleabbrev' => 'format_suppressed_tags', 'type' => 'span', 'userinput' => 'format_userinput', 'variablelist' => 'format_variablelist', @@ -252,8 +273,10 @@ ), 'void' => 'format_void', 'warning' => 'format_admonition', + 'xref' => 'a', 'year' => 'span', 'quote' => 'format_quote', + 'qandadiv' => 'div', 'qandaset' => 'div', 'qandaentry' => 'dl', 'question' => 'dt', @@ -264,6 +287,7 @@ 'affiliation' => 'format_suppressed_text', 'contrib' => 'format_suppressed_text', 'shortaffil' => 'format_suppressed_text', + 'titleabbrev' => 'format_suppressed_text', 'programlisting' => 'format_programlisting_text', 'alt' => 'format_alt_text', 'modifier' => array( @@ -305,6 +329,7 @@ ), ), 'literal' => 'format_literal_text', + 'email' => 'format_email_text', ); @@ -1110,6 +1135,17 @@ public function admonition_title($title, $lang) { return '<b class="' .(strtolower($title)). '">' .($this->autogen($title, $lang)). '</b>'; } + + public function format_citation($open, $name, $attrs, $props) { + if ($open) { + return '[<span class="citation">'; + } + return '</span>]'; + } + + public function format_email_text($value) { + return '&lt;<a href="mailto:' . $value . '">' . $value . '</a>&gt;'; + } } /* http://cvs.php.net/viewvc.cgi/phd/include/PhDBuildOptions.class.php?r1=1.3&r2=1.4&diff_format=u Index: phd/include/PhDBuildOptions.class.php diff -u phd/include/PhDBuildOptions.class.php:1.3 phd/include/PhDBuildOptions.class.php:1.4 --- phd/include/PhDBuildOptions.class.php:1.3 Fri May 30 15:37:44 2008 +++ phd/include/PhDBuildOptions.class.php Wed Jul 9 22:57:06 2008 @@ -1,5 +1,5 @@ <?php -/* $Id: PhDBuildOptions.class.php,v 1.3 2008/05/30 15:37:44 rquadling Exp $ */ +/* $Id: PhDBuildOptions.class.php,v 1.4 2008/07/09 22:57:06 loudi Exp $ */ class PhDBuildOptionsParser extends PhDOptionParser { @@ -30,9 +30,20 @@ } public function option_format($k, $v) { - if ($v != "xhtml") { - trigger_error("Only xhtml is supported at this time", E_USER_ERROR); + $formats = array(); + foreach((array)$v as $i => $val) { + switch($val) { + case "xhtml": + case "manpage": + if (!in_array($val, $formats)) { + $formats[] = $val; + } + break; + default: + trigger_error("Only xhtml and manpage are supported at this time", E_USER_ERROR); + } } + PhDConfig::set_output_format($formats); } public function option_t($k, $v) @@ -44,6 +55,7 @@ /* Remove the default themes */ $themes = PhDConfig::output_theme(); $themes['xhtml']['php'] = array(); + $themes['manpage']['php'] = array(); foreach((array)$v as $i => $val) { switch($val) { @@ -55,6 +67,27 @@ $themes["xhtml"]["php"][] = $val; } break; + case "phpfunctions": + if (!in_array($val, $themes["manpage"]["php"])) { + $themes["manpage"]["php"][] = $val; + } + break; + case "pear": + $themes["xhtml"]["pear"] = array( + 'pearweb', + 'pearchunkedhtml', + 'pearbightml', + 'pearchm' + ); + break; + case "pearweb": + case "pearchunkedhtml": + case "pearbightml": + case "pearchm": + if (!in_array($val, $themes["xhtml"]["pear"])) { + $themes["xhtml"]["pear"][] = $val; + } + break; default: trigger_error(sprintf("Unknown theme '%s'", $val), E_USER_ERROR); } http://cvs.php.net/viewvc.cgi/phd/formats/manpage.php?view=markup&rev=1.1 Index: phd/formats/manpage.php +++ phd/formats/manpage.php <?php class ManpagePhDFormat extends PhDFormat { protected $elementmap = array( /* {{{ */ 'acronym' => 'format_suppressed_tags', 'abbrev' => 'format_suppressed_tags', 'caution' => 'format_admonition', 'citerefentry' => 'format_suppressed_tags', 'classname' => 'format_suppressed_tags', 'classsynopsis' => '.PP', 'classsynopsisinfo' => 'format_suppressed_tags', 'code' => 'format_suppressed_tags', 'command' => '\\fI', 'constant' => '\\fB', 'constructorsynopsis' => 'format_methodsynopsis', 'destructorsynopsis' => 'format_methodsynopsis', 'emphasis' => '\\fI', 'envar' => 'format_suppressed_tags', 'errortype' => 'format_suppressed_tags', 'example' => 'format_example', 'fieldsynopsis' => 'format_suppressed_tags', 'filename' => '\\fI', 'formalpara' => 'format_indent', /*'funcsynopsis' => '.SH SYNOPSIS', 'funcsynopsisinfo' => '', 'funcprototype' => '',*/ 'funcdef' => '.B', 'function' => array( /* DEFAULT */ 'format_suppressed_tags', 'member' => 'format_suppressed_tags', ), 'glossterm' => 'format_suppressed_tags', 'imagedata' => 'format_suppressed_tags', 'imageobject' => 'format_suppressed_tags', 'informalexample' => '.PP', 'initializer' => array( /* DEFAULT */ false, 'methodparam' => 'format_suppressed_tags', ), 'interfacename' => 'format_suppressed_tags', 'itemizedlist' => 'format_itemizedlist', 'link' => 'format_suppressed_tags', 'listitem' => array( /* DEFAULT */ false, 'varlistentry' => 'format_suppressed_tags', 'itemizedlist' => ".TP 0.2i\n\\(bu", 'orderedlist' => ".TP 0.2i\n\\(bu", ), 'literal' => '\\fI', 'literallayout' => 'format_verbatim', 'manvolnum' => 'format_manvolnum', 'mediaobject' => '\\fB[NOT DISPLAYABLE MEDIA]', 'member' => 'format_member', 'methodname' => '\\fB', 'methodparam' => 'format_methodparam', 'methodsynopsis' => 'format_methodsynopsis', 'modifier' => 'format_suppressed_tags', 'note' => 'format_admonition', 'ooclass' => 'format_suppressed_tags', 'option' => '\\fI', 'orderedlist' => 'format_itemizedlist', 'para' => array( /* DEFAULT */ '.PP', 'listitem' => 'format_suppressed_tags', 'entry' => 'format_suppressed_tags', ), 'paramdef' => 'format_suppressed_tags', 'parameter' => array( /* DEFAULT */ 'format_suppressed_tags', 'methodparam' => 'format_suppressed_tags', 'code' => '\\fI', ), 'productname' => 'format_suppressed_tags', 'programlisting' => 'format_verbatim', 'property' => 'format_suppressed_tags', 'refentry' => 'format_suppressed_tags', 'refentrytitle' => '\\fB', 'refname' => '.SH NAME', 'refnamediv' => 'format_suppressed_tags', 'refpurpose' => 'format_refpurpose', 'refsect1' => 'format_refsect', 'refsection' => 'format_refsect', 'refsynopsisdiv' => 'format_refsynopsisdiv', 'replaceable' => '\\fI', 'screen' => 'format_verbatim', 'seg' => 'format_seg', 'seglistitem' => 'format_seglistitem', 'segmentedlist' => 'format_segmentedlist', 'segtitle' => 'format_suppressed_tags', 'simpara' => array( /* DEFAULT */ '.PP', 'listitem' => '', ), 'simplelist' => 'format_simplelist', 'subscript' => 'format_suppressed_tags', 'synopsis' => 'format_suppressed_tags', 'systemitem' => '\\fB', 'tag' => 'format_suppressed_tags', 'term' => 'format_term', 'title' => array( /* DEFAULT */ '.B', 'segmentedlist' => '.B', 'refsect1' => 'format_refsect_title', 'refsection' => 'format_refsect_title', ), 'tip' => 'format_admonition', 'type' => array( /* DEFAULT */ '\\fR', 'methodparam' => 'format_suppressed_tags' ), 'userinput' => '\\fB', 'variablelist' => 'format_indent', 'varlistentry' => ".TP 0.2i\n\\(bu", 'varname' => 'format_suppressed_tags', 'void' => 'format_void', 'warning' => 'format_admonition', 'xref' => 'format_xref', // GROFF (tbl) ARRAYS 'informaltable' => '.P', 'table' => '.P', 'tgroup' => 'format_tgroup', 'colspec' => 'format_suppressed_tags', 'thead' => 'format_thead', 'tbody' => 'format_suppressed_tags', 'row' => 'format_row', 'entry' => 'format_entry', ); /* }}} */ protected $textmap = array( 'classname' => array( /* DEFAULT */ false, 'ooclass' => 'format_ooclass_name_text', ), 'function' => 'format_function_text', 'initializer' => array( /* DEFAULT */ false, 'methodparam' => 'format_initializer_method_text', ), 'literallayout' => 'format_verbatim_text', 'manvolnum' => 'format_text', 'parameter' => array( /* DEFAULT */ 'format_parameter_text', 'code' => false, //'term' => 'format_parameter_term_text', 'methodparam' => 'format_parameter_method_text', ), 'programlisting' => 'format_verbatim_text', 'refname' => 'format_text', 'refpurpose' => 'format_text', 'screen' => 'format_verbatim_text', 'segtitle' => 'format_segtitle_text', // 'term' => array( // /* DEFAULT */ false, // 'varlistentry' => 'format_term_text', // ), 'title' => array( /* DEFAULT */ false, 'refsect' => 'format_refsect_text', 'refsect1' => 'format_refsect_text', ), 'tag' => 'format_tag_text', 'type' => array( /* DEFAULT */ false, 'methodparam' => 'format_type_method_text', ), 'varname' => 'format_parameter_text', ); /* Current Chunk variables */ protected $cchunk = array(); /* Default Chunk variables */ protected $dchunk = array( "appendlater" => false, "firstitem" => false, "buffer" => array(), "examplenumber" => 0, "methodsynopsis" => array( "params" => array(), "firstsynopsis" => true, ), "open" => false, "ooclass" => null, "role" => null, "segtitle" => array(), "segindex" => 0, ); /* If a chunk is being processed */ protected $chunkOpen = false; public function __construct(array $IDs) { parent::__construct($IDs); } public function __call($func, $args) { if ($args[0] && $this->chunkOpen) { trigger_error("No mapper found for '{$func}'", E_USER_WARNING); } return "\n.B [NOT PROCESSED] $args[1] [/NOT PROCESSED]"; } public function transformFromMap($open, $tag, $name, $attrs, $props) { if ($tag === '') return $tag; $isMacro = (strncmp($tag, ".", 1) == 0); if ($open) { return "\n" . $tag . ($isMacro ? "\n" : ""); } return ($isMacro ? "" : "\\fP"); } public function CDATA($str) { return trim($str); } public function TEXT($str) { $ret = trim(ereg_replace( "[ \n\t]+", ' ', $str)); // No newline if current line begins with ',', ';', ':', '.' if (strncmp($ret, ",", 1) && strncmp($ret, ";", 1) && strncmp($ret, ":", 1) && strncmp($ret, ".", 1)) $ret = "\n" . $ret; return $ret; } public function getChunkInfo() { return $this->cchunk; } public function format_suppressed_tags($open, $name, $attrs) { /* Ignore it */ return ""; } public function format_suppressed_text($value, $tag) { /* Suppress any content */ return ""; } public function format_refsect_text($value, $tag) { if ($this->cchunk["appendlater"] && isset($this->cchunk["buffer"])) array_push($this->cchunk["buffer"], strtoupper('"'.$value.'"')); else return strtoupper('"'.$value.'"'); } public function format_refsect_title($open, $name, $attrs, $props) { if ($open) { if ($this->cchunk["appendlater"] && isset($this->cchunk["buffer"])) array_push($this->cchunk["buffer"], "\n.SH "); else return "\n.SH "; } return ""; } public function format_refpurpose($open, $name, $attrs, $props) { if ($open) { return " \- "; } } public function format_function_text($value, $tag) { return "\n\\fB" . $this->toValidName($value) . "\\fP(3)"; } public function format_parameter_text($value, $tag) { return "\n\\fI$" . $value . "\\fP"; } public function format_parameter_term_text($value, $tag) { return "\n\\fI$" . $value . "\\fP\n\-"; } public function format_term($open, $name, $attrs, $props) { if ($open) return ""; return "\n\-"; } public function format_simplelist($open, $name, $attrs, $props) { if (isset($this->cchunk["role"]) && $this->cchunk["role"] == "seealso") { if ($open) { $this->cchunk["firstitem"] = true; return ""; } return "."; } else { if ($open) { $this->cchunk["firstitem"] = true; return "\n.PP\n.RS\n"; } return "\n.RE\n.PP\n"; } } public function format_member($open, $name, $attrs, $props) { if ($open) { if (isset($this->cchunk["role"]) && $this->cchunk["role"] == "seealso") { if ($this->cchunk["firstitem"]) { $ret = ""; $this->cchunk["firstitem"] = false; } else $ret = ","; return $ret; } if ($this->cchunk["firstitem"]) { $ret = "\n.TP 0.2i\n\\(bu"; $this->cchunk["firstitem"] = false; } else $ret = "\n.TP 0.2i\n\\(bu"; return $ret; } return ""; } public function format_admonition($open, $name, $attrs, $props) { if ($open) { return "\n.PP\n\\fB" . $this->autogen($name, $props["lang"]) . "\\fR\n.RS"; } return "\n.RE\n.PP"; } public function format_example($open, $name, $attrs, $props) { if ($open && isset($this->cchunk["examplenumber"])) { return "\n.PP\n\\fB" . $this->autogen($name, $props["lang"]) . ++$this->cchunk["examplenumber"] . "\\fR\n.RS"; } return "\n.RE"; } public function format_itemizedlist($open, $name, $attrs, $props) { if ($open) { return "\n.PP\n.RS"; } return "\n.RE\n.PP"; } public function format_methodparam($open, $name, $attrs, $props) { if ($open) { $opt = isset($attrs[PhDReader::XMLNS_DOCBOOK]["choice"]) && $attrs[PhDReader::XMLNS_DOCBOOK]["choice"] == "opt"; $this->cchunk["methodsynopsis"]["params"][] = array( "optional" => $opt, "type" => "", "name" => "", "initializer" => ""); } return ""; } public function format_void($open, $name, $attrs, $props) { if ($open) { $this->cchunk["methodsynopsis"]["params"][] = array( "optional" => false, "type" => "void", "name" => "", "initializer" => ""); } return ""; } public function format_type_method_text($value, $tag) { $this->cchunk['methodsynopsis']['params'][count($this->cchunk['methodsynopsis']['params'])-1]['type'] = $value; return ""; } public function format_parameter_method_text($value, $tag) { $this->cchunk['methodsynopsis']['params'][count($this->cchunk['methodsynopsis']['params'])-1]['name'] = $value; return ""; } public function format_initializer_method_text($value, $tag) { $this->cchunk['methodsynopsis']['params'][count($this->cchunk['methodsynopsis']['params'])-1]['initializer'] = $value; return ""; } public function format_refsynopsisdiv($open, $name, $attrs, $props) { if ($open && isset($this->cchunk["methodsynopsis"]["firstsynopsis"]) && $this->cchunk["methodsynopsis"]["firstsynopsis"]) { return "\n.SH SYNOPSIS\n"; } if (!$open && isset($this->cchunk["methodsynopsis"]["firstsynopsis"])) $this->cchunk["methodsynopsis"]["firstsynopsis"] = false; return ""; } public function format_methodsynopsis($open, $name, $attrs, $props) { if ($open && isset($this->cchunk["methodsynopsis"]["firstsynopsis"]) && $this->cchunk["methodsynopsis"]["firstsynopsis"] && $this->cchunk["appendlater"]) { $this->cchunk["appendlater"] = false; return "\n.SH SYNOPSIS\n"; } if ($open) return "\n.br"; $params = array(); // write the formatted synopsis foreach ($this->cchunk['methodsynopsis']['params'] as $parameter) array_push( $params, ($parameter['optional'] ? "[" : "") . $parameter['type'] . ($parameter['name'] ? " \\fI$" . $parameter['name'] . "\\fP" : "") . ($parameter['initializer'] ? " = " . $parameter['initializer'] : "") . ($parameter['optional'] ? "]" : "") ); $ret = "\n(" . join($params, ", ") . ")"; $this->cchunk['methodsynopsis']['params'] = array(); // finally write what is in the buffer if (isset($this->cchunk["buffer"])) { $ret .= implode("", $this->cchunk["buffer"]); $this->cchunk["buffer"] = array(); } if (isset($this->cchunk["methodsynopsis"]["firstsynopsis"])) $this->cchunk["methodsynopsis"]["firstsynopsis"] = false; return $ret; } public function newChunk() { $this->cchunk = $this->dchunk; $this->chunkOpen = true; } public function closeChunk() { $this->chunkOpen = false; } public function format_xref($open, $name, $attrs, $props) { if ($props['empty']) return "\n\"" . PhDHelper::getDescription($attrs[PhDReader::XMLNS_DOCBOOK]["linkend"]) . "\""; return ""; } public function format_verbatim($open, $name, $attrs, $props) { if ($open) { return "\n.PP\n.nf"; } return "\n.fi"; } public function format_verbatim_text($value, $tag) { return "\n" . trim($value) . "\n"; } public function format_refsect($open, $name, $attrs, $props) { if ($open && isset($attrs[PhDReader::XMLNS_DOCBOOK]["role"])) { $this->cchunk["role"] = $attrs[PhDReader::XMLNS_DOCBOOK]["role"]; if ($this->cchunk["role"] == "description") { $this->cchunk["appendlater"] = true; } } if (!$open) $this->cchunk["role"] = null; return ""; } // Returns the unformatted value without whitespaces (nor new lines) public function format_text($value, $tag) { return trim(ereg_replace("[ \n\t]+", ' ', $value)); } public function format_tgroup($open, $name, $attrs, $props) { if ($open) { $nbCols = $attrs[PhDReader::XMLNS_DOCBOOK]["cols"]; $ret = "\n.TS\nbox, tab (|);\n"; for ($i = 0; $i < $nbCols; $i++) $ret .= "c | "; $ret .= "."; return $ret; } return "\n.TE\n.PP"; } public function format_thead($open, $name, $attrs, $props) { if ($open) { return ""; } return "\n="; } public function format_row($open, $name, $attrs, $props) { if ($open) { $this->cchunk["firstitem"] = true; return "\n"; } return ""; } public function format_entry($open, $name, $attrs, $props) { if ($open) { if ($this->cchunk["firstitem"]) { $this->cchunk["firstitem"] = false; return "T{\n"; } return "|T{\n"; } return "\nT}"; } public function format_segmentedlist($open, $name, $attrs, $props) { if ($open) { return "\n.P"; } $this->cchunk["segtitle"] = array(); return "\n"; } public function format_seglistitem($open, $name, $attrs, $props) { if ($open && isset($this->cchunk["segindex"])) $this->cchunk["segindex"] = 0; return ""; } public function format_seg($open, $name, $attrs, $props) { if (! (isset($this->cchunk["segtitle"]) && isset($this->cchunk["segtitle"][$this->cchunk["segindex"]])) ) return ""; if ($open) { return "\n.br\n\\fB" . $this->cchunk["segtitle"][$this->cchunk["segindex"]] . ":\\fR"; } $this->cchunk["segindex"]++; return ""; } public function format_segtitle_text($value, $tag) { if (isset($this->cchunk["segtitle"])) $this->cchunk["segtitle"][] = $value; return ""; } public function format_manvolnum($open, $name, $attrs, $props) { if ($open) { return "("; } return ")"; } public function format_ooclass_name_text($value, $tag) { return "\n.br\n\\fI" . $value . "\\fP"; } public function format_indent($open, $name, $attrs, $props) { if ($open) { return "\n.PP\n.RS"; } return "\n.RE\n.PP"; } public function format_tag_text($value, $tag) { return "\n<" . $value . ">"; } // Convert the function name to a Unix valid filename public function toValidName($functionName) { return str_replace(array("::", "->"), array(".", "."), $functionName); } } http://cvs.php.net/viewvc.cgi/phd/themes/php/phpfunctions.php?view=markup&rev=1.1 Index: phd/themes/php/phpfunctions.php +++ phd/themes/php/phpfunctions.php <?php class phpfunctions extends PhDTheme { const OPEN_CHUNK = 0x01; const CLOSE_CHUNK = 0x02; const OPENED_CHUNK = 0x03; protected $elementmap = array( 'set' => 'format_set', 'refentry' => 'format_refentry', 'refname' => 'format_refname', ); protected $textmap = array( 'pubdate' => 'format_pubdate', 'refname' => 'format_refname_text', 'title' => array( /* DEFAULT */ false, 'set' => array( /* DEFAULT */ 'format_bookname', 'set' => false, ), ), ); public $role = false; protected $chunked = true; protected $CURRENT_ID = ""; /* Current Chunk settings */ protected $cchunk = array(); /* Default Chunk settings */ protected $dchunk = array( "funcname" => array(), "firstrefname" => true, ); protected $isChunk = false; /* Common properties for all functions pages */ protected $bookName = ""; protected $date = ""; protected $outputdir = ""; protected $isFunctionRefSet = false; public function __construct(array $IDs, array $filenames, $format = "man", $chunked = true) { parent::__construct($IDs); $this->format = $format; $this->outputdir = PhDConfig::output_dir() . $this->format . DIRECTORY_SEPARATOR; if(!file_exists($this->outputdir) || is_file($this->outputdir)) mkdir($this->outputdir) or die("Can't create the cache directory"); } public function header($index) { return ".TH " . strtoupper($this->cchunk["funcname"][$index]) . " 3 \"" . $this->date . "\" \"PHP Documentation Group\" \"" . $this->bookName . "\""; } public function writeChunk($stream) { if (!isset($this->cchunk["funcname"][0])) return; $index = 0; rewind($stream); $filename = $this->cchunk["funcname"][$index] . '.3'; file_put_contents($this->outputdir . $filename, $this->header($index)); file_put_contents($this->outputdir . $filename, $stream, FILE_APPEND); v("Wrote %s", $this->outputdir . $filename, VERBOSE_CHUNK_WRITING); while(isset($this->cchunk["funcname"][++$index])) { $filename = $this->cchunk["funcname"][$index] . '.3'; rewind($stream); // Replace the default function name by the alternative one $content = preg_replace('/'.$this->cchunk["funcname"][0].'/', $this->cchunk["funcname"][$index], stream_get_contents($stream), 1); file_put_contents($this->outputdir . $filename, $this->header($index)); file_put_contents($this->outputdir . $filename, $content, FILE_APPEND); v("Wrote %s", $this->outputdir . $filename, VERBOSE_CHUNK_WRITING); } } public function appendData($data, $isChunk) { if (!$this->isFunctionRefSet) return 0; switch($this->isChunk) { case self::CLOSE_CHUNK: $stream = array_pop($this->streams); $retval = (trim($data) === "") ? false : fwrite($stream, $data); $this->writeChunk($stream); fclose($stream); $this->isChunk = null; $this->cchunk = array(); return $retval; break; case self::OPEN_CHUNK: $this->streams[] = fopen("php://temp/maxmemory", "r+"); $this->isChunk = self::OPENED_CHUNK; case self::OPENED_CHUNK: $stream = end($this->streams); // Remove whitespace nodes $retval = ($data != "\n" && trim($data) === "") ? false : fwrite($stream, $data); return $retval; default: return 0; } } public function format_bookname($value, $tag) { $this->bookName = $value; return false; } public function format_pubdate($value, $tag) { $this->date = $value; return false; } public function format_set($open, $name, $attrs, $props) { if (isset($attrs[PhDReader::XMLNS_XML]["id"]) && $attrs[PhDReader::XMLNS_XML]["id"] == "funcref") { $this->isFunctionRefSet = $open; } return false; } public function format_refentry($open, $name, $attrs, $props) { if (!$this->isFunctionRefSet) return false; if ($open) { $this->isChunk = self::OPEN_CHUNK; $this->format->newChunk(); $this->cchunk = $this->dchunk; } else { $this->isChunk = self::CLOSE_CHUNK; $this->format->closeChunk(); } return false; } public function format_refname($open, $name, $attrs, $props) { if ($open) { return (isset($this->cchunk["firstrefname"]) && $this->cchunk["firstrefname"]) ? false : ""; } else { if (isset($this->cchunk["firstrefname"]) && $this->cchunk["firstrefname"]) { $this->cchunk["firstrefname"] = false; return false; } return ""; } } public function format_refname_text($value, $tag) { $this->cchunk["funcname"][] = $this->format->toValidName(trim($value)); if (isset($this->cchunk["firstrefname"]) && $this->cchunk["firstrefname"]) { return false; } return ""; } }
« previous php.doc.cvs (#1855) next »