Overview

Packages

  • Reflection

Classes

  • Horde_Reflection
  • Horde_Reflection_CLI
  • Horde_Reflection_Html
  • Horde_Reflection_Wiki
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * The Horde_Reflection_Wiki class renders method documention in the Text_Wiki
  4:  * format.
  5:  *
  6:  * Copyright 2008-2012 Horde LLC (http://www.horde.org/)
  7:  *
  8:  * See the enclosed file COPYING for license information (LGPL). If you
  9:  * did not receive this file, see http://www.horde.org/licenses/lgpl21.
 10:  *
 11:  * @author  Duck <duck@obala.net>
 12:  * @author  Jan Schneider <jan@horde.org>
 13:  * @package Reflection
 14:  */
 15: class Horde_Reflection_Wiki extends Horde_Reflection {
 16: 
 17:     /**
 18:      * Returns a signature of the method.
 19:      *
 20:      * @return string  Method signature.
 21:      */
 22:     private function _getSignature()
 23:     {
 24:         $name = $this->_name;
 25:         $returnType = $this->_returns;
 26: 
 27:         $title = substr($this->_name, strpos($name, '_', 2) + 1);
 28:         $desc = substr($this->_help, 0, 20) . '...';
 29: 
 30:         $result = "++$title - $desc\n";
 31:         $result .= "##gray|($returnType)## ";
 32:         $result .= "##660000|$title##";
 33:         $result .= "(";
 34:         $first = true;
 35:         $nbr = 0;
 36:         while (list($name, $parameter) = each($this->_parameters)) {
 37:             $nbr++;
 38:             if ($nbr == $this->_numberOfRequiredParameters + 1) {
 39:                 $result .= " [ ";
 40:             }
 41:             if ($first) {
 42:                 $first = false;
 43:             } else {
 44:                 $result .= ', ';
 45:             }
 46:             $type = $parameter['type'];
 47:             $result .= "##gray|($type) ##";
 48:             $result .= "##336600|$name##";
 49:         }
 50:         reset($this->_parameters);
 51:         if ($nbr > $this->_numberOfRequiredParameters) {
 52:             $result .= " ] ";
 53:         }
 54:         $result .= ")";
 55:         return $result;
 56:     }
 57: 
 58:     /**
 59:      * Returns a complete wiki description of the method.
 60:      *
 61:      * @return string  A wiki snippet with the method documentation.
 62:      */
 63:     public function autoDocument()
 64:     {
 65:         $signature = $this->_getSignature();
 66:         $id = md5($this->_name);
 67:         $help = trim(strip_tags($this->_help));
 68: 
 69:         $html = "$signature\n";
 70:         if ($help) {
 71:             $html .= "\nDescription : \n<code>\n$help\n</code>\n";
 72:         }
 73: 
 74:         if (count($this->_parameters)>0) {
 75:             $html .= "Parameters: \n";
 76:             if (count($this->_parameters)>0) {
 77: 
 78:                 $html .= "||~ Type||~ Name||~ Documentation||\n";
 79:                 while (list($name, $parameter) = each($this->_parameters)) {
 80:                     $type = $parameter['type'];
 81:                     if (is_array($type)) {
 82:                         $type = implode(' | ', $type);
 83:                     }
 84:                     if (isset($parameter['doc'])) {
 85:                         $doc = htmlentities($parameter['doc']);
 86:                     } else {
 87:                         $doc = '';
 88:                         echo 'Missing doc for ' . $this->_name . '<br />';
 89:                     }
 90:                     $html .= "||$type||$name||$doc||\n";
 91:                 }
 92:                 reset($this->_parameters);
 93:             }
 94:         }
 95: 
 96:         return $html;
 97:     }
 98: 
 99: }
100: 
API documentation generated by ApiGen