Skip to content

Commit a10bea6

Browse files
committed
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
1 parent c862026 commit a10bea6

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

CodeSniffer/DocGenerators/Generator.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,16 @@ public function generate()
132132
*/
133133
protected function getStandardFiles()
134134
{
135-
$standardDir = realpath(dirname(__FILE__).'/../Standards/'.$this->_standard);
136-
$sniffs = PHP_CodeSniffer::getSniffFiles($standardDir, $this->_standard);
135+
if (is_dir($this->_standard) === true) {
136+
// This is a custom standard.
137+
$standardDir = $this->_standard;
138+
$standard = basename($this->_standard);
139+
} else {
140+
$standardDir = realpath(dirname(__FILE__).'/../Standards/'.$this->_standard);
141+
$standard = $this->_standard;
142+
}
143+
144+
$sniffs = PHP_CodeSniffer::getSniffFiles($standardDir, $standard);
137145

138146
$standardFiles = array();
139147
foreach ($sniffs as $sniff) {
@@ -147,7 +155,7 @@ protected function getStandardFiles()
147155
}
148156
}
149157

150-
$standardFile = str_replace('/Sniffs/', '/Docs/', $sniff);
158+
$standardFile = str_replace(DIRECTORY_SEPARATOR.'Sniffs'.DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR.'Docs'.DIRECTORY_SEPARATOR, $sniff);
151159
$standardFile = str_replace('Sniff.php', 'Standard.xml', $standardFile);
152160

153161
if (is_file($standardFile) === true) {

0 commit comments

Comments
 (0)