svn: /phd/trunk/phpdotnet/phd/Package/ Generic/ChunkedXHTML.php Generic/XHTML.php IDE/Base.php IDE/XML.php

From: Date: Sat, 02 Jul 2011 23:25:55 +0000
Subject: svn: /phd/trunk/phpdotnet/phd/Package/ Generic/ChunkedXHTML.php Generic/XHTML.php IDE/Base.php IDE/XML.php
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-8399@lists.php.net to get a copy of this message
moacir Sat, 02 Jul 2011 23:25:55 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=312826 Log: Rendering all descriptions as html * Maybe we should make this optional, render as text or html * CDATA is used in the XML format * Now is possible to render all IDE formats at once \o/ Changed paths: U phd/trunk/phpdotnet/phd/Package/Generic/ChunkedXHTML.php U phd/trunk/phpdotnet/phd/Package/Generic/XHTML.php U phd/trunk/phpdotnet/phd/Package/IDE/Base.php U phd/trunk/phpdotnet/phd/Package/IDE/XML.php Modified: phd/trunk/phpdotnet/phd/Package/Generic/ChunkedXHTML.php =================================================================== --- phd/trunk/phpdotnet/phd/Package/Generic/ChunkedXHTML.php 2011-07-02 23:17:37 UTC (rev 312825) +++ phd/trunk/phpdotnet/phd/Package/Generic/ChunkedXHTML.php 2011-07-02 23:25:55 UTC (rev 312826) @@ -67,6 +67,10 @@ break; case Render::INIT: + if ($this->appendToBuffer) { + return; //Don't create output dir when rendering to buffer + } + $this->setOutputDir(Config::output_dir() . strtolower($this->getFormatName()) . '/'); $this->postConstruct(); if (file_exists($this->getOutputDir())) { Modified: phd/trunk/phpdotnet/phd/Package/Generic/XHTML.php =================================================================== --- phd/trunk/phpdotnet/phd/Package/Generic/XHTML.php 2011-07-02 23:17:37 UTC (rev 312825) +++ phd/trunk/phpdotnet/phd/Package/Generic/XHTML.php 2011-07-02 23:25:55 UTC (rev 312826) @@ -1322,7 +1322,8 @@ return ""; } if ($open) { - return "<p><b>" . ($this->autogen('example', $props['lang']) . ++$this->cchunk["examples"]) . " "; + return "<p><b>" . ($this->autogen('example', $props['lang']) + . (isset($this->cchunk["examples"]) ? ++$this->cchunk["examples"] : "")) . " "; } return "</b></p>"; } Modified: phd/trunk/phpdotnet/phd/Package/IDE/Base.php =================================================================== --- phd/trunk/phpdotnet/phd/Package/IDE/Base.php 2011-07-02 23:17:37 UTC (rev 312825) +++ phd/trunk/phpdotnet/phd/Package/IDE/Base.php 2011-07-02 23:25:55 UTC (rev 312826) @@ -110,6 +110,14 @@ } } + public function renderHTML() { + static $format = null; + if ($format == null) { + $format = new Package_Generic_ChunkedXHTML(); + } + return $format->parse(ReaderKeeper::getReader()->readInnerXML()); + } + public function CHUNK($value) { $this->chunkFlags = $value; } @@ -241,7 +249,7 @@ public function format_refpurpose($value, $tag) { if ($this->isFunctionRefSet) { - $this->function['purpose'] = str_replace("\n", '', trim(ReaderKeeper::getReader()->readContent())); + $this->function['purpose'] = str_replace("\n", '', trim(ReaderKeeper::getReader()->readString())); } } @@ -320,14 +328,7 @@ } if ($open) { //Read the description - $reader = ReaderKeeper::getReader(); - $content = ''; - do { - $reader->read(); - if ($reader->nodeType === \XMLReader::ELEMENT) { - $content .= trim($reader->readContent()); - } - } while ($reader->name != $name); + $content = $this->renderHTML(); if (isset($this->cchunk['currentParam']) && isset($this->function['params'][$this->cchunk['currentParam']])) { $this->function['params'][$this->cchunk['currentParam']]['description'] = $content; } @@ -347,15 +348,7 @@ public function format_return($open, $name, $attrs, $props) { if ($open) { //Read the description - $reader = ReaderKeeper::getReader(); - $content = ''; - do { - $reader->read(); - //Skipping the title - if ($reader->nodeType === \XMLReader::ELEMENT && $reader->name != 'title') { - $content .= trim($reader->readContent()); - } - } while ($reader->name != 'refsect1'); + $content = $this->renderHTML(); $this->function['return']['description'] = $content; } } @@ -366,15 +359,7 @@ } if ($open) { //Read the description - $reader = ReaderKeeper::getReader(); - $content = ''; - do { - $reader->read(); - //Skipping the title - if ($reader->nodeType === \XMLReader::ELEMENT && $reader->name != 'title') { - $content .= trim($reader->readContent()); - } - } while ($reader->name != $name); + $content = $this->renderHTML(); $note = array(); $note['type'] = $name; $note['description'] = $content; @@ -385,16 +370,7 @@ public function format_errors($open, $name, $attrs, $props) { if ($open) { //Read the description - $reader = ReaderKeeper::getReader(); - $content = ''; - do { - $reader->read(); - //Skipping the title - if ($reader->nodeType === \XMLReader::ELEMENT && $reader->name != 'title') { - $content .= trim($reader->readContent()); - } - } while ($reader->name != 'refsect1'); - $this->function['errors'] = $content; + $this->function['errors'] = $this->renderHTML();; } } @@ -421,7 +397,7 @@ $entryType = ($this->cchunk['changelog']['entry'] == 'version') ? 'change' : 'version'; - $this->cchunk['changelog'][$entryType] = trim(ReaderKeeper::getReader()->readContent()); + $this->cchunk['changelog'][$entryType] = trim(ReaderKeeper::getReader()->readString()); $this->cchunk['changelog']['entry'] = $entryType; } } Modified: phd/trunk/phpdotnet/phd/Package/IDE/XML.php =================================================================== --- phd/trunk/phpdotnet/phd/Package/IDE/XML.php 2011-07-02 23:17:37 UTC (rev 312825) +++ phd/trunk/phpdotnet/phd/Package/IDE/XML.php 2011-07-02 23:25:55 UTC (rev 312826) @@ -27,7 +27,7 @@ if (isset($param['initializer'])) { $str .= ' <initializer>' . $param['initializer'] . '</initializer>' . PHP_EOL; } - $str .= ' <description>' . (isset($param['description']) ? $this->e($param['description']) : '') . '</description>' . PHP_EOL; + $str .= ' <description>' . (isset($param['description']) ? $this->cdata_str($param['description']) : '') . '</description>' . PHP_EOL; $str .= ' </param>' . PHP_EOL; } $str .= '</params>' . PHP_EOL; @@ -35,12 +35,12 @@ //Return $str .= '<return>' . PHP_EOL; $str .= ' <type>' . $this->function['return']['type'] . '</type>' . PHP_EOL; - $str .= ' <description>' . $this->e($this->function['return']['description']) . '</description>' . PHP_EOL; + $str .= ' <description>' . $this->cdata_str($this->function['return']['description']) . '</description>' . PHP_EOL; $str .= '</return>' . PHP_EOL; //Errors $str .= '<errors>' . PHP_EOL; - $str .= ' <description>' . $this->e($this->function['errors']) . '</description>' . PHP_EOL; + $str .= ' <description>' . $this->cdata_str($this->function['errors']) . '</description>' . PHP_EOL; $str .= '</errors>' . PHP_EOL; //Notes @@ -48,7 +48,7 @@ foreach ((array)$this->function['notes'] as $note) { $str .= ' <note>' . PHP_EOL; $str .= ' <type>' . $note['type'] . '</type>' . PHP_EOL; - $str .= ' <description>' . $this->e($note['description']) . '</description>' . PHP_EOL; + $str .= ' <description>' . $this->cdata_str($note['description']) . '</description>' . PHP_EOL; $str .= ' </note>' . PHP_EOL; } $str .= '</notes>' . PHP_EOL; @@ -81,6 +81,10 @@ return htmlspecialchars($data, ENT_QUOTES, 'UTF-8'); } + protected function cdata_str($data) { + return "<![CDATA[$data]]>"; + } + } /*

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