cvs: pear /QA_Peardoc_Coverage package.xml /QA_Peardoc_Coverage/QA/Peardoc Coverage.php /QA_Peardoc_Coverage/QA/Peardoc/Coverage ClassList.php
MethodList.php Renderer.php /QA_Peardoc_Coverage/QA/Peardoc/Coverage/Renderer DeveloperList.php ExtendetPackageList.php MissingDocsPerDeveloper.php
SimplePackageList.php /QA_Peardoc_Coverage/examples displayMissing.php genData.php genDeveloperStats.php genExtendetStats.php
genMissingDocsPerDeveloper.php genSimpleStats.php gtk2VardumpData.php /QA_Peardoc_Coverage/tests QA_Peardoc_CoverageTest.php
QA_Peardoc_Coverage_ClassListTest.php QA_Peardoc_Coverage_MethodListTest.php QA_Peardoc_Coverage_Renderer_DeveloperListTest.php
QA_Peardoc_Coverage_Renderer_SimpleClassListTest.php config.php maketests.php

From: Date: Thu, 26 Oct 2006 06:26:12 +0000
Subject: cvs: pear /QA_Peardoc_Coverage package.xml /QA_Peardoc_Coverage/QA/Peardoc Coverage.php /QA_Peardoc_Coverage/QA/Peardoc/Coverage ClassList.php
MethodList.php Renderer.php /QA_Peardoc_Coverage/QA/Peardoc/Coverage/Renderer DeveloperList.php ExtendetPackageList.php MissingDocsPerDeveloper.php
SimplePackageList.php /QA_Peardoc_Coverage/examples displayMissing.php genData.php genDeveloperStats.php genExtendetStats.php
genMissingDocsPerDeveloper.php genSimpleStats.php gtk2VardumpData.php /QA_Peardoc_Coverage/tests QA_Peardoc_CoverageTest.php
QA_Peardoc_Coverage_ClassListTest.php QA_Peardoc_Coverage_MethodListTest.php QA_Peardoc_Coverage_Renderer_DeveloperListTest.php
QA_Peardoc_Coverage_Renderer_SimpleClassListTest.php config.php maketests.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-42821@lists.php.net to get a copy of this message
cweiske Thu Oct 26 06:26:12 2006 UTC Added files: /pear/QA_Peardoc_Coverage package.xml /pear/QA_Peardoc_Coverage/QA/Peardoc Coverage.php /pear/QA_Peardoc_Coverage/QA/Peardoc/Coverage ClassList.php MethodList.php Renderer.php /pear/QA_Peardoc_Coverage/QA/Peardoc/Coverage/Renderer DeveloperList.php ExtendetPackageList.php MissingDocsPerDeveloper.php SimplePackageList.php /pear/QA_Peardoc_Coverage/examples displayMissing.php genData.php genDeveloperStats.php genExtendetStats.php genMissingDocsPerDeveloper.php genSimpleStats.php gtk2VardumpData.php /pear/QA_Peardoc_Coverage/tests QA_Peardoc_CoverageTest.php QA_Peardoc_Coverage_ClassListTest.php QA_Peardoc_Coverage_MethodListTest.php QA_Peardoc_Coverage_Renderer_DeveloperListTest.php QA_Peardoc_Coverage_Renderer_SimpleClassListTest.php config.php maketests.php Log: Initial commit of QA_Peardoc_Coverage

http://cvs.php.net/viewvc.cgi/pear/QA_Peardoc_Coverage/package.xml?view=markup&rev=1.1 Index: pear/QA_Peardoc_Coverage/package.xml +++ pear/QA_Peardoc_Coverage/package.xml <?xml version="1.0" encoding="utf-8"?> <package version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd"> <name>QA_Peardoc_Coverage</name> <channel>pear.php.net</channel> <summary>PEAR documentation coverage analysis.</summary> <description> Takes the PEAR documentation CVS and the PEAR package CVS directories, and compares which packages have been documented. Also checks which classes and methods have been documented, and generates HTML reports. </description> <lead> <name>Christian Weiske</name> <user>cweiske</user> <email>cweiske@php.net</email> <active>yes</active> </lead> <date>2006-10-19</date> <version> <release>0.2.0</release> <api>0.2.0</api> </version> <stability> <release>beta</release> <api>beta</api> </stability> <license uri="http://www.gnu.org/licenses/lgpl.html">LGPL</license> <notes> First version </notes> <contents> <dir name="/" baseinstalldir="/"> <dir name="QA"> <dir name="Peardoc"> <file name="Coverage.php" role="php"/> <dir name="Coverage"> <file name="ClassList.php" role="php"/> <file name="MethodList.php" role="php"/> <file name="Renderer.php" role="php"/> <dir name="Renderer"> <file name="DeveloperList.php" role="php"/> <file name="ExtendetPackageList.php" role="php"/> <file name="MissingDocsPerDeveloper.php" role="php"/> <file name="SimplePackageList.php" role="php"/> </dir> </dir> </dir> </dir> <dir name="examples"> <file name="displayMissing.php" role="doc"/> <file name="genData.php" role="doc"/> <file name="genDeveloperStats.php" role="doc"/> <file name="genExtendetStats.php" role="doc"/> <file name="genMissingDocsPerDeveloper.php" role="doc"/> <file name="genSimpleStats.php" role="doc"/> <file name="gtk2VardumpData.php" role="doc"/> </dir> <dir name="tests"> <file name="config.php" role="test"/> <file name="QA_Peardoc_CoverageTest.php" role="test"/> <file name="QA_Peardoc_Coverage_ClassListTest.php" role="test"/> <file name="QA_Peardoc_Coverage_MethodListTest.php" role="test"/> <file name="QA_Peardoc_Coverage_Renderer_DeveloperListTest.php" role="test"/> <file name="QA_Peardoc_Coverage_Renderer_SimpleClassListTest.php" role="test"/> </dir> </dir> </contents> <dependencies> <required> <php> <min>5.1</min> <max>5.999.999</max> </php> <pearinstaller> <min>1.4.1</min> </pearinstaller> </required> </dependencies> <phprelease/> <changelog> <release> <version> <release>0.1.0</release> <api>0.1.0</api> </version> <stability> <release>beta</release> <api>beta</api> </stability> <date>2006-10-18</date> <license uri="http://www.gnu.org/licenses/lgpl.html">LGPL</license> <notes> First version </notes> </release> </changelog> </package> http://cvs.php.net/viewvc.cgi/pear/QA_Peardoc_Coverage/QA/Peardoc/Coverage.php?view=markup&rev=1.1 Index: pear/QA_Peardoc_Coverage/QA/Peardoc/Coverage.php +++ pear/QA_Peardoc_Coverage/QA/Peardoc/Coverage.php <?php require_once 'QA/Peardoc/Coverage/ClassList.php'; require_once 'QA/Peardoc/Coverage/MethodList.php'; /* <!-- missing entities --> <!ENTITY copy "(C)"> <!ENTITY agrave ""> <!ENTITY dollar "$"> <!ENTITY eacute ""> <!ENTITY euro "€"> */ /** * Simple peardoc coverage analysis. * Compares the classes and methods in PEAR packages * with the PEAR documentation, trying to find * out which packages aren't documented at all, * where documentation of parts is lacking or * which packages are fully documented. * * IDs in peardoc: * --------------- * $packagename has "_" replaced with "-" * * = Class: * package.$category.$packagename * package.html.html-form * package.$category.$shortpackagename * package.gtk.filedrop * * = Methods: * package.$category.$packagename.$methodname * package.html.html-template-it.show * package.html.html-template-it.show.desc * package.html.html-template-it.show.parameter * package.html.html-template-it.show.throws * package.$category.$packagename.$classname.$methodname * package.html.html-quickform.html-quickform.addelement * * = Constructor: * package.$category.$packagename.constructor * package.gtk2.entrydialog.constructor * package.$category.$packagename.$classname.$classname * package.datetime.calendar.calendar-day.calendar-day * * * TODO: * - differentiate between stable and unstable packages * (read package.xml) * * @author Christian Weiske <cweiske@php.net> */ class QA_Peardoc_Coverage { /** * Special category associations. * * key: package name * value: category name */ public static $arCategoryAssociation = array( 'benchmark' => 'benchmarking', 'calendar' => 'datetime', 'games_chess' => 'structures', 'genealogy_gedcom' => 'fileformats', 'fsm' => 'processing', 'i18nv2' => 'internationalization', 'inline_c' => 'php', 'message' => 'encryption', 'mime_type' => 'tools', 'ole' => 'structures', 'pager' => 'html', 'pager_sliding' => 'html', 'pecl_gen' => 'php', 'phpdoc' => 'tools', 'phpdocumentor' => 'tools', 'safe_html' => 'html', 'search_mnogosearch' => 'tools', 'selenium' => 'testing', 'spreadsheet_excel_writer' => 'fileformats', 'sql_parser' => 'database', 'translation' => 'internationalization', 'translation2' => 'internationalization', 'tree' => 'structures', 'xml_rpc' => 'webservices', 'xml_rpc2' => 'webservices', ); /** * List with package category name => Doc category name * associations. * * Doc category assignments may be arrays of strings. * * @var array */ public static $arCategoryDocNames = array( 'archive' => 'fileformats', 'auth' => 'authentication', 'cache' => 'caching', 'codegen' => 'tools', 'config' => 'configuration', 'contact' => 'fileformats', 'crypt' => 'encryption', 'date' => 'datetime', 'db' => 'database', 'dba' => 'database', 'file' => array('fileformats', 'filesystem'), 'i18n' => 'internationalization', 'image' => 'images', 'liveuser' => 'authentication', 'log' => 'logging', 'mdb' => 'database', 'mdb2' => 'database', 'mp3' => 'fileformats', 'net' => 'networking', 'rdf' => 'semanticweb', 'services' => 'webservices', 'soap' => 'webservices', 'stream' => 'streams', ); /** * Lowercase package names that should be ignored. * @var array */ public static $arIgnoredPackages = array( 'forum', 'perm_liveuser' ); /** * Creates a new coverage checker instance. * * @param string $strManualPath Full path to the manual.xml file * of the pear documentation. */ public function __construct($strManualPath, $strPearDir) { $this->strManualPath = $strManualPath; $this->strPearDir = $strPearDir; }//public function __construct($strManualPath, $strPearDir) /** * Generates the coverage analysis * * @return array Documentation coverage array. Pass it to a render() method. */ public function generateCoverage() { $this->loadXmlDocument($this->strManualPath); /* * This is an array with doc statistics. * key: category * value: array * key: package name * value: array * special key: '*docid*' * special value: documentation id * NULL if no doc * special key: '*path*' * special value: path to package cvs * key: classname * value: array, NULL if no doc * key: methodname * value: ?? */ $arDoc = array(); foreach (self::getPackageList($this->strPearDir) as $strPackageDir => $strPackage ) { if (in_array(strtolower($strPackage), self::$arIgnoredPackages)) { continue; } $arCategories = self::getCategory($strPackage); foreach ($arCategories as $strCategory) { $strId = $this->getPackageDocId($strPackage, $strCategory); if ($strId !== null) { break; } } if ($strId === null) { $arDoc[$strCategory][$strPackage] = array( '*docid*' => null, '*package*' => $strPackageDir ); } else { $arDoc[$strCategory][$strPackage] = $this->getPackageCoverage($strPackage, $strCategory, $strId, $strPackageDir); } } ksort($arDoc); foreach ($arDoc as &$arPackages) { ksort($arPackages); } return $arDoc; }//public function generateCoverage() /** * Renders the coverage analysis into a viewable format. * * @param array $arCoverage Coverage analysis array from generateCoverage() * @param string $strRenderer Classname of the renderer * * @return string Viewable coverage analysis. */ public static function renderCoverage( $arCoverage, $strRenderer = 'QA_Peardoc_Coverage_Renderer_SimplePackageList' ) { if (!class_exists($strRenderer)) { require_once str_replace('_', '/', $strRenderer) . '.php'; } return call_user_func( array($strRenderer, 'render'), $arCoverage ); }//public static function renderCoverage(..) /** * Loads the given xml file into a DOM document. * * @param string $strManualPath Full path to the manual.xml file * of the pear documentation. * @return boolean true if all is ok. */ protected function loadXmlDocument($strManualPath) { if (!file_exists($strManualPath)) { throw new Exception('Manual file does not exist: ' . $strManualPath); } $strPath = getcwd(); chdir(dirname($strManualPath)); $this->doc = new DOMDocument(); $this->doc->resolveExternals = true; $this->doc->substituteEntities = true; if ($this->doc->load($strManualPath)) { $this->xpath = new DOMXPath($this->doc); chdir($strPath); return true; } else { chdir($strPath); throw new Exception('manual XML could not be loaded.'); } }//protected function loadXmlDocument($strManualPath) /** * Returns a list of packages and their paths * * @param string $strPearDir PEAR CVS directory * @return array Array with package dir as key and package name as value */ public static function getPackageList($strPearDir) { $arPackages = array(); if (substr($strPearDir, -1) != '/') { $strPearDir .= '/'; } foreach ( glob($strPearDir . '*/packag{e,e2}.xml', GLOB_BRACE) as $strPackageFilePath ) { $strPackageDir = substr($strPackageFilePath, 0, strrpos($strPackageFilePath, '/')); $arPackages[$strPackageDir] = basename($strPackageDir); } asort($arPackages); return $arPackages; }//public static function getPackageList($strPearDir) /** * Returns the category name for the package. * * @param string $strPackage Package name (e.g. Gtk2_EntryDialog) * @return string Array with category names (lowercase) */ public static function getCategory($strPackage) { $strPackage = strtolower($strPackage); if (isset(self::$arCategoryAssociation[$strPackage])) { $strCategory = self::$arCategoryAssociation[$strPackage]; } else { $nPos = strpos($strPackage, '_'); if ($nPos === false) { $strCategory = $strPackage; } else { $strCategory = substr($strPackage, 0, $nPos); } } if (isset(self::$arCategoryDocNames[$strCategory])) { $arCategories = self::$arCategoryDocNames[$strCategory]; } else { $arCategories = array($strCategory); } if (!is_array($arCategories)) { $arCategories = array($arCategories); } $arCategories = array_map('strtolower', $arCategories); return $arCategories; }//public static function getCategory($strPackage) /** * Returns the ID of the XML node of the package * in the pear documentation. * * @param string $strPackage Package name * @param string $strCategory Category name, gotten from self::getCategory() * * @return string The id, or NULL if not found -> not documented. */ public function getPackageDocId($strPackage, $strCategory) { $strCategory = strtolower($strCategory); $strPackageIdName = strtolower(str_replace('_', '-', $strPackage)); $strPackageIdName2 = strtolower(str_replace('_', '-', substr( $strPackage, strpos($strPackage, '_') + 1 ) )); $strId = 'package.' . $strCategory . '.' . $strPackageIdName; $strId2 = 'package.' . $strCategory . '.' . $strPackageIdName2; $strId3 = 'core.' . $strCategory . '.' . $strPackageIdName; //echo $strId . "|" . $strId2 . "|" . $strId3 . "\n"; if ($this->existsId($strId)) { return $strId; } else if ($this->existsId($strId2)) { return $strId2; } else if ($this->existsId($strId3)) { return $strId3; } else { return null; } }//public function getPackageDocId($strPackage) /** * Checks if an id exists in the manual * * @param string $strId xml id="" to check * @return boolean True if it exists, false if not */ public function existsId($strId) { //echo $strId; return $this->doc->getElementById($strId) != null; }//public function existsId($strId) /** * Creates the documentation coverage for the given package. * * @param string $strPackage Package name * @param string $strCategory Category (lowercase) * @param string $strBaseId Base documentation id attribute * @param string $strPackageDir Package directory * * @return array Array with doc coverage information */ public function getPackageCoverage($strPackage, $strCategory, $strBaseId, $strPackageDir) { $arDoc = array( '*docid*' => $strBaseId, '*package*' => $strPackageDir ); foreach ( QA_Peardoc_Coverage_ClassList::getClassList($strPackageDir) as $strClassFile ) { $arClass = QA_Peardoc_Coverage_MethodList::getMethods($strClassFile); if ($arClass === false) { continue; } list($strClassName, $arMethods) = $arClass; //Check if class is documented $strClassDocId = $strBaseId . '.' . strtolower(str_replace('_', '-', $strClassName)); if (!$this->existsId($strClassDocId)) { //FIXME: if classname is the same as package name -> short version //class is not documented $arDoc[$strClassName] = null; continue; } foreach ($arMethods as $strMethod => $bDocBlock) { $strMethodDocId = $strClassDocId . '.' . strtolower(str_replace('_', '-', $strMethod)); $arDoc[$strClassName][$strMethod] = $this->existsId($strMethodDocId); }//foreach method }//foreach class return $arDoc; }//public function getPackageCoverage($strPackage, $strCategory, $strBaseId, $strPackageDir) }//class QA_Peardoc_Coverage ?> http://cvs.php.net/viewvc.cgi/pear/QA_Peardoc_Coverage/QA/Peardoc/Coverage/ClassList.php?view=markup&rev=1.1 Index: pear/QA_Peardoc_Coverage/QA/Peardoc/Coverage/ClassList.php +++ pear/QA_Peardoc_Coverage/QA/Peardoc/Coverage/ClassList.php <?php /** * Class and method list for a given package directory. * * Don't list: * - doc|docs directory * - examples * - test|tests * * @author Christian Weiske <cweiske@php.net> */ class QA_Peardoc_Coverage_Classlist { protected static $arBadFiles = array( '/tests/', '/test/', '/test.php', '/test_.+.php', '/data/', '/cases/', '/demo/', '/doc/', '/docs/', '/example/', '/examples/', '/Examples/', '/example.php', '/.+_example.php', '/.+Example.php', '/scripts/', '/buildPackage.php', '/compileAll.php', '/createPackageXml.php', '/generate_package_xml.php', '/generate_package2_xml.php', '/generatePackage.xml.php', 'constants.php', '/makepackage.php', '/package.php', '/package_.+.php', '/test.+.php', '/updatePear.php', /* '/DBA_Relational/Toolbox.php', '/DB_DOM/DB_DOM.php', '/fix.+Files.php', '/Gtk_Styled/Buttons.php', '/HTTP_WebDAV_Client/Client.php', '/HTTP_WebDAV_Server/file.php', '/MDB_Frontend/Common.php', '/MDB_Frontend/Dump.php', '/MDB_Frontend/Frontend.php', '/MDB_Frontend/Login.tpl.php', '/MDB_Frontend/Update.php', '/PDBPLUS/pdbplus.php', '/PDBPLUS/readline.php', '/PEAR/PEAR.php', '/PEAR_Frontend_Web/WebInstaller.php', '/PHPDoc/front-end.php', '/PHPDoc/index.php', '/PHPDoc/prepend.php', '/PHP_Parser/skeleton.php', '/PHP_ParserGenerator/Lemon.php', '/PHP_ParserGenerator/parsephp.php', '/PhpDocumentor/phpdoc.php', '/SOAP_Interop/', '/SQL_Parser/Dialect_.+.php', '/SQL_Parser/ctype.php', '/Science_Chemistry/Chemistry.php', '/Services_Weather/buildMetarDB.php', '/Translation/translation.str_mgmt.php', '/XML_HTMLSax/XML_HTMLSax.php', '/Auth/Auth/Auth.php', '/DBA/DBA/Compatibility.php', '/DB_DataObject/DataObject/createTables.php', '/Forum/', '/HTML_AJAX/js/build.php', '/HTML_Page/Page/Doctypes.php', '/HTML_Page/Page/Namespaces.php', '/HTML_Page2/Page2/Doctypes.php', '/HTML_Page2/Page2/Namespaces.php', '/HTTP_SessionServer/SessionServer/SaveHandler.php', '/I18N/Messages/determineLanguage.inc.php', '/I18Nv2/.+/.+.php', '/Image_Graph/Graph/Config.php', '/Image_Graph/Graph/Constants.php', '/Image_Transform/Driver/.+.php', '/Image_Transform/imgtests/.+.php', '/MDB/MDB/reverse_engineer_xml_schema.php', '/Math_Fibonacci/Fibonacci/_fibonacciTable.php', '/Message/misc/.+.php', '/Net_GameServerQuery/GameServerQuery/Games.php', '/Net_SmartIRC/SmartIRC/defines.php', '/PEAR_Frontend_Gtk2/Gtk2/Checks.php', '/PHP_Compat/Compat/', '/PHP_CompatInfo/CompatInfo/', */ ); /** * Returns a list of .php files in the given * directory and its subdirectories. * The files do not match self::$arBadFiles. * * @param string $strPackageDir Directory to scan * @param boolean $bAbsolute Return absolute file paths * (or relative to package dir) * @return array Array with absolute file paths */ public static function getClassList($strPackageDir, $bAbsolute = true) { if (!file_exists($strPackageDir) || !is_dir($strPackageDir)) { throw new Exception("Package directory does not exist: " . $strPackageDir); } if (substr($strPackageDir, -1) != '/') { $strPackageDir .= '/'; } $strPath = getcwd(); chdir($strPackageDir); $arFiles = preg_grep( '!(' . implode(self::$arBadFiles, '|') . ')!', glob('./' . '{*,*/*,*/*/*,*/*/*/*}.php', GLOB_BRACE), PREG_GREP_INVERT ); foreach ($arFiles as $id => $strFile) { if ($bAbsolute) { $arFiles[$id] = $strPackageDir . substr($strFile, 2); } else { $arFiles[$id] = substr($strFile, 2); } } chdir($strPath); return $arFiles; }//public static function getClassList($strPackageDir, $bAbsolute = true) }//class QA_Peardoc_Coverage_Classlist ?> http://cvs.php.net/viewvc.cgi/pear/QA_Peardoc_Coverage/QA/Peardoc/Coverage/MethodList.php?view=markup&rev=1.1 Index: pear/QA_Peardoc_Coverage/QA/Peardoc/Coverage/MethodList.php +++ pear/QA_Peardoc_Coverage/QA/Peardoc/Coverage/MethodList.php <?php /** * Returns a method list for the class * defined in the given filename. * * @author Christian Weiske <cweiske@php.net> */ class QA_Peardoc_Coverage_MethodList { /** * Returns a method list for the class * defined in the given filename. * * @param string $strClassFile Path of a .php file to load * @return array Array with classname and methods */ public static function getMethods($strClassFile) { if (!file_exists($strClassFile)) { throw new Exception('File does not exist: ' . $strClassFile); } $strClassName = self::getClassnameFromFilename($strClassFile); if ($strClassName === false) { return false; } $bWaitForClassname = false; $bWaitForMethodname = false; $arMethods = array(); foreach ( token_get_all( file_get_contents($strClassFile) ) as $token ) { if (!is_string($token)) { list($nId, $strText) = $token; if ($nId == T_CLASS) { $bWaitForClassname = true; } else if ($nId == T_FUNCTION) { $bWaitForMethodname = true; } else if ($bWaitForClassname && $nId == T_STRING) { $strClassName = $strText; $bWaitForClassname = false; } else if ($bWaitForMethodname && $nId == T_STRING) { $strMethodname = $strText; //FIXME: check if docblock //FIXME: use public methods only $arMethods[$strMethodname] = false; $bWaitForMethodname = false; } } } return array($strClassName, $arMethods); }//public static function getMethods($strClassFile) /** * Tries to guess a classname from a given filename * * @param string $strClassFile .php filename * @return string Class name OR false if no class found */ public static function getClassnameFromFilename($strClassFile) { //simple: open file and search for "class classname" $strContent = file_get_contents($strClassFile); if (preg_match('/' . "(?:\r|\n)" . '\\s*(?:abstract\\s+)?(?:final\\s+)?(?:[Cc]lass|interface)\\s+([A-Za-z0-9_]+)/', $strContent, $arMatches)) { return $arMatches[1]; } else { //no match? //throw new Exception('No classname in ' . $strClassFile); return false; } }//public static function getClassnameFromFilename($strClassFile) }//class QA_Peardoc_Coverage_MethodList ?> http://cvs.php.net/viewvc.cgi/pear/QA_Peardoc_Coverage/QA/Peardoc/Coverage/Renderer.php?view=markup&rev=1.1 Index: pear/QA_Peardoc_Coverage/QA/Peardoc/Coverage/Renderer.php +++ pear/QA_Peardoc_Coverage/QA/Peardoc/Coverage/Renderer.php <?php /** * Renderer interface. */ interface QA_Peardoc_Coverage_Renderer { /** * This method gets the $arDoc array * with coverage analysis, and returns * a string with the rendered coverage. */ public function render($arDoc); }//interface QA_Peardoc_Coverage_Renderer ?> http://cvs.php.net/viewvc.cgi/pear/QA_Peardoc_Coverage/QA/Peardoc/Coverage/Renderer/DeveloperList.php?view=markup&rev=1.1 Index: pear/QA_Peardoc_Coverage/QA/Peardoc/Coverage/Renderer/DeveloperList.php +++ pear/QA_Peardoc_Coverage/QA/Peardoc/Coverage/Renderer/DeveloperList.php <?php require_once 'QA/Peardoc/Coverage/Renderer.php'; require_once 'HTML/Table.php'; /** * Renders a list with developers, the number of packages * they maintain and the documented/undocumented ratio * * @author Christian Weiske <cweisek@php.net> */ class QA_Peardoc_Coverage_Renderer_DeveloperList implements QA_Peardoc_Coverage_Renderer { public static $colNotDocumented = '#F00'; public static $colDocumented = '#0F0'; public static $arLevels = array( 100 => 'Well done', 90 => 'Not bad', 50 => 'Should be better', 30 => 'Shame on you' ); /** * Returns the color code matching the number. * * @param float $flNumber Number (x/y), !no! percentage * @return string HTML color #0AF */ public static function getColor($flNumber) { if ($flNumber == 1) { return '#0F0'; } else if ($flNumber >= 0.9) { return '#dfff00'; } else if ($flNumber >= 0.5) { return '#FF0'; } else if ($flNumber >= 0.3) { return '#F70'; } else { return '#F00'; } }//public static function getColor($flNumber) /** * Renders the given coverage array and * returns the HTML. */ public function render($arDoc) { $arMaintainer = self::getMaintainers($arDoc); $n = "\n"; $out = ''; $out .= '<?xml version="1.0" encoding="utf-8" ?>' . $n . '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ' . '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'; $out .= '<html><head><title>PEAR Documentation coverage by developer</title></head><body>'; $out .= '<table border="1"><caption>' . 'PEAR documentation coverage by developer ' . date('Y-m-d H:i:s') . '</caption>' . $n; $arMaintainers = self::getMaintainers($arDoc); uasort($arMaintainers, array('self', 'compareMaintainers')); $out .= '<thead>' . '<tr><th>Place</th><th>Developer</th><th>Docced</th><th>Packages</th><th>Percentage</th>' . '<th>Undocumented Packages</th>' . '</tr>' . '</thead>' . $n; $nPlace = 0; $nNextNumber = 101; reset(self::$arLevels); foreach ($arMaintainers as $strUsername => $arMaintainer) { $num = $arMaintainer['docced'] / $arMaintainer['packages']; $glatt = intval($num * 100); if ($glatt < $nNextNumber) { $strLevel = current(self::$arLevels); $out .= '<tr><th colspan="6">' . $strLevel . '</th></tr>' . $n; next(self::$arLevels); $nNextNumber = key(self::$arLevels); } $arUndocumented = array(); if ($glatt != 100) { foreach ($arMaintainer['packagelist'] as $strPackageName => $arPackage) { if ($arPackage['*docid*'] === null) { $arUndocumented[] = '<a href="http://pear.php.net/package/' . $strPackageName . '">' . $strPackageName . '</a>'; } } } $out .= '<tr>' . '<td>' . ++$nPlace . '</td>' . '<td><a href="http://pear.php.net/user/' . $strUsername . '">' . $strUsername . '</a></td>' . '<td>' . $arMaintainer['docced'] . '</td>' . '<td>' . $arMaintainer['packages'] . '</td>' . '<td style="background-color:' . self::getColor($num) . '">' . number_format($num * 100, 2) . '%</td>' . '<td>' . implode(', ', $arUndocumented) . '</td>' . '</tr>' . $n ; } $out .= '</table>' . $n; $out .= '</body></html>'; return $out; }//public function render($arDoc) /** * Returns an array of package maintainer usernames, * their email address, real name and the packages * maintained by them. Also lists which packages are * not docced, and which are. * * @param array $arDoc Array as passed to render() method. * @return array Array with the following data: * [username] => array( * [name] => Real name * [email] => Email address * [docced] => # of documented packages * [packages] => # of packages at all * [packagelist] => array with package names (key) * value is reference to doc array * ) */ public static function getMaintainers($arDoc) { $arMaintainers = array(); foreach ($arDoc as $strCategory => &$arPackages) { foreach ($arPackages as $strPackageName => &$arPackage) { $strPath = $arPackage['*package*']; $strV1 = $strPath . '/package.xml'; $strV2 = $strPath . '/package2.xml'; if (file_exists($strV2)) { $strPackageXmlPath = $strV2; } else { $strPackageXmlPath = $strV1; } $arPackageMaintainers = self::getPackageMaintainers( $strPackageXmlPath ); foreach ($arPackageMaintainers as $strUsername => $arMaintainer) { if (!isset($arMaintainers[$strUsername])) { $arMaintainers[$strUsername] = $arMaintainer; $arMaintainers[$strUsername]['packages'] = 0; $arMaintainers[$strUsername]['docced'] = 0; $arMaintainers[$strUsername]['packagelist'] = array(); } ++$arMaintainers[$strUsername]['packages']; $arMaintainers[$strUsername]['packagelist'][$strPackageName] = &$arPackage; if ($arPackage['*docid*'] !== null) { ++$arMaintainers[$strUsername]['docced']; } } } } return $arMaintainers; }//public static function getMaintainers($arDoc) /** * Reads the package maintainers from a package.xml (v1 and v2) * file. * * @param string $strPackageXmlPath Path to a package.xml file * @return array Array with maintainers of following structure: * [username] => array( * [name] => Real name * [email] => Email address * ) */ public static function getPackageMaintainers($strPackageXmlPath) { if (!file_exists($strPackageXmlPath)) { throw new Exception('File does not exist: ' . $strPackageXmlPath); } $doc = new DOMDocument(); if (!@$doc->load($strPackageXmlPath)) { // echo "BAD: " . $strPackageXmlPath . "\n"; return array(); throw new Exception('Package xml is broken: ' . $strPackageXmlPath); } $xpath = new DOMXPath($doc); $arMaintainers = array(); $pack = $doc->getElementsByTagName('package')->item(0); $strVersion = $pack->getAttribute('version'); if ($strVersion == '') { $strVersion = '1.0'; } if ($strVersion != '1.0' && $strVersion != '2.0') { throw new Exception('Unsupported package.xml version ' . $strVersion . ' in ' . $strPackageXmlPath); } if ($strVersion == '1.0') { //get maintainers $maintainers = $xpath->query('/package/maintainers/maintainer'); foreach ($maintainers as $maintainer) { $strUsername = $maintainer->getElementsByTagName('user')->item(0)->textContent; $strRealname = $maintainer->getElementsByTagName('name')->item(0)->textContent; $strEmail = $maintainer->getElementsByTagName('email')->item(0)->textContent; $arMaintainers[$strUsername] = array( 'username' => $strUsername, 'name' => $strRealname, 'email' => $strEmail ); } } else { //v2 $maintainers = $pack->getElementsByTagName('lead'); foreach ($maintainers as $maintainer) { if ($maintainer->getElementsByTagName('active')->item(0)->textContent != 'yes') { continue; } $strUsername = $maintainer->getElementsByTagName('user')->item(0)->textContent; $strRealname = $maintainer->getElementsByTagName('name')->item(0)->textContent; $strEmail = $maintainer->getElementsByTagName('email')->item(0)->textContent; $arMaintainers[$strUsername] = array( 'username' => $strUsername, 'name' => $strRealname, 'email' => $strEmail ); } $maintainers = $pack->getElementsByTagName('developer'); foreach ($maintainers as $maintainer) { if ($maintainer->getElementsByTagName('active')->item(0)->textContent != 'yes') { continue; } $strUsername = $maintainer->getElementsByTagName('user')->item(0)->textContent; $strRealname = $maintainer->getElementsByTagName('name')->item(0)->textContent; $strEmail = $maintainer->getElementsByTagName('email')->item(0)->textContent; $arMaintainers[$strUsername] = array( 'username' => $strUsername, 'name' => $strRealname, 'email' => $strEmail ); } } return $arMaintainers; }//public static function getPackageMaintainers($strPackageXmlPath) public static function compareMaintainers($m1, $m2) { $v1 = $m1['docced'] / $m1['packages']; $v2 = $m2['docced'] / $m2['packages']; if ($v1 == $v2) { return strcasecmp($m1['username'], $m2['username']); } return ($v1 > $v2) ? -1 : 1; }//public static function compareMaintainers($m1, $m2) }//class QA_Peardoc_Coverage_Renderer_DeveloperList implements QA_Peardoc_Coverage_Renderer ?> http://cvs.php.net/viewvc.cgi/pear/QA_Peardoc_Coverage/QA/Peardoc/Coverage/Renderer/ExtendetPackageList.php?view=markup&rev=1.1 Index: pear/QA_Peardoc_Coverage/QA/Peardoc/Coverage/Renderer/ExtendetPackageList.php +++ pear/QA_Peardoc_Coverage/QA/Peardoc/Coverage/Renderer/ExtendetPackageList.php <?php require_once 'QA/Peardoc/Coverage/Renderer.php'; require_once 'HTML/Table.php'; /** * Renders the coverage result in an extendet * list of packages with its documented state, * and the classes with their methods. * * @author Christian Weiske <cweisek@php.net> */ class QA_Peardoc_Coverage_Renderer_ExtendetPackageList implements QA_Peardoc_Coverage_Renderer { public static $colNotDocumented = '#F00'; public static $colDocumented = '#0F0'; public static $colMethodDocumented = '#9F9'; public static $colMethodNotDocumented = '#F99'; public static $colMethodPartlyDocumented= '#FF9'; /** * Returns the color code matching the number. * * @param float $flNumber Number (x/y), !no! percentage * @return string HTML color #0AF */ public static function getColor($flNumber) { if ($flNumber == 1) { return '#0F0'; } else if ($flNumber >= 0.9) { return '#dfff00'; } else if ($flNumber >= 0.5) { return '#FF0'; } else if ($flNumber >= 0.3) { return '#F70'; } else { return '#F00'; } }//public static function getColor($flNumber) /** * Returns the manual url (deep link) for * the given documentation id. * * @param string $strDocId Documentation id="" * @return string URL to the manual */ public static function getDocUrl($strDocId) { return 'http://pear.php.net/manual/en/' . $strDocId . '.php'; }//public static function getDocUrl($strDocId) /** * Renders the given coverage array and * returns the HTML. */ public function render($arDoc) { $n = "\n"; $out = ''; $out .= '<?xml version="1.0" encoding="utf-8" ?>' . $n . '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ' . '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'; $out .= '<html><head><title>Extendet PEAR Documentation coverage analysis</title>' . '<style type="text/css">th { background-color: black; color: white; }' . 'td.class { font-weight:bold;}' . '</style></head><body>'; $out .= '<table border="1"><caption>' . 'Extendet PEAR Documentation coverage analysis as of ' . date('Y-m-d H:i:s') . '</caption>' . $n; $nPackages = 0; $nDoccedPackages = 0; $nCategories = 0; //Package name|Class name|methods|number/percent foreach ($arDoc as $strCategory => $arCategoryPackages) { $out .= '<tr><th colspan="3">' . ucfirst($strCategory) . '</th></tr>' . $n; ++$nCategories; $nCategoryPackages = 0; $nCategoryDoccedPackages = 0; foreach ($arCategoryPackages as $strPackageName => $arPackageCoverage) { ++$nCategoryPackages; ++$nPackages; $out .= '<tr><td colspan="2">' . '<a href="http://pear.php.net/package/' . $strPackageName . '">' . $strPackageName . '</a>' . '</td>'; if ($arPackageCoverage['*docid*'] === null) { //not documented $out .= '<td style="background-color:' . self::$colNotDocumented . '">not documented</td></tr>' . $n; } else { //documented ++$nDoccedPackages; ++$nCategoryDoccedPackages; $out .= '<td style="background-color:' . self::$colDocumented . '"><a href="' . self::getDocUrl($arPackageCoverage['*docid*']) . '">documented</a></td></tr>' . $n; $out .= self::getMethodDocState($arPackageCoverage); } }//foreach package in category /* $col = self::getColor($nCategoryDoccedPackages/$nCategoryPackages); $out .= '<tr>' . '<td>' . $nCategoryPackages . '</td>' . '<td style="text-align:right; font-weight:bold; background-color:' . $col . '">' . $nCategoryDoccedPackages . '/' . $nCategoryPackages . '</td>' . '</tr>' . $n; */ }//foreach category $col = self::getColor($nDoccedPackages/$nPackages); $out .= '<tr style="font-weight:bold; background-color:' . $col . '">' . '<td rowspan="2">' . $nCategories . ' categories</td>' . '<td style="text-align:right;">Packages documented: ' . $nDoccedPackages . '/' . $nPackages . '</td>' . '</tr>' . $n; $out .= '<tr style="font-weight:bold; background-color:' . $col . '">' . '<td style="text-align:right;">' . number_format($nDoccedPackages/$nPackages * 100, 2) . '%</td>' . '</tr>' . $n; $out .= '</table>'; $out .= '</body></html>'; return $out; }//public function render($arDoc) /** * Generates the class/method coverage html * * @return string class and method coverage HTML */ public static function getMethodDocState($arPackageCoverage) { $n = "\n"; $out = ''; $nClasses = 0; $nClassesDocced = 0; foreach ($arPackageCoverage as $strClass => $arMethods) { if ($strClass[0] == '*') { continue; } ++$nClasses; if ($arMethods === null) { //FIXME: display not docced $out .= '<tr><td></td><td class="class">' . $strClass . '</td><td style="background-color:' . self::$colMethodNotDocumented . '">poor</td></tr>' . $n; continue; } $nMethods = 0; $nMethodsDocced = 0; $strDocced = ''; $strNotDocced = ''; foreach ($arMethods as $strMethod => $bDocumented) { if ($strMethod[0] == '_') { continue; } ++$nMethods; if ($bDocumented) { ++$nMethodsDocced; $strDocced .= $strMethod . ', '; } else { $strNotDocced .= $strMethod . ', '; } } //class $mout = ''; if ($nMethods > 0 && $nMethods != $nMethodsDocced) { if ($nMethodsDocced > 0) { //docced $mout .= '<tr><td></td>' . '<td style="background-color:' . self::$colMethodDocumented . '">' . $strDocced . '</td>' . '<td>' . $nMethodsDocced . '</td></tr>' . $n; } //undocced $mout .= '<tr><td></td>' . '<td style="background-color:' . self::$colMethodNotDocumented . '">' . $strNotDocced . '</td>' . '<td>' . ($nMethods - $nMethodsDocced) . '</td></tr>' . $n; } if ($nMethods == $nMethodsDocced) { $strState = 'perfect'; $col = self::$colMethodDocumented; } else if ($nMethodsDocced == 0) { $strState = 'poor'; $col = self::$colMethodNotDocumented; } else { $strState = 'partly'; $col = self::$colMethodPartlyDocumented; } $out .= '<tr><td></td>' . '<td class="class">' . $strClass . '</td>' . '<td style="background-color:' . $col . '">' . $strState . '</td></tr>' . $n; $out .= $mout; } return $out; }//public static function getMethodDocState($arPackageCoverage) }//class QA_Peardoc_Coverage_Renderer_ExtendetPackageList implements QA_Peardoc_Coverage_Renderer ?> http://cvs.php.net/viewvc.cgi/pear/QA_Peardoc_Coverage/QA/Peardoc/Coverage/Renderer/MissingDocsPerDeveloper.php?view=markup&rev=1.1 Index: pear/QA_Peardoc_Coverage/QA/Peardoc/Coverage/Renderer/MissingDocsPerDeveloper.php +++ pear/QA_Peardoc_Coverage/QA/Peardoc/Coverage/Renderer/MissingDocsPerDeveloper.php <?php require_once 'QA/Peardoc/Coverage/Renderer.php'; require_once 'QA/Peardoc/Coverage/Renderer/DeveloperList.php'; require_once 'HTML/Table.php'; /** * Creates the serialized output of an array * containing the email address of a developer * and his undocumented packages. * * array( * email => array(package1, package2), * email2 => array(package1, package2), * ) * * @author Christian Weiske <cweisek@php.net> */ class QA_Peardoc_Coverage_Renderer_MissingDocsPerDeveloper implements QA_Peardoc_Coverage_Renderer { /** * Renders the given coverage array and * returns the HTML. */ public function render($arDoc) { $arMaintainers = QA_Peardoc_Coverage_Renderer_DeveloperList::getMaintainers($arDoc); $arList = array(); foreach ($arMaintainers as $strUsername => $arMaintainer) { $strEmail = $arMaintainer['email']; $arUndocumented = array(); if ($arMaintainer['docced'] != $arMaintainer['packages']) { foreach ($arMaintainer['packagelist'] as $strPackageName => $arPackage) { if ($arPackage['*docid*'] === null) { $arUndocumented[] = $strPackageName; } } } if (count($arUndocumented) > 0) { $arList[$strEmail] = $arUndocumented; } } ksort($arList); return serialize($arList); }//public function render($arDoc) }//class QA_Peardoc_Coverage_Renderer_MissingDocsPerDeveloper implements QA_Peardoc_Coverage_Renderer ?> http://cvs.php.net/viewvc.cgi/pear/QA_Peardoc_Coverage/QA/Peardoc/Coverage/Renderer/SimplePackageList.php?view=markup&rev=1.1 Index: pear/QA_Peardoc_Coverage/QA/Peardoc/Coverage/Renderer/SimplePackageList.php +++ pear/QA_Peardoc_Coverage/QA/Peardoc/Coverage/Renderer/SimplePackageList.php <?php require_once 'QA/Peardoc/Coverage/Renderer.php'; require_once 'HTML/Table.php'; /** * Renders the coverage result in a simple * list of packages with their documentation state. * * @author Christian Weiske <cweisek@php.net> */ class QA_Peardoc_Coverage_Renderer_SimplePackageList implements QA_Peardoc_Coverage_Renderer { public static $colNotDocumented = '#F00'; public static $colDocumented = '#0F0'; /** * Returns the color code matching the number. * * @param float $flNumber Number (x/y), !no! percentage * @return string HTML color #0AF */ public static function getColor($flNumber) { if ($flNumber == 1) { return '#0F0'; } else if ($flNumber >= 0.9) { return '#dfff00'; } else if ($flNumber >= 0.5) { return '#FF0'; } else if ($flNumber >= 0.3) { return '#F70'; } else { return '#F00'; } }//public static function getColor($flNumber) /** * Returns the manual url (deep link) for * the given documentation id. * * @param string $strDocId Documentation id="" * @return string URL to the manual */ public static function getDocUrl($strDocId) { return 'http://pear.php.net/manual/en/' . $strDocId . '.php'; }//public static function getDocUrl($strDocId) /** * Renders the given coverage array and * returns the HTML. */ public function render($arDoc) { $n = "\n"; $out = ''; $out .= '<?xml version="1.0" encoding="utf-8" ?>' . $n . '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ' . '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'; $out .= '<html><head><title>Simple PEAR Documentation coverage analysis</title></head><body>'; $out .= '<table border="1"><caption>' . 'Simple PEAR Documentation coverage analysis as of ' . date('Y-m-d H:i:s') . '</caption>' . $n; $nPackages = 0; $nDoccedPackages = 0; $nCategories = 0; foreach ($arDoc as $strCategory => $arCategoryPackages) { $out .= '<tr><th colspan="3">' . ucfirst($strCategory) . '</th></tr>' . $n; ++$nCategories; $nCategoryPackages = 0; $nCategoryDoccedPackages = 0; foreach ($arCategoryPackages as $strPackageName => $arPackageCoverage) { ++$nCategoryPackages; ++$nPackages; $out .= '<tr><td></td><td>' . '<a href="http://pear.php.net/package/' . $strPackageName . '">' . $strPackageName . '</a>' . '</td>'; if ($arPackageCoverage['*docid*'] === null) { //not documented $out .= '<td style="background-color:' . self::$colNotDocumented . '">not documented</td>'; } else { //documented ++$nDoccedPackages; ++$nCategoryDoccedPackages; $out .= '<td style="background-color:' . self::$colDocumented . '"><a href="' . self::getDocUrl($arPackageCoverage['*docid*']) . '">documented</a></td>'; } $out .= '</tr>' . $n; }//foreach package in category $col = self::getColor($nCategoryDoccedPackages/$nCategoryPackages); $out .= '<tr>' . '<td>Sum</td>' . '<td>' . $nCategoryPackages . '</td>' . '<td style="text-align:right; font-weight:bold; background-color:' . $col . '">' . $nCategoryDoccedPackages . '/' . $nCategoryPackages . '</td>' . '</tr>' . $n; }//foreach category $col = self::getColor($nDoccedPackages/$nPackages); $out .= '<tr style="font-weight:bold; background-color:' . $col . '">' . '<td rowspan="2">All in all</td>' . '<td rowspan="2">' . $nCategories . ' categories</td>' . '<td style="text-align:right;">' . $nDoccedPackages . '/' . $nPackages . '</td>' . '</tr>' . $n; $out .= '<tr style="font-weight:bold; background-color:' . $col . '">' . '<td style="text-align:right;">' . number_format($nDoccedPackages/$nPackages * 100, 2) . '%</td>' . '</tr>' . $n; $out .= '</table>'; $out .= '</body></html>'; return $out; }//public function render($arDoc) }//class QA_Peardoc_Coverage_Renderer_SimplePackageList implements QA_Peardoc_Coverage_Renderer ?> http://cvs.php.net/viewvc.cgi/pear/QA_Peardoc_Coverage/examples/displayMissing.php?view=markup&rev=1.1 Index: pear/QA_Peardoc_Coverage/examples/displayMissing.php +++ pear/QA_Peardoc_Coverage/examples/displayMissing.php <?php /** * Displays the packages per email on the console */ $ar = unserialize(file_get_contents('missingdocs.serialized')); foreach ($ar as $strEmail => $arPackages) { echo $strEmail . "\n"; echo ' ' . implode(', ', $arPackages) . "\n"; } ?> http://cvs.php.net/viewvc.cgi/pear/QA_Peardoc_Coverage/examples/genData.php?view=markup&rev=1.1 Index: pear/QA_Peardoc_Coverage/examples/genData.php +++ pear/QA_Peardoc_Coverage/examples/genData.php <?php require_once 'QA/Peardoc/Coverage.php'; if ($argc < 3) { echo <<<EOD Generates PEAR documentation coverage data. Usage: php genData.php path/to/peardoc/manual.xml path/to/pearcvs/ EOD; exit(1); } //$strManualPath = dirname(__FILE__) . '/../peardoc/manual.xml'; //$strPearDir = dirname(__FILE__) . '/../pear/'; $strManualPath = $argv[1]; $strPearDir = $argv[2]; $pdc = new QA_Peardoc_Coverage($strManualPath, $strPearDir); file_put_contents( 'doc.dat', serialize( $pdc->generateCoverage() ) ); ?> http://cvs.php.net/viewvc.cgi/pear/QA_Peardoc_Coverage/examples/genDeveloperStats.php?view=markup&rev=1.1 Index: pear/QA_Peardoc_Coverage/examples/genDeveloperStats.php +++ pear/QA_Peardoc_Coverage/examples/genDeveloperStats.php <?php require_once 'QA/Peardoc/Coverage.php'; if ($argc < 3) { echo <<<EOD Generates PEAR documentation coverage by developer. Usage: php genDeveloperStats.php path/to/peardoc/manual.xml path/to/pearcvs/ EOD; exit(1); } $strManualPath = $argv[1]; $strPearDir = $argv[2]; $pdc = new QA_Peardoc_Coverage($strManualPath, $strPearDir); echo QA_Peardoc_Coverage::renderCoverage( unserialize(file_get_contents('doc.dat')), 'QA_Peardoc_Coverage_Renderer_DeveloperList' ); ?> http://cvs.php.net/viewvc.cgi/pear/QA_Peardoc_Coverage/examples/genExtendetStats.php?view=markup&rev=1.1 Index: pear/QA_Peardoc_Coverage/examples/genExtendetStats.php +++ pear/QA_Peardoc_Coverage/examples/genExtendetStats.php <?php require_once 'QA/Peardoc/Coverage.php'; if ($argc < 3) { echo <<<EOD Generates an extendet PEAR documentation coverage. Usage: php genExtendetStats.php path/to/peardoc/manual.xml path/to/pearcvs/ EOD; exit(1); } $strManualPath = $argv[1]; $strPearDir = $argv[2]; $pdc = new QA_Peardoc_Coverage($strManualPath, $strPearDir); echo QA_Peardoc_Coverage::renderCoverage( unserialize(file_get_contents('doc.dat')), 'QA_Peardoc_Coverage_Renderer_ExtendetPackageList' ); ?> http://cvs.php.net/viewvc.cgi/pear/QA_Peardoc_Coverage/examples/genMissingDocsPerDeveloper.php?view=markup&rev=1.1 Index: pear/QA_Peardoc_Coverage/examples/genMissingDocsPerDeveloper.php +++ pear/QA_Peardoc_Coverage/examples/genMissingDocsPerDeveloper.php <?php require_once 'QA/Peardoc/Coverage.php'; if ($argc < 3) { echo <<<EOD Generates serialized array with developer email and package names missing documentation. Usage: php genMissingDocsPerDeveloper.php path/to/peardoc/manual.xml path/to/pearcvs/ EOD; exit(1); } $strManualPath = $argv[1]; $strPearDir = $argv[2]; $pdc = new QA_Peardoc_Coverage($strManualPath, $strPearDir); echo QA_Peardoc_Coverage::renderCoverage( unserialize(file_get_contents('doc.dat')), 'QA_Peardoc_Coverage_Renderer_MissingDocsPerDeveloper' ); ?> http://cvs.php.net/viewvc.cgi/pear/QA_Peardoc_Coverage/examples/genSimpleStats.php?view=markup&rev=1.1 Index: pear/QA_Peardoc_Coverage/examples/genSimpleStats.php +++ pear/QA_Peardoc_Coverage/examples/genSimpleStats.php <?php require_once 'QA/Peardoc/Coverage.php'; if ($argc < 3) { echo <<<EOD Generates a simple PEAR documentation coverage. Usage: php genSimpleStats.php path/to/peardoc/manual.xml path/to/pearcvs/ EOD; exit(1); } $strManualPath = $argv[1]; $strPearDir = $argv[2]; $pdc = new QA_Peardoc_Coverage($strManualPath, $strPearDir); echo QA_Peardoc_Coverage::renderCoverage( unserialize(file_get_contents('doc.dat')) ); ?> http://cvs.php.net/viewvc.cgi/pear/QA_Peardoc_Coverage/examples/gtk2VardumpData.php?view=markup&rev=1.1 Index: pear/QA_Peardoc_Coverage/examples/gtk2VardumpData.php +++ pear/QA_Peardoc_Coverage/examples/gtk2VardumpData.php <?php /** * displays the generated data with Gtk2_VarDump */ require_once 'Gtk2/VarDump.php'; Gtk2_VarDump::display( unserialize( file_get_contents('doc.dat') ), 'PEAR documentation coverage data' ); ?> http://cvs.php.net/viewvc.cgi/pear/QA_Peardoc_Coverage/tests/QA_Peardoc_CoverageTest.php?view=markup&rev=1.1 Index: pear/QA_Peardoc_Coverage/tests/QA_Peardoc_CoverageTest.php +++ pear/QA_Peardoc_Coverage/tests/QA_Peardoc_CoverageTest.php <?php // Call QA_Peardoc_CoverageTest::main() if this source file is executed directly. if (!defined("PHPUnit2_MAIN_METHOD")) { define("PHPUnit2_MAIN_METHOD", "QA_Peardoc_CoverageTest::main"); } require_once "PHPUnit2/Framework/TestCase.php"; require_once "PHPUnit2/Framework/TestSuite.php"; // You may remove the following line when all tests have been implemented. require_once "PHPUnit2/Framework/IncompleteTestError.php"; require_once "QA/Peardoc/Coverage.php"; require_once dirname(__FILE__) . '/config.php'; /** * Test class for QA_Peardoc_Coverage. * Generated by PHPUnit2_Util_Skeleton on 2006-10-18 at 12:28:36. */ class QA_Peardoc_CoverageTest extends PHPUnit2_Framework_TestCase { /** * Runs the test methods of this class. * * @access public * @static */ public static function main() { require_once "PHPUnit2/TextUI/TestRunner.php"; $suite = new PHPUnit2_Framework_TestSuite("QA_Peardoc_CoverageTest"); $result = PHPUnit2_TextUI_TestRunner::run($suite); } /** * Sets up the fixture, for example, open a network connection. * This method is called before a test is executed. * * @access protected */ protected function setUp() { $this->strPearDir = $GLOBALS['testConfig']['PearDir']; $this->assertTrue(file_exists($this->strPearDir)); $this->assertTrue(is_dir($this->strPearDir)); } /** * Tears down the fixture, for example, close a network connection. * This method is called after a test is executed. * * @access protected */ protected function tearDown() { } /** * @todo Implement testGenerateCoverage(). */ public function testGenerateCoverage() { // Remove the following line when you implement this test. throw new PHPUnit2_Framework_IncompleteTestError; } /** * @todo Implement testRenderCoverage(). */ public function testRenderCoverage() { // Remove the following line when you implement this test. throw new PHPUnit2_Framework_IncompleteTestError; } /** * @todo Implement testGetPackageList(). */ public function testGetPackageList() { $ar = QA_Peardoc_Coverage::getPackageList($this->strPearDir); $this->assertTrue(in_array('Auth' , $ar)); $this->assertTrue(in_array('LiveUser' , $ar)); $this->assertTrue(in_array('System_Folders' , $ar)); $this->assertTrue(in_array('Selenium' , $ar)); $this->assertTrue(in_array('XML_RPC' , $ar)); } /** * @todo Implement testGetCategory(). */ public function testGetCategory() { $this->assertEquals(array('authentication'), QA_Peardoc_Coverage::getCategory('Auth') ); $this->assertEquals(array('database'), QA_Peardoc_Coverage::getCategory('MDB') ); $this->assertEquals(array('php'), QA_Peardoc_Coverage::getCategory('PHP_Archive') ); $this->assertEquals(array('testing'), QA_Peardoc_Coverage::getCategory('Selenium') ); } /** * @todo Implement testGetPackageDocId(). */ public function testGetPackageDocId() { // Remove the following line when you implement this test. throw new PHPUnit2_Framework_IncompleteTestError; } /** * @todo Implement testExistsId(). */ public function testExistsId() { // Remove the following line when you implement this test. throw new PHPUnit2_Framework_IncompleteTestError; } /** * @todo Implement testGetPackageCoverage(). */ public function testGetPackageCoverage() { // Remove the following line when you implement this test. throw new PHPUnit2_Framework_IncompleteTestError; } } // Call QA_Peardoc_CoverageTest::main() if this source file is executed directly. if (PHPUnit2_MAIN_METHOD == "QA_Peardoc_CoverageTest::main") { QA_Peardoc_CoverageTest::main(); } ?> http://cvs.php.net/viewvc.cgi/pear/QA_Peardoc_Coverage/tests/QA_Peardoc_Coverage_ClassListTest.php?view=markup&rev=1.1 Index: pear/QA_Peardoc_Coverage/tests/QA_Peardoc_Coverage_ClassListTest.php +++ pear/QA_Peardoc_Coverage/tests/QA_Peardoc_Coverage_ClassListTest.php <?php // Call QA_Peardoc_Coverage_ClassListTest::main() if this source file is executed directly. if (!defined("PHPUnit2_MAIN_METHOD")) { define("PHPUnit2_MAIN_METHOD", "QA_Peardoc_Coverage_ClassListTest::main"); } require_once "PHPUnit2/Framework/TestCase.php"; require_once "PHPUnit2/Framework/TestSuite.php"; // You may remove the following line when all tests have been implemented. require_once "PHPUnit2/Framework/IncompleteTestError.php"; require_once "QA/Peardoc/Coverage/ClassList.php"; require_once dirname(__FILE__) . '/config.php'; /** * Test class for QA_Peardoc_Coverage_ClassList. * Generated by PHPUnit2_Util_Skeleton on 2006-10-18 at 12:28:36. */ class QA_Peardoc_Coverage_ClassListTest extends PHPUnit2_Framework_TestCase { /** * Runs the test methods of this class. * * @access public * @static */ public static function main() { require_once "PHPUnit2/TextUI/TestRunner.php"; $suite = new PHPUnit2_Framework_TestSuite("QA_Peardoc_Coverage_ClassListTest"); $result = PHPUnit2_TextUI_TestRunner::run($suite); } /** * Sets up the fixture, for example, open a network connection. * This method is called before a test is executed. * * @access protected */ protected function setUp() { $this->strPearDir = $GLOBALS['testConfig']['PearDir']; $this->assertTrue(file_exists($this->strPearDir)); $this->assertTrue(is_dir($this->strPearDir)); } /** * Tears down the fixture, for example, close a network connection. * This method is called after a test is executed. * * @access protected */ protected function tearDown() { } public function testAuth() { $strAuthDir = $this->strPearDir . '/Auth'; $this->assertTrue(file_exists($strAuthDir)); $ar = QA_Peardoc_Coverage_ClassList::getClassList($strAuthDir, false); $this->assertNotEquals(0, count($ar)); $this->assertTrue(in_array('Auth.php', $ar)); $this->assertTrue(in_array('Auth/Auth.php', $ar)); $this->assertTrue(in_array('Container/Array.php', $ar)); $this->assertFalse(in_array('tests/DBContainer.php', $ar)); }//public function testAuth() } // Call QA_Peardoc_Coverage_ClassListTest::main() if this source file is executed directly. if (PHPUnit2_MAIN_METHOD == "QA_Peardoc_Coverage_ClassListTest::main") { QA_Peardoc_Coverage_ClassListTest::main(); } ?> http://cvs.php.net/viewvc.cgi/pear/QA_Peardoc_Coverage/tests/QA_Peardoc_Coverage_MethodListTest.php?view=markup&rev=1.1 Index: pear/QA_Peardoc_Coverage/tests/QA_Peardoc_Coverage_MethodListTest.php +++ pear/QA_Peardoc_Coverage/tests/QA_Peardoc_Coverage_MethodListTest.php <?php // Call QA_Peardoc_Coverage_MethodListTest::main() if this source file is executed directly. if (!defined("PHPUnit2_MAIN_METHOD")) { define("PHPUnit2_MAIN_METHOD", "QA_Peardoc_Coverage_MethodListTest::main"); } require_once "PHPUnit2/Framework/TestCase.php"; require_once "PHPUnit2/Framework/TestSuite.php"; // You may remove the following line when all tests have been implemented. require_once "PHPUnit2/Framework/IncompleteTestError.php"; require_once "QA/Peardoc/Coverage/MethodList.php"; /** * Test class for QA_Peardoc_Coverage_MethodList. * Generated by PHPUnit2_Util_Skeleton on 2006-10-18 at 12:28:36. */ class QA_Peardoc_Coverage_MethodListTest extends PHPUnit2_Framework_TestCase { /** * Runs the test methods of this class. * * @access public * @static */ public static function main() { require_once "PHPUnit2/TextUI/TestRunner.php"; $suite = new PHPUnit2_Framework_TestSuite("QA_Peardoc_Coverage_MethodListTest"); $result = PHPUnit2_TextUI_TestRunner::run($suite); } /** * Sets up the fixture, for example, open a network connection. * This method is called before a test is executed. * * @access protected */ protected function setUp() { } /** * Tears down the fixture, for example, close a network connection. * This method is called after a test is executed. * * @access protected */ protected function tearDown() { } /** * @todo Implement testGetMethods(). */ public function testGetMethods() { // Remove the following line when you implement this test. throw new PHPUnit2_Framework_IncompleteTestError; } /** * @todo Implement testGetClassnameFromFilename(). */ public function testGetClassnameFromFilename() { // Remove the following line when you implement this test. throw new PHPUnit2_Framework_IncompleteTestError; } } // Call QA_Peardoc_Coverage_MethodListTest::main() if this source file is executed directly. if (PHPUnit2_MAIN_METHOD == "QA_Peardoc_Coverage_MethodListTest::main") { QA_Peardoc_Coverage_MethodListTest::main(); } ?> http://cvs.php.net/viewvc.cgi/pear/QA_Peardoc_Coverage/tests/QA_Peardoc_Coverage_Renderer_DeveloperListTest.php?view=markup&rev=1.1 Index: pear/QA_Peardoc_Coverage/tests/QA_Peardoc_Coverage_Renderer_DeveloperListTest.php +++ pear/QA_Peardoc_Coverage/tests/QA_Peardoc_Coverage_Renderer_DeveloperListTest.php <?php // Call QA_Peardoc_Coverage_Renderer_DeveloperListTest::main() if this source file is executed directly. if (!defined("PHPUnit2_MAIN_METHOD")) { define("PHPUnit2_MAIN_METHOD", "QA_Peardoc_Coverage_Renderer_DeveloperListTest::main"); } require_once "PHPUnit2/Framework/TestCase.php"; require_once "PHPUnit2/Framework/TestSuite.php"; // You may remove the following line when all tests have been implemented. require_once "PHPUnit2/Framework/IncompleteTestError.php"; require_once "QA/Peardoc/Coverage/Renderer/DeveloperList.php"; require_once dirname(__FILE__) . '/config.php'; /** * Test class for QA_Peardoc_Coverage_Renderer_DeveloperList. * Generated by PHPUnit2_Util_Skeleton on 2006-10-19 at 11:41:33. */ class QA_Peardoc_Coverage_Renderer_DeveloperListTest extends PHPUnit2_Framework_TestCase { /** * Runs the test methods of this class. * * @access public * @static */ public static function main() { require_once "PHPUnit2/TextUI/TestRunner.php"; $suite = new PHPUnit2_Framework_TestSuite("QA_Peardoc_Coverage_Renderer_DeveloperListTest"); $result = PHPUnit2_TextUI_TestRunner::run($suite); } /** * Sets up the fixture, for example, open a network connection. * This method is called before a test is executed. * * @access protected */ protected function setUp() { $this->strPearDir = $GLOBALS['testConfig']['PearDir']; $this->assertTrue(file_exists($this->strPearDir)); $this->assertTrue(is_dir($this->strPearDir)); } /** * Tears down the fixture, for example, close a network connection. * This method is called after a test is executed. * * @access protected */ protected function tearDown() { } /** * @todo Implement testRender(). */ public function testRender() { // Remove the following line when you implement this test. // throw new PHPUnit2_Framework_IncompleteTestError; } /** * */ public function testGetMaintainers() { $this->assertTrue(file_exists('doc.dat')); $ar = QA_Peardoc_Coverage_Renderer_DeveloperList::getMaintainers( unserialize( file_get_contents('doc.dat') ) ); $this->assertTrue(isset($ar['cweiske'])); $this->assertTrue(10 <= count($ar['cweiske']['packagelist'])); $this->assertTrue(5 <= $ar['cweiske']['docced']); $this->assertTrue(10 <= $ar['cweiske']['packages']); $this->assertEquals( count($ar['cweiske']['packagelist']), $ar['cweiske']['packages'] ); $this->assertTrue( count($ar['cweiske']['packagelist']) >= $ar['cweiske']['docced'] ); } /** * */ public function testGetPackageMaintainers() { //test package.xml v1 $ar = QA_Peardoc_Coverage_Renderer_DeveloperList::getPackageMaintainers( $this->strPearDir . '/File/package.xml' ); $this->assertEquals(5, count($ar)); $this->assertTrue(isset($ar['richard'])); $this->assertTrue(isset($ar['tal'])); $this->assertTrue(isset($ar['dufuz'])); //no version info $ar = QA_Peardoc_Coverage_Renderer_DeveloperList::getPackageMaintainers( $this->strPearDir . '/DBA/package.xml' ); $this->assertEquals(1, count($ar)); //test package.xml v2 $ar = QA_Peardoc_Coverage_Renderer_DeveloperList::getPackageMaintainers( $this->strPearDir . '/Auth/package2.xml' ); $this->assertEquals(1, count($ar)); } } // Call QA_Peardoc_Coverage_Renderer_DeveloperListTest::main() if this source file is executed directly. if (PHPUnit2_MAIN_METHOD == "QA_Peardoc_Coverage_Renderer_DeveloperListTest::main") { QA_Peardoc_Coverage_Renderer_DeveloperListTest::main(); } ?> http://cvs.php.net/viewvc.cgi/pear/QA_Peardoc_Coverage/tests/QA_Peardoc_Coverage_Renderer_SimpleClassListTest.php?view=markup&rev=1.1 Index: pear/QA_Peardoc_Coverage/tests/QA_Peardoc_Coverage_Renderer_SimpleClassListTest.php +++ pear/QA_Peardoc_Coverage/tests/QA_Peardoc_Coverage_Renderer_SimpleClassListTest.php <?php // Call QA_Peardoc_Coverage_Renderer_SimpleClassListTest::main() if this source file is executed directly. if (!defined("PHPUnit2_MAIN_METHOD")) { define("PHPUnit2_MAIN_METHOD", "QA_Peardoc_Coverage_Renderer_SimpleClassListTest::main"); } require_once "PHPUnit2/Framework/TestCase.php"; require_once "PHPUnit2/Framework/TestSuite.php"; // You may remove the following line when all tests have been implemented. require_once "PHPUnit2/Framework/IncompleteTestError.php"; require_once "QA/Peardoc/Coverage/Renderer/SimpleClassList.php"; /** * Test class for QA_Peardoc_Coverage_Renderer_SimpleClassList. * Generated by PHPUnit2_Util_Skeleton on 2006-10-18 at 12:28:36. */ class QA_Peardoc_Coverage_Renderer_SimpleClassListTest extends PHPUnit2_Framework_TestCase { /** * Runs the test methods of this class. * * @access public * @static */ public static function main() { require_once "PHPUnit2/TextUI/TestRunner.php"; $suite = new PHPUnit2_Framework_TestSuite("QA_Peardoc_Coverage_Renderer_SimpleClassListTest"); $result = PHPUnit2_TextUI_TestRunner::run($suite); } /** * Sets up the fixture, for example, open a network connection. * This method is called before a test is executed. * * @access protected */ protected function setUp() { } /** * Tears down the fixture, for example, close a network connection. * This method is called after a test is executed. * * @access protected */ protected function tearDown() { } /** * @todo Implement testRender(). */ public function testRender() { // Remove the following line when you implement this test. throw new PHPUnit2_Framework_IncompleteTestError; } } // Call QA_Peardoc_Coverage_Renderer_SimpleClassListTest::main() if this source file is executed directly. if (PHPUnit2_MAIN_METHOD == "QA_Peardoc_Coverage_Renderer_SimpleClassListTest::main") { QA_Peardoc_Coverage_Renderer_SimpleClassListTest::main(); } ?> http://cvs.php.net/viewvc.cgi/pear/QA_Peardoc_Coverage/tests/config.php?view=markup&rev=1.1 Index: pear/QA_Peardoc_Coverage/tests/config.php +++ pear/QA_Peardoc_Coverage/tests/config.php <?php $GLOBALS['testConfig'] = array( 'ManualPath' => dirname(__FILE__) . '/../../peardoc/manual.xml', 'PearDir' => dirname(__FILE__) . '/../../pear/', ); ?> http://cvs.php.net/viewvc.cgi/pear/QA_Peardoc_Coverage/tests/maketests.php?view=markup&rev=1.1 Index: pear/QA_Peardoc_Coverage/tests/maketests.php +++ pear/QA_Peardoc_Coverage/tests/maketests.php <?php // Use PHPUnit2 to create the skeletons. require_once 'PHPUnit2/Util/Skeleton.php'; /* require_once 'QA/Peardoc/Coverage.php'; require_once 'QA/Peardoc/Coverage/ClassList.php'; require_once 'QA/Peardoc/Coverage/MethodList.php'; require_once 'QA/Peardoc/Coverage/Renderer/SimpleClassList.php'; */ $classes = array( 'QA_Peardoc_Coverage_Renderer_DeveloperList' /* 'QA_Peardoc_Coverage_Renderer_SimpleClassList', 'QA_Peardoc_Coverage_ClassList', 'QA_Peardoc_Coverage_MethodList', 'QA_Peardoc_Coverage', */ ); foreach ($classes as $class) { // Create a skeleton for the class. $skeleton = new PHPUnit2_Util_Skeleton( $class, str_replace('_', '/', $class) . '.php' ); // Write the test. $skeleton->write(); } ?>
« previous php.pear.cvs (#42821) next »