From a10bea65d6cecc20e9599fc8b0b5d1e786b534f6 Mon Sep 17 00:00:00 2001 From: Greg Sherwood Date: Thu, 20 Dec 2007 21:39:09 +0000 Subject: [PATCH] Patch from Dirk Thomas to get the doc generator working with external standards git-svn-id: http://svn.php.net/repository/pear/packages/PHP_CodeSniffer/trunk@248628 c90b9560-bf6c-de11-be94-00142212c4b1 --- CodeSniffer/DocGenerators/Generator.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/CodeSniffer/DocGenerators/Generator.php b/CodeSniffer/DocGenerators/Generator.php index a2a6809acd..51ba0c6f92 100644 --- a/CodeSniffer/DocGenerators/Generator.php +++ b/CodeSniffer/DocGenerators/Generator.php @@ -132,8 +132,16 @@ public function generate() */ protected function getStandardFiles() { - $standardDir = realpath(dirname(__FILE__).'/../Standards/'.$this->_standard); - $sniffs = PHP_CodeSniffer::getSniffFiles($standardDir, $this->_standard); + if (is_dir($this->_standard) === true) { + // This is a custom standard. + $standardDir = $this->_standard; + $standard = basename($this->_standard); + } else { + $standardDir = realpath(dirname(__FILE__).'/../Standards/'.$this->_standard); + $standard = $this->_standard; + } + + $sniffs = PHP_CodeSniffer::getSniffFiles($standardDir, $standard); $standardFiles = array(); foreach ($sniffs as $sniff) { @@ -147,7 +155,7 @@ protected function getStandardFiles() } } - $standardFile = str_replace('/Sniffs/', '/Docs/', $sniff); + $standardFile = str_replace(DIRECTORY_SEPARATOR.'Sniffs'.DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR.'Docs'.DIRECTORY_SEPARATOR, $sniff); $standardFile = str_replace('Sniff.php', 'Standard.xml', $standardFile); if (is_file($standardFile) === true) {