cvs: pear /QA_Peardoc_Coverage/QA/Peardoc Coverage.php /QA_Peardoc_Coverage/tests QA_Peardoc_Coverage_ClassListTest.php

From: Date: Mon, 30 Oct 2006 13:12:21 +0000
Subject: cvs: pear /QA_Peardoc_Coverage/QA/Peardoc Coverage.php /QA_Peardoc_Coverage/tests QA_Peardoc_Coverage_ClassListTest.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-42887@lists.php.net to get a copy of this message
cweiske Mon Oct 30 13:12:21 2006 UTC Modified files: /pear/QA_Peardoc_Coverage/QA/Peardoc Coverage.php /pear/QA_Peardoc_Coverage/tests QA_Peardoc_Coverage_ClassListTest.php Log: - Check for <classname> Tags - Check for <function> Tags http://cvs.php.net/viewvc.cgi/pear/QA_Peardoc_Coverage/QA/Peardoc/Coverage.php?r1=1.1&r2=1.2&diff_format=u Index: pear/QA_Peardoc_Coverage/QA/Peardoc/Coverage.php diff -u pear/QA_Peardoc_Coverage/QA/Peardoc/Coverage.php:1.1 pear/QA_Peardoc_Coverage/QA/Peardoc/Coverage.php:1.2 --- pear/QA_Peardoc_Coverage/QA/Peardoc/Coverage.php:1.1 Thu Oct 26 06:26:12 2006 +++ pear/QA_Peardoc_Coverage/QA/Peardoc/Coverage.php Mon Oct 30 13:12:21 2006 @@ -381,6 +381,15 @@ /** * Creates the documentation coverage for the given package. * + * A class is considered documented if either an ID + * /baseid + "." + classname/ exists, or the classname + * is surrounded by <classname> tags at least once. + * + * Functions/methds are considered as documented if + * they are mentioned inside a <function> tag or + * an id like /baseid + "." + classname + "." + functionname/ + * exists. + * * @param string $strPackage Package name * @param string $strCategory Category (lowercase) * @param string $strBaseId Base documentation id attribute @@ -395,6 +404,13 @@ '*package*' => $strPackageDir ); + $baseElement = $this->doc->getElementById($strBaseId); + //find <classname> elements + $arDocClasses = array(); + foreach ($baseElement->getElementsByTagName('classname') as $classElement) { + $arDocClasses[$classElement->nodeValue] = true; + } + foreach ( QA_Peardoc_Coverage_ClassList::getClassList($strPackageDir) as $strClassFile @@ -409,16 +425,34 @@ //Check if class is documented $strClassDocId = $strBaseId . '.' . strtolower(str_replace('_', '-', $strClassName)); - if (!$this->existsId($strClassDocId)) { + if (!isset($arDocClasses[$strClassName]) && !$this->existsId($strClassDocId)) { //FIXME: if classname is the same as package name -> short version //class is not documented $arDoc[$strClassName] = null; continue; } + $arDocMethods = array(); + foreach ($baseElement->getElementsByTagName('function') as $funcElement) { + $arDocMethods[$funcElement->nodeValue] = true; + } + + //check if methods exist foreach ($arMethods as $strMethod => $bDocBlock) { - $strMethodDocId = $strClassDocId . '.' . strtolower(str_replace('_', '-', $strMethod)); - $arDoc[$strClassName][$strMethod] = $this->existsId($strMethodDocId); + //omit constructors + if ($strMethod == $strClassName || $strMethod == '__construct') { + continue; + } + + if (isset($arDocMethods[$strMethod])) { + //first check if the method is in a <function> tag + $arDoc[$strClassName][$strMethod] = true; + } else { + //then check if the method has its own section + $strMethodDocId = $strClassDocId . '.' . strtolower(str_replace('_', '-', $strMethod)); + + $arDoc[$strClassName][$strMethod] = $this->existsId($strMethodDocId); + } }//foreach method }//foreach class http://cvs.php.net/viewvc.cgi/pear/QA_Peardoc_Coverage/tests/QA_Peardoc_Coverage_ClassListTest.php?r1=1.1&r2=1.2&diff_format=u Index: pear/QA_Peardoc_Coverage/tests/QA_Peardoc_Coverage_ClassListTest.php diff -u pear/QA_Peardoc_Coverage/tests/QA_Peardoc_Coverage_ClassListTest.php:1.1 pear/QA_Peardoc_Coverage/tests/QA_Peardoc_Coverage_ClassListTest.php:1.2 --- pear/QA_Peardoc_Coverage/tests/QA_Peardoc_Coverage_ClassListTest.php:1.1 Thu Oct 26 06:26:12 2006 +++ pear/QA_Peardoc_Coverage/tests/QA_Peardoc_Coverage_ClassListTest.php Mon Oct 30 13:12:21 2006 @@ -67,6 +67,18 @@ $this->assertFalse(in_array('tests/DBContainer.php', $ar)); }//public function testAuth() + + + public function testMDB2() + { + $strMdb2Dir = $this->strPearDir . '/MDB2'; + $this->assertTrue(file_exists($strMdb2Dir)); + $ar = QA_Peardoc_Coverage_ClassList::getClassList($strMdb2Dir, false); + + $this->assertNotEquals(0, count($ar)); + $this->assertTrue(in_array('MDB2.php', $ar)); + } + } // Call QA_Peardoc_Coverage_ClassListTest::main() if this source file is executed directly.

« previous php.pear.cvs (#42887) next »