cvs: phd /themes/pear pearchunkedhtml.php peartheme.php pearweb.php
| From: | Christian Weiske | Date: | Fri, 07 Nov 2008 17:55:50 +0000 |
| Subject: | cvs: phd /themes/pear pearchunkedhtml.php peartheme.php pearweb.php | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-2464@lists.php.net to get a copy of this message | ||
cweiske Fri Nov 7 17:55:50 2008 UTC
Modified files:
/phd/themes/pear pearchunkedhtml.php peartheme.php pearweb.php
Log:
DOC] Implement
<phd:pearapi phd:package="PackageName" phd:linkend="ClassName"/>
for pear themes
http://cvs.php.net/viewvc.cgi/phd/themes/pear/pearchunkedhtml.php?r1=1.10&r2=1.11&diff_format=u
Index: phd/themes/pear/pearchunkedhtml.php
diff -u phd/themes/pear/pearchunkedhtml.php:1.10 phd/themes/pear/pearchunkedhtml.php:1.11
--- phd/themes/pear/pearchunkedhtml.php:1.10 Tue Oct 28 18:17:18 2008
+++ phd/themes/pear/pearchunkedhtml.php Fri Nov 7 17:55:50 2008
@@ -5,12 +5,21 @@
* PEAR theme for the normal-html-in-many-files version
*
* @package PhD
-* @version CVS: $Id: pearchunkedhtml.php,v 1.10 2008/10/28 18:17:18 cweiske Exp $
+* @version CVS: $Id: pearchunkedhtml.php,v 1.11 2008/11/07 17:55:50 cweiske Exp $
*/
class pearchunkedhtml extends pearweb
{
private $nav = "";
+ /**
+ * URL prefix for all API doc link generated with <phd:pearapi>
+ *
+ * @var string
+ */
+ public $phd_pearapi_urlprefix = 'http://pear.php.net/package/';
+
+
+
public function __construct(array $IDs, $ext = "html")
{
parent::__construct($IDs, $ext, true);
http://cvs.php.net/viewvc.cgi/phd/themes/pear/peartheme.php?r1=1.20&r2=1.21&diff_format=u
Index: phd/themes/pear/peartheme.php
diff -u phd/themes/pear/peartheme.php:1.20 phd/themes/pear/peartheme.php:1.21
--- phd/themes/pear/peartheme.php:1.20 Wed Nov 5 20:54:59 2008
+++ phd/themes/pear/peartheme.php Fri Nov 7 17:55:50 2008
@@ -93,6 +93,7 @@
'paramdef' => 'format_suppressed_tags',
),
'part' => 'format_container_chunk',
+ 'phd:pearapi' => 'format_phd_pearapi',
'preface' => 'format_container_chunk',
'programlisting' => 'format_programlisting',
'prompt' => 'tt',
@@ -204,6 +205,7 @@
'funcdef' => false,
'refname' => 'format_refname_function_text',
),
+ 'phd:pearapi' => 'format_phd_pearapi_text',
'programlisting' => 'format_programlisting_text',
'refname' => 'format_refname_text',
'year' => 'format_year',
@@ -242,7 +244,14 @@
*/
public $trim = false;
- protected $CURRENT_ID = '';
+ /**
+ * URL prefix for all API doc link generated with <phd:pearapi>
+ *
+ * @var string
+ */
+ public $phd_pearapi_urlprefix = 'http://pear.php.net/package/';
+
+ protected $CURRENT_ID = "";
/* Current Chunk settings */
protected $cchunk = array();
@@ -362,7 +371,7 @@
* @param string $name Name of the element
* @param array $attrs Attributes present for the element. Array keys are the attribute
namespaces.
* @param array $props Associative array of additional properties
- *
+ *
* @return string
*/
public function format_root_chunk($open, $name, $attrs, $props)
@@ -390,7 +399,7 @@
* @param string $name Name of the element.
* @param array $attrs Attributes present for the element. Array keys are the attribute
namespaces.
* @param array $props Properties
- *
+ *
* @return string
*/
public function format_link($open, $name, $attrs, $props)
@@ -485,6 +494,69 @@
return $this->format_table($open, $name, $attrs, $props) .
$this->format->restorePara();
}
+ /**
+ * Creates a link to the PEAR API documentation.
+ * Uses the tag text as well as the optional attributes package, class,
+ * method and var.
+ */
+ public function format_phd_pearapi($open, $name, $attrs, $props)
+ {
+ if ($open && !$props['empty']) {
+ return '';
+ }
+
+ $text = $props['empty'] ? '' : $this->phd_pearapi_text;
+ $package = $attrs[PhDReader::XMLNS_PHD]['package'];
+ $linkend = isset($attrs[PhDReader::XMLNS_PHD]['linkend'])
+ ? $attrs[PhDReader::XMLNS_PHD]['linkend'] : null;
+ $arLinkend = explode('::', $linkend);
+ $class = null;
+ $method = null;
+ $variable = null;
+
+ if ($linkend === null) {
+ //link to package
+ if ($props['empty']) {
+ $text = $package;
+ }
+ $linktpl = '{$package}/docs/latest/li_{$package}.html';
+ } else {
+ $class = $arLinkend[0];
+ if ($props['empty']) {
+ $text = $linkend;
+ }
+ if (count($arLinkend) == 1) {
+ //link to class
+ $linktpl = '{$package}/docs/latest/{$package}/{$class}.html';
+ } else if ($arLinkend[1]{0} == '$') {
+ //link to class variable
+ $variable = $arLinkend[1];
+ $linktpl =
'{$package}/docs/latest/{$package}/{$class}.html#var{$variable}';
+ } else {
+ //link to method
+ if ($props['empty']) {
+ $text .= '()';
+ }
+ $method = $arLinkend[1];
+ $linktpl =
'{$package}/docs/latest/{$package}/{$class}.html#method{$method}';
+ }
+ }
+
+ $uri = $this->phd_pearapi_urlprefix . str_replace(
+ array('{$package}', '{$class}', '{$method}',
'{$variable}'),
+ array($package, $class, $method, $variable),
+ $linktpl
+ );
+
+ return '<a href="' . htmlspecialchars($uri) . '"'
+ . ' class="apidoclink">' . $text . '</a>';
+ }
+
+ public function format_phd_pearapi_text($value, $tag)
+ {
+ $this->phd_pearapi_text = $value;
+ }
+
public function format_programlisting($open, $name, $attrs)
{
if ($open) {
@@ -508,7 +580,7 @@
*
* @param string $value Value of the text to format.
* @param unknown_type $tag
- *
+ *
* @return string
*/
public function format_programlisting_text($value, $tag)
@@ -827,9 +899,9 @@
/**
* FIXME: This function is a crazy performance killer
- *
+ *
* @param resource $stream Stream containing the contents of a Q&A section
- *
+ *
* @return string
*/
public function qandaset($stream)
@@ -866,7 +938,7 @@
}
return '</dl>';
}
-
+
public function format_answer($open, $name, $attrs)
{
if ($open) {
http://cvs.php.net/viewvc.cgi/phd/themes/pear/pearweb.php?r1=1.7&r2=1.8&diff_format=u
Index: phd/themes/pear/pearweb.php
diff -u phd/themes/pear/pearweb.php:1.7 phd/themes/pear/pearweb.php:1.8
--- phd/themes/pear/pearweb.php:1.7 Wed Nov 5 16:45:14 2008
+++ phd/themes/pear/pearweb.php Fri Nov 7 17:55:50 2008
@@ -5,7 +5,7 @@
* PEAR theme for the many php files used for pearweb
*
* @package PhD
-* @version CVS: $Id: pearweb.php,v 1.7 2008/11/05 16:45:14 saltybeagle Exp $
+* @version CVS: $Id: pearweb.php,v 1.8 2008/11/07 17:55:50 cweiske Exp $
*/
class pearweb extends peartheme
{
@@ -15,6 +15,15 @@
protected $outputdir = '';
+ /**
+ * URL prefix for all API doc link generated with <phd:pearapi>.
+ * On pearweb, the manual is at "/manual/$lang/". This means that
+ * we can use a relative URI here to make the links work on mirrors, too.
+ *
+ * @var string
+ */
+ public $phd_pearapi_urlprefix = '../../package/';
+
/**
* Constructor