3 * All abstract representations of html tags in DocBlocks are handled by the
\r
4 * classes in this file
\r
6 * Before version 1.2, phpDocumentor simply passed html to converters, without
\r
7 * much thought, except the {@link adv_htmlentities()} function was provided
\r
8 * along with a list of allowed html. That list is no longer used, in favor
\r
11 * The PDF Converter output looked wretched in version 1.1.0 because line breaks
\r
12 * in DocBlocks were honored. This meant that output often had just a few words
\r
13 * on every other line! To fix this problem, DocBlock descriptions are now
\r
14 * parsed using the {@link ParserDescParser}, and split into paragraphs. In
\r
15 * addition, html in DocBlocks are parsed into these objects to allow for easy
\r
16 * conversion in destination converters. This design also allows different
\r
17 * conversion for different templates within a converter, which separates
\r
18 * design from logic almost 100%
\r
20 * phpDocumentor :: automatic documentation generator
\r
22 * PHP versions 4 and 5
\r
24 * Copyright (c) 2002-2007 Gregory Beaver
\r
28 * This library is free software; you can redistribute it
\r
29 * and/or modify it under the terms of the GNU Lesser General
\r
30 * Public License as published by the Free Software Foundation;
\r
31 * either version 2.1 of the License, or (at your option) any
\r
34 * This library is distributed in the hope that it will be useful,
\r
35 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
36 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
37 * Lesser General Public License for more details.
\r
39 * You should have received a copy of the GNU Lesser General Public
\r
40 * License along with this library; if not, write to the Free Software
\r
41 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
43 * @category ToolsAndUtilities
\r
44 * @package phpDocumentor
\r
45 * @subpackage DescHTML
\r
46 * @author Greg Beaver <cellog@php.net>
\r
47 * @copyright 2002-2007 Gregory Beaver
\r
48 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
\r
49 * @version CVS: $Id: DescHTML.inc,v 1.5 2007/11/17 03:07:00 ashnazg Exp $
\r
51 * @link http://www.phpdoc.org
\r
52 * @link http://pear.php.net/PhpDocumentor
\r
53 * @see parserDocBlock, parserInclude, parserPage, parserClass
\r
54 * @see parserDefine, parserFunction, parserMethod, parserVar
\r
56 * @todo CS cleanup - change package to PhpDocumentor
\r
59 * Used for <<code>> in a description
\r
61 * @category ToolsAndUtilities
\r
62 * @package phpDocumentor
\r
63 * @subpackage DescHTML
\r
64 * @author Greg Beaver <cellog@php.net>
\r
65 * @copyright 2002-2007 Gregory Beaver
\r
66 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
\r
67 * @version Release: 1.4.1
\r
68 * @link http://www.phpdoc.org
\r
69 * @link http://pear.php.net/PhpDocumentor
\r
71 * @todo CS cleanup - change package to PhpDocumentor
\r
72 * @todo CS cleanup - rename class to ParserCode
\r
74 class parserCode extends parserStringWithInlineTags
\r
77 * performs the conversion of code tags
\r
79 * @param Converter &$c the converter object
\r
81 * @return string the converted code block
\r
82 * @uses Converter::ProgramExample()
\r
83 * @todo CS cleanup - rename method to convert()
\r
85 function Convert(&$c)
\r
87 if (!isset($this->value[0])) {
\r
90 if (is_string($this->value[0]) && $this->value[0]{0} == "\n") {
\r
91 $this->value[0] = substr($this->value[0], 1);
\r
93 $linktags = array();
\r
94 foreach ($this->value as $val) {
\r
95 if (phpDocumentor_get_class($val) == 'parserlinkinlinetag'
\r
96 || phpDocumentor_get_class($val) == 'parsertutorialinlinetag'
\r
98 $linktags[] = array(
\r
99 $c->postProcess($val->Convert($c, false, false)), $val);
\r
102 $a = $c->ProgramExample(rtrim(ltrim(parent::Convert($c,
\r
103 false, false), "\n\r")));
\r
104 foreach ($linktags as $tag) {
\r
105 $a = str_replace($tag[0], $tag[1]->Convert($c, false, false), $a);
\r
112 * Used for <<pre>> in a description
\r
114 * @category ToolsAndUtilities
\r
115 * @package phpDocumentor
\r
116 * @subpackage DescHTML
\r
117 * @author Greg Beaver <cellog@php.net>
\r
118 * @copyright 2002-2007 Gregory Beaver
\r
119 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
\r
120 * @version Release: 1.4.1
\r
121 * @link http://www.phpdoc.org
\r
122 * @link http://pear.php.net/PhpDocumentor
\r
124 * @todo CS cleanup - change package to PhpDocumentor
\r
125 * @todo CS cleanup - rename class to ParserPre
\r
127 class parserPre extends parserStringWithInlineTags
\r
130 * performs the conversion of code tags
\r
132 * @param Converter &$c the converter object
\r
134 * @return string the converted pre block
\r
135 * @uses Converter::PreserveWhiteSpace()
\r
136 * @todo CS cleanup - rename method to convert()
\r
138 function Convert(&$c)
\r
140 return $c->PreserveWhiteSpace(rtrim(ltrim(parent::Convert($c,
\r
141 false, false), "\n\r")));
\r
146 * Used for <<b>> in a description
\r
148 * @category ToolsAndUtilities
\r
149 * @package phpDocumentor
\r
150 * @subpackage DescHTML
\r
151 * @author Greg Beaver <cellog@php.net>
\r
152 * @copyright 2002-2007 Gregory Beaver
\r
153 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
\r
154 * @version Release: 1.4.1
\r
155 * @link http://www.phpdoc.org
\r
156 * @link http://pear.php.net/PhpDocumentor
\r
158 * @todo CS cleanup - change package to PhpDocumentor
\r
159 * @todo CS cleanup - rename class to ParserB
\r
161 class parserB extends parserStringWithInlineTags
\r
164 * performs the conversion of bold tags
\r
166 * @param Converter &$c the converter object
\r
168 * @return string the converted pre block
\r
169 * @uses Converter::Bolden()
\r
170 * @todo CS cleanup - rename method to convert()
\r
172 function Convert(&$c)
\r
174 return $c->Bolden(parent::Convert($c));
\r
179 * Used for <<i>> in a description
\r
181 * @category ToolsAndUtilities
\r
182 * @package phpDocumentor
\r
183 * @subpackage DescHTML
\r
184 * @author Greg Beaver <cellog@php.net>
\r
185 * @copyright 2002-2007 Gregory Beaver
\r
186 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
\r
187 * @version Release: 1.4.1
\r
188 * @link http://www.phpdoc.org
\r
189 * @link http://pear.php.net/PhpDocumentor
\r
191 * @todo CS cleanup - change package to PhpDocumentor
\r
192 * @todo CS cleanup - rename class to ParserI
\r
194 class parserI extends parserStringWithInlineTags
\r
197 * performs the conversion of italic tags
\r
199 * @param Converter &$c the converter object
\r
201 * @return string the converted pre block
\r
202 * @uses Converter::Italicize()
\r
203 * @todo CS cleanup - rename method to convert()
\r
205 function Convert(&$c)
\r
207 return $c->Italicize(parent::Convert($c));
\r
212 * Used for <<var>> in a description
\r
214 * @category ToolsAndUtilities
\r
215 * @package phpDocumentor
\r
216 * @subpackage DescHTML
\r
217 * @author Greg Beaver <cellog@php.net>
\r
218 * @copyright 2002-2007 Gregory Beaver
\r
219 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
\r
220 * @version Release: 1.4.1
\r
221 * @link http://www.phpdoc.org
\r
222 * @link http://pear.php.net/PhpDocumentor
\r
224 * @todo CS cleanup - change package to PhpDocumentor
\r
225 * @todo CS cleanup - rename class to ParserDescVar
\r
227 class parserDescVar extends parserStringWithInlineTags
\r
230 * performs the conversion of variable tags
\r
232 * @param Converter &$c the converter object
\r
234 * @return string the converted pre block
\r
235 * @uses Converter::Varize()
\r
236 * @todo CS cleanup - rename method to convert()
\r
238 function Convert(&$c)
\r
240 return $c->Varize(parent::Convert($c));
\r
245 * Used for <<samp>> in a description
\r
247 * @category ToolsAndUtilities
\r
248 * @package phpDocumentor
\r
249 * @subpackage DescHTML
\r
250 * @author Greg Beaver <cellog@php.net>
\r
251 * @copyright 2002-2007 Gregory Beaver
\r
252 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
\r
253 * @version Release: 1.4.1
\r
254 * @link http://www.phpdoc.org
\r
255 * @link http://pear.php.net/PhpDocumentor
\r
257 * @todo CS cleanup - change package to PhpDocumentor
\r
258 * @todo CS cleanup - rename class to ParserSamp
\r
260 class parserSamp extends parserStringWithInlineTags
\r
263 * performs the conversion of sample tags
\r
265 * @param Converter &$c the converter object
\r
267 * @return string the converted pre block
\r
268 * @uses Converter::Sampize()
\r
269 * @todo CS cleanup - rename method to convert()
\r
271 function Convert(&$c)
\r
273 return $c->Sampize(parent::Convert($c));
\r
278 * Used for <<kbd>> in a description
\r
280 * @category ToolsAndUtilities
\r
281 * @package phpDocumentor
\r
282 * @subpackage DescHTML
\r
283 * @author Greg Beaver <cellog@php.net>
\r
284 * @copyright 2002-2007 Gregory Beaver
\r
285 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
\r
286 * @version Release: 1.4.1
\r
287 * @link http://www.phpdoc.org
\r
288 * @link http://pear.php.net/PhpDocumentor
\r
290 * @todo CS cleanup - change package to PhpDocumentor
\r
291 * @todo CS cleanup - rename class to ParserKbd
\r
293 class parserKbd extends parserStringWithInlineTags
\r
296 * performs the conversion of keyboard tags
\r
298 * @param Converter &$c the converter object
\r
300 * @return string the converted pre block
\r
301 * @uses Converter::Kbdize()
\r
302 * @todo CS cleanup - rename method to convert()
\r
304 function Convert(&$c)
\r
306 return $c->Kbdize(parent::Convert($c));
\r
311 * Used for <<br>> in a description
\r
313 * @category ToolsAndUtilities
\r
314 * @package phpDocumentor
\r
315 * @subpackage DescHTML
\r
316 * @author Greg Beaver <cellog@php.net>
\r
317 * @copyright 2002-2007 Gregory Beaver
\r
318 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
\r
319 * @version Release: 1.4.1
\r
320 * @link http://www.phpdoc.org
\r
321 * @link http://pear.php.net/PhpDocumentor
\r
323 * @todo CS cleanup - change package to PhpDocumentor
\r
324 * @todo CS cleanup - rename class to ParserBr
\r
326 class parserBr extends parserStringWithInlineTags
\r
329 * performs the conversion of linebreak tags
\r
331 * @param Converter &$c the converter object
\r
333 * @return string the converted pre block
\r
334 * @uses Converter::Br()
\r
335 * @todo CS cleanup - rename method to convert()
\r
337 function Convert(&$c)
\r
339 return $c->Br($this->getString());
\r
344 * Used for lists <<ol>> and <<ul>>
\r
346 * @category ToolsAndUtilities
\r
347 * @package phpDocumentor
\r
348 * @subpackage DescHTML
\r
349 * @author Greg Beaver <cellog@php.net>
\r
350 * @copyright 2002-2007 Gregory Beaver
\r
351 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
\r
352 * @version Release: 1.4.1
\r
353 * @link http://www.phpdoc.org
\r
354 * @link http://pear.php.net/PhpDocumentor
\r
356 * @todo CS cleanup - change package to PhpDocumentor
\r
357 * @todo CS cleanup - rename class to ParserList
\r
359 class parserList extends parserStringWithInlineTags
\r
370 * Constructor - create a new list
\r
372 * @param integer $numbered a reference number for the new list
\r
374 function parserList($numbered)
\r
376 $this->numbered = $numbered;
\r
380 * add an item to a list
\r
382 * @param parserStringWithInlineTags $item the item to add
\r
386 function addItem($item)
\r
388 $this->value[$this->items++] = $item;
\r
394 * @param parserList $list the list to add
\r
398 function addList($list)
\r
400 $this->value[$this->items++] = $list;
\r
404 * performs the conversion of list tags
\r
406 * @param Converter &$c the converter object
\r
408 * @return string the converted pre block
\r
409 * @uses Converter::ListItem() enclose each item of the list
\r
410 * @uses Converter::EncloseList() enclose the list
\r
411 * @todo CS cleanup - rename method to convert()
\r
413 function Convert(&$c)
\r
416 foreach ($this->value as $item) {
\r
417 $list .= $c->ListItem(trim($item->Convert($c)));
\r
419 return $c->EncloseList($list, $this->numbered);
\r