Manually adding version information to "random pages" now possible
| From: | Hannes Magnusson | Date: | Tue, 05 Jul 2011 19:11:31 +0000 |
| Subject: | Manually adding version information to "random pages" now possible | ||
| Groups: | php.doc | ||
| Request: | Send a blank email to phpdoc+get-969382876@lists.php.net to get a copy of this message | ||
PhD has now support for <?phpdoc print-version-for="foobar"?>
This means you can now print out the version information on any page,
such as namespace docs, language constructs or wherever.
See http://svn.php.net/viewvc?view=revision&revision=312947
for examples.
Remember, the
foobar entry needs to be available in some versions.xml file.
You can create a new versions.xml file if it doesn't already exists.
configure.php will aggregate all versions.xml under
en/<dir>/<dir>/versions.xml
-Hannes
---------- Forwarded message ----------
From: Hannes Magnusson <bjori@php.net>
Date: Tue, Jul 5, 2011 at 20:54
Subject: [DOC-CVS] svn: /phd/trunk/ package.xml
phpdotnet/phd/PI/PHPDOCHandler.php phpdotnet/phd/Package/PHP/XHTML.php
phpdotnet/phd/Render.php
To: doc-cvs@lists.php.net
bjori Tue, 05 Jul 2011 18:54:18 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=312946
Log:
Add support for <?phpdoc?>
Initially only supports <?phpdoc print-version-for="foobar"?>
where foobar is an item in the aggregated version.xml file.
print-version-for will go through the same mechanism as all
refpages to generate version information, and therefore
fallback to "may only be in svn" if no found.
Changed paths:
U phd/trunk/package.xml
A phd/trunk/phpdotnet/phd/PI/PHPDOCHandler.php
U phd/trunk/phpdotnet/phd/Package/PHP/XHTML.php
U phd/trunk/phpdotnet/phd/Render.php
Modified: phd/trunk/package.xml
===================================================================
--- phd/trunk/package.xml 2011-07-05 18:38:56 UTC (rev 312945)
+++ phd/trunk/package.xml 2011-07-05 18:54:18 UTC (rev 312946)
@@ -24,18 +24,18 @@
<active>yes</active>
</lead>
<lead>
- <name>Christian Weiske</name>
- <user>cweiske</user>
- <email>cweiske@php.net</email>
- <active>yes</active>
- </lead>
- <lead>
<name>Moacir de Oliveira</name>
<user>moacir</user>
<email>moacir@php.net</email>
<active>yes</active>
</lead>
<developer>
+ <name>Christian Weiske</name>
+ <user>cweiske</user>
+ <email>cweiske@php.net</email>
+ <active>yes</active>
+ </developer>
+ <developer>
<name>Paul M Jones</name>
<user>pmjones</user>
<email>pmjones@php.net</email>
@@ -71,7 +71,7 @@
</stability>
<license uri="http://www.opensource.org/licenses/bsd-license.php">BSD
Style</license>
<notes>
- -notes
+ - Added phpdoc PI handler to handle manually added version information.
</notes>
<contents>
@@ -117,6 +117,7 @@
</dir>
<dir name="PI">
<file name="DBHTMLHandler.php" role="php"/>
+ <file name="PHPDOCHandler.php" role="php"/>
</dir>
<file name="Autoloader.php" role="php"/>
<file name="Config.php" role="php">
Added: phd/trunk/phpdotnet/phd/PI/PHPDOCHandler.php
===================================================================
--- phd/trunk/phpdotnet/phd/PI/PHPDOCHandler.php
(rev 0)
+++ phd/trunk/phpdotnet/phd/PI/PHPDOCHandler.php 2011-07-05
18:54:18 UTC (rev 312946)
@@ -0,0 +1,29 @@
+<?php
+namespace phpdotnet\phd;
+/* $Id: PHPDOCHandler.php 293260 2010-01-08 10:41:19Z rquadling $ */
+
+class PI_PHPDOCHandler extends PIHandler {
+
+ public function __construct($format) {
+ parent::__construct($format);
+ }
+
+ public function parse($target, $data) {
+ $pattern =
"/(?<attr>[\w]+[\w\-\.]*)[\s]*=[\s]*\"(?<value>[^\"]*)\"/";
+
+ preg_match($pattern, $data, $matches);
+ switch($matches["attr"]) {
+ case "print-version-for":
+ // FIXME: Figureout a way to detect the current
language (for unknownversion)
+ return
$this->format->autogenVersionInfo($matches["value"], "en");
+ }
+ }
+
+}
+
+/*
+* vim600: sw=4 ts=4 syntax=php et
+* vim<600: sw=4 ts=4
+*/
+
+
Modified: phd/trunk/phpdotnet/phd/Package/PHP/XHTML.php
===================================================================
--- phd/trunk/phpdotnet/phd/Package/PHP/XHTML.php 2011-07-05
18:38:56 UTC (rev 312945)
+++ phd/trunk/phpdotnet/phd/Package/PHP/XHTML.php 2011-07-05
18:54:18 UTC (rev 312946)
@@ -134,12 +134,18 @@
"refname" => array(),
);
+ protected $pihandlers = array(
+ 'dbhtml' => 'PI_DBHTMLHandler',
+ 'dbtimestamp' => 'PI_DBHTMLHandler',
+ 'phpdoc' => 'PI_PHPDOCHandler',
+ );
+
public function __construct() {
parent::__construct();
$this->myelementmap =
array_merge(parent::getDefaultElementMap(),
static::getDefaultElementMap());
$this->mytextmap = array_merge(parent::getDefaultTextMap(),
static::getDefaultTextMap());
$this->dchunk = array_merge(parent::getDefaultChunkInfo(),
static::getDefaultChunkInfo());
- $this->extraIndexInformation();
+ $this->registerPIHandlers($this->pihandlers);
}
public function getDefaultElementMap() {
@@ -154,14 +160,6 @@
return $this->dchunk;
}
- public function extraIndexInformation() {
- $this->addRefname("function.include", "include");
- $this->addRefname("function.include-once", "include-once");
- $this->addRefname("function.require", "require");
- $this->addRefname("function.require-once", "require-once");
- $this->addRefname("function.return", "return");
- }
-
public function loadVersionAcronymInfo() {
$this->versions =
self::generateVersionInfo(Config::phpweb_version_filename());
$this->acronyms =
self::generateAcronymInfo(Config::phpweb_acronym_filename());
@@ -234,23 +232,27 @@
return $acronyms;
}
+ public function autogenVersionInfo($refnames, $lang) {
+ $verinfo = null;
+ foreach((array)$refnames as $refname) {
+ $verinfo = $this->versionInfo($refname);
+
+ if ($verinfo) {
+ break;
+ }
+ }
+ if (!$verinfo) {
+ $verinfo = $this->autogen("unknownversion", $lang);
+ }
+
+ $retval = '<p class="verinfo">(' .(htmlspecialchars($verinfo,
ENT_QUOTES, "UTF-8")). ')</p>';
+ return $retval;
+ }
public function format_refpurpose($open, $tag, $attrs, $props) {
if ($open) {
$retval = "";
if ($this->cchunk["verinfo"]) {
- $verinfo = "";
- foreach((array)$this->cchunk["refname"] as $refname) {
- $verinfo = $this->versionInfo($refname);
-
- if ($verinfo) {
- break;
- }
- }
- if (!$verinfo) {
- $verinfo = $this->autogen("unknownversion",
$props["lang"]);
- }
-
- $retval = '<p class="verinfo">('
.(htmlspecialchars($verinfo, ENT_QUOTES, "UTF-8")). ')</p>';
+ $retval =
$this->autogenVersionInfo($this->cchunk["refname"], $props["lang"]);
}
$refnames = implode('</span> -- <span
class="refname">',
$this->cchunk["refname"]);
Modified: phd/trunk/phpdotnet/phd/Render.php
===================================================================
--- phd/trunk/phpdotnet/phd/Render.php 2011-07-05 18:38:56 UTC (rev 312945)
+++ phd/trunk/phpdotnet/phd/Render.php 2011-07-05 18:54:18 UTC (rev 312946)
@@ -173,7 +173,10 @@
$target = $r->name;
$data = $r->value;
foreach ($this as $format) {
- $format->parsePI($target, $data);
+ $retval = $format->parsePI($target, $data);
+ if ($retval) {
+ $format->appendData($retval);
+ }
}
break;
}
--
PHP Documentation Commits Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php