3 // +----------------------------------------------------------------------+
5 // +----------------------------------------------------------------------+
6 // | Copyright (c) 1997-2002 The PHP Group |
7 // +----------------------------------------------------------------------+
8 // | This source file is subject to version 2.02 of the PHP license, |
9 // | that is bundled with this package in the file LICENSE, and is |
10 // | available at through the world-wide-web at |
11 // | http://www.php.net/license/2_02.txt. |
12 // | If you did not receive a copy of the PHP license and are unable to |
13 // | obtain it through the world-wide-web, please send a note to |
14 // | license@php.net so we can mail you a copy immediately. |
15 // +----------------------------------------------------------------------+
16 // | Authors: Alan Knowles <alan@akbkhome.com> |
17 // +----------------------------------------------------------------------+
20 * Docbook data container (for pages and sections)
22 * @package PHP_CodeDoc
24 * @author Alan Knowles <alan@akbkhome.com>
27 class PHP_CodeDoc_Data_Docbook {
28 var $pages = array(); //
29 var $name; // name of parameter
31 var $tagname; // name that appears in url
32 var $sections = array(); // array of sections;
33 var $paras = array(); // array of paragraphs;
34 var $Operations = array(); // book methods
35 var $iOperations = array(); // book iherited Methods
37 var $_activeSection; // link to current section
38 var $_activePage; // link to active page.
40 function outputDocbook() {
41 // should read an array from para's and output the correct docbook/xml tags
43 foreach ($this->paras as $para) {
45 if (is_array($para)) {
48 $this->_outputList($para[1]);
55 echo htmlspecialchars($para) . "\n";
62 function _outputList($items) {
63 echo "<itemizedlist>\n";
64 foreach($items as $item) {
65 if (trim($item) == "") {
68 echo " <listitem>\n ". htmlspecialchars($item) ."\n </listitem>\n";
70 echo "<itemizedlist>\n";
73 function outputSummary() {
75 echo $this->pages['INDEX']->paras[0];
76 unset($this->pages['INDEX']);
81 function parse($comment) {
84 $lines = explode("\n",$comment);
86 foreach ($lines as $line) {
87 // get rid of trailing *
88 $line = preg_replace("/^\s*\/*[\*]+\/*/","",$line);
90 //$line = preg_replace("/^\s*\*/","",$line);
91 $bits = explode(' ', strtolower(trim($line)));
92 //echo "CASE {$bits[0]}\n";
97 $page = preg_replace("/\s*\@docbook_page\s*/i","",$line);
98 $this->addPara($buffer);
100 $this->addPage($page);
102 case "@docbook_section":
103 $section = preg_replace("/\s*\@docbook_section\s*/i","",$line);
104 $this->addPara($buffer);
106 $this->addSection($section);
108 case "@docbook_page_summary":
109 $summary = preg_replace("/\s*\@docbook_page_summary\s*/i","",$line);
110 $this->addPara($buffer);
112 $this->addPageSummary($summary);
115 case "@docbook_package_section":
117 $this->addPara($buffer);
119 $ps = preg_replace("/\s*\@docbook_package_section\s*/i","",$line);
122 case "@docbook_package_title":
123 $this->addPara($buffer);
125 $ps = preg_replace("/\s*\@docbook_package_title\s*/i","",$line);
126 $this->title = trim($ps);
128 case "@docbook_list":
129 $this->addPara($buffer);
133 /* Standard phpdoc stuff */
155 if (trim($line) == "") {
156 if (trim($buffer) == "") {
160 $this->addList($buffer);
163 $this->addPara($buffer);
168 $buffer .= $line . "\n";
173 $this->addPara($buffer);
178 function &addPage($page) {
181 $this->pages[$page] = new PHP_CodeDoc_Data_Docbook;
182 /* create links .. */
183 $this->_activeSection = &$this->pages[$page];
184 $this->_activePage = &$this->pages[$page];
185 $this->_activePage->type = 'Page';
186 unset($this->_activePage->pages);
188 $this->_activePage->name = $page;
189 $this->_activePage->title = $page;
190 $this->_activePage->tagname = preg_replace("/[^a-z0-9]/i", "-",trim($page));
191 return $this->pages[$page];
193 function addPageSummary($summary) {
194 $this->_activePage->summary = $summary;
197 function addSection($section) {
198 if (!$this->_activePage->type == 'Page') {
199 $this->addPage($section);
201 $section = trim($section);
202 $this->_activePage->sections[$section] = new PHP_CodeDoc_Data_Docbook;
203 $this->_activeSection = &$this->_activePage->sections[$section];
204 $this->_activeSection->name = $section;
205 $this->_activeSection->title = $section;
206 unset($this->_activeSection->pages);
207 unset($this->_activeSection->sections);
209 function addList($lines) {
210 $this->_activeSection->paras[] = array("LIST", explode("\n",$lines));
212 function addPara($lines) {
216 $this->_activeSection->paras[] = $lines;
219 function setMethod(&$method) {
220 $method->mergePhpDoc();
221 $this->_activeSection->method = &$method;
223 function mergeMethods() {
225 foreach(array_keys($this->Operations) as $id) {
226 $method = &$this->Operations[$id];
227 if ($method->name{0} == "_") {
231 $this->addSection($method->class . "::". $method->name);
233 $this->setMethod($method);
234 $this->parse($method->description->original);
236 foreach(array_keys($this->iOperations) as $id) {
238 $method = &$this->iOperations[$id];
239 if ($this->name{0} == "_") {
243 $this->addSection($method->class . "::". $method->name);
244 $this->parse($method->description->original);
245 $this->setMethod($method);
249 function longToHtml()