cvs: phd(PHD_0_2) / build.php config.php /formats manpage.php xhtml.php /themes/php chunkedhtml.php phpfunctions.php phpkdevelop.php

From: Date: Thu, 24 Jul 2008 10:21:06 +0000
Subject: cvs: phd(PHD_0_2) / build.php config.php /formats manpage.php xhtml.php /themes/php chunkedhtml.php phpfunctions.php phpkdevelop.php
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-1913@lists.php.net to get a copy of this message
loudi Thu Jul 24 10:21:06 2008 UTC Added files: (Branch: PHD_0_2) /phd/themes/php phpkdevelop.php phpfunctions.php /phd/formats manpage.php Modified files: /phd/themes/php chunkedhtml.php /phd config.php build.php /phd/formats xhtml.php Log: * adds kdevelop table of content output as a xhtml theme (-t phpkdevelop modifier) * adds manpage output as a xhtml format (-f manpage, with its php theme "phpfunctions", -t phpfunctions) * added kdevelop & manpage stuff to build.php & config.php to handle them * fixed a minor chm appearence issue with gnochm tested: kdevelop & manpage outputs now process fine with this branch (phd_0_2)

http://cvs.php.net/viewvc.cgi/phd/themes/php/chunkedhtml.php?r1=1.11&r2=1.11.2.1&diff_format=u Index: phd/themes/php/chunkedhtml.php diff -u phd/themes/php/chunkedhtml.php:1.11 phd/themes/php/chunkedhtml.php:1.11.2.1 --- phd/themes/php/chunkedhtml.php:1.11 Sat May 24 14:49:14 2008 +++ phd/themes/php/chunkedhtml.php Thu Jul 24 10:21:06 2008 @@ -1,5 +1,5 @@ <?php -/* $Id: chunkedhtml.php,v 1.11 2008/05/24 14:49:14 gwynne Exp $ */ +/* $Id: chunkedhtml.php,v 1.11.2.1 2008/07/24 10:21:06 loudi Exp $ */ require_once $ROOT . '/themes/php/phpweb.php'; class chunkedhtml extends phpweb { @@ -33,8 +33,8 @@ $nav = <<< NAV <div style="text-align: center;"> - <div class="prev" style="float: left;"><a href="{$prev[0]}">{$prev[1]}</a></div> - <div class="next" style="float: right;"><a href="{$next[0]}">{$next[1]}</a></div> + <div class="prev" style="text-align: left; float: left;"><a href="{$prev[0]}">{$prev[1]}</a></div> + <div class="next" style="text-align: right; float: right;"><a href="{$next[0]}">{$next[1]}</a></div> <div class="up"><a href="{$up[0]}">{$up[1]}</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div> http://cvs.php.net/viewvc.cgi/phd/config.php?r1=1.45.2.4&r2=1.45.2.5&diff_format=u Index: phd/config.php diff -u phd/config.php:1.45.2.4 phd/config.php:1.45.2.5 --- phd/config.php:1.45.2.4 Wed Jul 23 18:31:49 2008 +++ phd/config.php Thu Jul 24 10:21:06 2008 @@ -1,5 +1,5 @@ <?php -/* $Id: config.php,v 1.45.2.4 2008/07/23 18:31:49 bjori Exp $ */ +/* $Id: config.php,v 1.45.2.5 2008/07/24 10:21:06 loudi Exp $ */ /* {{{ PhD error & message handler */ @@ -127,7 +127,7 @@ /* {{{ Default $OPTIONS */ $OPTIONS = array ( - 'output_format' => array('xhtml'), + 'output_format' => array('xhtml', /* 'manpage' */ ), 'output_theme' => array( 'xhtml' => array( 'php' => array( @@ -135,6 +135,12 @@ 'chunkedhtml', 'bightml', 'chmsource', + /* 'phpkdevelop', */ + ), + ), + 'manpage' => array( + 'php' => array( + /* 'phpfunctions', */ ), ), ), @@ -265,9 +271,20 @@ /* {{{ Build format */ case "f": case "format": - 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); + } } + $OPTIONS["output_format"] = $formats; break; /* }}} */ @@ -297,16 +314,21 @@ case "formats": echo "Supported formats:\n"; echo "\txhtml\n"; + echo "\tmanpage\n"; break; case "t": case "theme": case "themes": echo "Supported themes:\n"; - echo "\tphpweb\n"; - echo "\tchunkedhtml\n"; - echo "\tbightml\n"; - echo "\tchmsource\n"; + echo "\txhtml:\n"; + echo "\t\tphpweb\n"; + echo "\t\tchunkedhtml\n"; + echo "\t\tbightml\n"; + echo "\t\tchmsource\n"; + echo "\t\phpkdevelop\n"; + echo "\tmanpage:\n"; + echo "\t\tphpfunctions\n"; break; default: @@ -316,11 +338,16 @@ case false: echo "Supported formats:\n"; echo "\txhtml\n"; + echo "\tmanpage\n"; echo "Supported themes:\n"; - echo "\tphpweb\n"; - echo "\tchunkedhtml\n"; - echo "\tbightml\n"; - echo "\tchmsource\n"; + echo "\txhtml:\n"; + echo "\t\tphpweb\n"; + echo "\t\tchunkedhtml\n"; + echo "\t\tbightml\n"; + echo "\t\tchmsource\n"; + echo "\t\phpkdevelop\n"; + echo "\tmanpage:\n"; + echo "\t\tphpfunctions\n"; break; } } @@ -376,10 +403,16 @@ case "chunkedhtml": case "bightml": case "chmsource": + case "phpkdevelop": if (!in_array($val, $OPTIONS["output_theme"]["xhtml"]["php"])) { $OPTIONS["output_theme"]["xhtml"]["php"][] = $val; } break; + case "phpfunctions": + if (!in_array($val, $OPTIONS["output_theme"]["manpage"]["php"])) { + $OPTIONS["output_theme"]["manpage"]["php"][] = $val; + } + break; default: trigger_error(sprintf("Unknown theme '%s'", $val), E_USER_ERROR); } http://cvs.php.net/viewvc.cgi/phd/build.php?r1=1.54&r2=1.54.2.1&diff_format=u Index: phd/build.php diff -u phd/build.php:1.54 phd/build.php:1.54.2.1 --- phd/build.php:1.54 Sat May 24 14:49:14 2008 +++ phd/build.php Thu Jul 24 10:21:06 2008 @@ -1,6 +1,6 @@ #!@php_bin@ <?php -/* $Id: build.php,v 1.54 2008/05/24 14:49:14 gwynne Exp $ */ +/* $Id: build.php,v 1.54.2.1 2008/07/24 10:21:06 loudi Exp $ */ /* {{{ Find the $ROOT directory of PhD @php_dir@ will be replaced by the pear package manager @@ -68,8 +68,12 @@ case "xhtml": $classname = "XHTMLPhDFormat"; break; + case "manpage": + $classname = "ManpagePhDFormat"; + break; } + // {{{ Initialize the output format and fetch the methodmaps require $ROOT. "/formats/$output_format.php"; $format = new $classname(array($IDs, $REFS)); http://cvs.php.net/viewvc.cgi/phd/formats/xhtml.php?r1=1.67&r2=1.67.2.1&diff_format=u Index: phd/formats/xhtml.php diff -u phd/formats/xhtml.php:1.67 phd/formats/xhtml.php:1.67.2.1 --- phd/formats/xhtml.php:1.67 Sat May 3 16:09:32 2008 +++ phd/formats/xhtml.php Thu Jul 24 10:21: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.67.2.1 2008/07/24 10:21: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', @@ -119,6 +127,7 @@ /* DEFAULT */ 'li', 'varlistentry' => 'format_varlistentry_listitem', ), + 'link' => 'a', 'literal' => 'format_literal', 'literallayout' => 'pre', 'manvolnum' => 'format_manvolnum', @@ -242,6 +251,7 @@ 'table' => 'format_table_title', 'variablelist' => 'strong', ), + 'titleabbrev' => 'format_suppressed_tags', 'type' => 'span', 'userinput' => 'format_userinput', 'variablelist' => 'format_variablelist', @@ -252,6 +262,7 @@ ), 'void' => 'format_void', 'warning' => 'format_admonition', + 'xref' => 'a', 'year' => 'span', 'quote' => 'format_quote', 'qandaset' => 'div', http://cvs.php.net/viewvc.cgi/phd/themes/php/phpkdevelop.php?view=markup&rev=1.1 Index: phd/themes/php/phpkdevelop.php +++ phd/themes/php/phpkdevelop.php <?php require_once $ROOT . '/themes/php/chunkedhtml.php'; class phpkdevelop extends PhDTheme { const DEFAULT_TITLE = "PHP Manual"; const DEFAULT_HREF = "http://www.php.net/manual/en/"; protected $elementmap = array( 'book' => 'format_tocsect1', 'bibliography' => array( /* DEFAULT */ false, 'book' => 'format_tocsect2', ), 'article' => array( /* DEFAULT */ false, 'book' => 'format_tocsect2', ), 'appendix' => array( /* DEFAULT */ false, 'book' => 'format_tocsect2', ), 'colophon' => array( /* DEFAULT */ false, 'book' => 'format_tocsect2', ), 'chapter' => array( /* DEFAULT */ false, 'book' => 'format_tocsect2', ), 'glossary' => array( /* DEFAULT */ false, 'book' => 'format_tocsect2', ), 'index' => array( /* DEFAULT */ false, 'book' => 'format_tocsect2', ), 'part' => array( /* DEFAULT */ false, 'book' => 'format_tocsect2', ), 'preface' => array( /* DEFAULT */ false, 'book' => 'format_tocsect2', ), 'reference' => array( /* DEFAULT */ false, 'book' => 'format_tocsect2', ), 'refentry' => 'format_refentry', 'refname' => 'format_suppressed_tags', 'refpurpose' => 'format_suppressed_tags', 'refsection' => 'format_suppressed_tags', ); protected $textmap = array( 'refname' => 'format_refname_text', ); // Kdevelop TOC file protected $tocStream; // TOC Output directory protected $tocDir; protected $ext; protected $currentEntryName; protected $index = array(); // CHM Table of contents protected $currentTocDepth = 0; protected $lastContent = null; protected $toc; // CHM Index Map protected $hhkStream; public function __construct(array $IDs, $filename, $ext = "php") { parent::__construct($IDs, $ext); $this->tocDir = PhDConfig::output_dir(); $this->ext = $ext; $this->tocStream = fopen($this->tocDir . "php.toc", "w"); self::headerToc(); } public function __destruct() { self::footerToc(); fclose($this->tocStream); } public function format_suppressed_tags($open, $name, $attrs) { return ""; } protected function headerToc() { fwrite($this->tocStream, "<!DOCTYPE kdeveloptoc>\n<kdeveloptoc>\n<title>" . self::DEFAULT_TITLE . "</title>\n" . "<base href=\"" . self::DEFAULT_HREF . "\"/>\n"); } protected function footerToc() { fwrite($this->tocStream, "<index>\n"); foreach ($this->index as $name => $url) fwrite($this->tocStream, "<entry name=\"{$name}\" url=\"{$url}\"/>\n"); fwrite($this->tocStream, "</index>\n</kdeveloptoc>\n"); } public function appendData($data, $isChunk) { } public function format_tocsect1($open, $name, $attrs) { if (!isset($attrs[PhDReader::XMLNS_XML]["id"])) return ""; $id = $attrs[PhDReader::XMLNS_XML]["id"]; $hasChild = (count(PhDHelper::getChildren($id)) > 0); if ($open) { $name = htmlspecialchars(PhDHelper::getDescription($id), ENT_QUOTES, 'UTF-8'); $url = (PhDHelper::getFilename($id) ? PhDHelper::getFilename($id) : $id) . "." . $this->ext; fwrite($this->tocStream, "<tocsect1 name=\"{$name}\" url=\"{$url}\"" . ($hasChild ? "" : "/") . ">\n"); } else { if ($hasChild) fwrite($this->tocStream, "</tocsect1>\n"); } return ""; } public function format_tocsect2($open, $name, $attrs) { if (!isset($attrs[PhDReader::XMLNS_XML]["id"])) return ""; $id = $attrs[PhDReader::XMLNS_XML]["id"]; $hasChild = (count(PhDHelper::getChildren($id)) > 0); if ($open) { $name = htmlspecialchars(PhDHelper::getDescription($id), ENT_QUOTES, 'UTF-8'); $url = (PhDHelper::getFilename($id) ? PhDHelper::getFilename($id) : $id) . "." . $this->ext; fwrite($this->tocStream, " <tocsect2 name=\"{$name}\" url=\"{$url}\"/>\n"); } return ""; } public function format_refentry($open, $name, $attrs) { if (!isset($attrs[PhDReader::XMLNS_XML]["id"])) return ""; $id = $attrs[PhDReader::XMLNS_XML]["id"]; if ($open) { $this->currentEntryName = null; } if (!$open && $this->currentEntryName) { $url = (PhDHelper::getFilename($id) ? PhDHelper::getFilename($id) : $id) . "." . $this->ext; $this->index[$this->currentEntryName] = $url; } return ""; } public function format_refname_text($value, $tag) { $this->currentEntryName = $value; return ""; } } 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 ""; } } 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); } }
« previous php.doc.cvs (#1913) next »