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>
29 class PHP_CodeDoc_Parser_Docbook {
33 static function read(PHP_CodeDoc_Parser $thiz, $comment,$inclass) { // called statically as part of the parser (and $this will actually be Parser)
34 //class name should be next!
35 $thiz->debug(__METHOD__, substr($comment, 0, 30));
36 // is docbook generation enabled?
37 $options = PHP_CodeDoc::$options;
38 if (!@$options['makeDocbook']) return;
41 // all docbook comments should start /*
42 if (substr(trim($comment),0,2) != "/*") {
47 $parts = explode("_",$thiz->active_package->name);
48 $pfile = $parts[count($parts) -1];
49 //* we only read sections when the filename matches the package name
50 //if (!preg_match("/\/{$pfile}.php$/",$this->rfilename)) {
55 // only understand page breaks when comments in classes
56 /* valid comment is /**(*****) some stuff without a start **** / */
57 echo "LOOKING FOR DOC BOOK \n";
59 if (preg_match('/^\s*\*\s*@/mi',$comment,$args)) {
60 $docbook = &$thiz->active_package->docbook;
61 $docbook->addPage($thiz->active_package->name);
62 $docbook->addSection('Introduction');
64 $thiz->active_package->docbookBase = $docbook->parse($comment);
69 /* otherwise we are in a header area?? */
73 function parse($comment) {
74 $lines = explode("\n",$comment);
76 foreach ($lines as $line) {
77 // get rid of trailing *
78 $line = preg_replace("/^\s*\/*[\*]+\/*/","",$line);
80 //$line = preg_replace("/^\s*\*/","",$line);
81 $bits = explode(' ', strtolower(trim($line)));
82 //echo "CASE {$bits[0]}\n";
87 $page = preg_replace("/\s*page:\s*/i","",$line);
88 PHP_CodeDoc_Parser_Docbook::addPara($buffer);
90 PHP_CodeDoc_Parser_Docbook::addPage($page);
93 $section = preg_replace("/\s*section:\s*/i","",$line);
94 PHP_CodeDoc_Parser_Docbook::addPara($buffer);
96 PHP_CodeDoc_Parser_Docbook::addSection($section);
99 $summary = preg_replace("/\s*pagesummary:\s*/i","",$line);
100 PHP_CodeDoc_Parser_Docbook::addPara($buffer);
102 PHP_CodeDoc_Parser_Docbook::addPageSummary($summary);
105 case "packagesection:":
107 PHP_CodeDoc_Parser_Docbook::addPara($buffer);
109 $ps = preg_replace("/\s*packagesection:\s*/i","",$line);
110 $this->active_package->docbookBase = trim($ps);
114 PHP_CodeDoc_Parser_Docbook::addPara($buffer);
118 PHP_CodeDoc_Parser_Docbook::addList($buffer);
122 if (trim($line) == "") {
123 if (trim($buffer) == "") {
126 PHP_CodeDoc_Parser_Docbook::addPara($buffer);
130 $buffer .= $line . "\n";
135 PHP_CodeDoc_Parser_Docbook::addPara($buffer);
136 //print_r($this->active_package->docbook);
141 function addPara($lines) {
145 $this->active_package->docbook->Operations = & $this->classes[$this->_active_class]->Operations;
146 $this->active_package->docbook->iOperations = & $this->classes[$this->_active_class]->iOperations;
154 /* ---------- method notes ------------- */
155 function parseMethodComment(&$method) {
156 // add a new section for it!
157 /* if ($method->class != $this->_active_package..... */
159 if ($method->name{0} == "_") return;
160 $docbook->addSection($method->class . "::". $method->name);
161 $this->_activeSection->method = &$method;