Index: trunk/extensions/Validator/includes/parserHooks/Validator_Describe.php |
— | — | @@ -110,7 +110,8 @@ |
111 | 111 | false |
112 | 112 | ); |
113 | 113 | |
114 | | - return $output->getText(); |
| 114 | + // This str_replace is a hack to allow for placing <pre>s into <pre>s, without breaking the outer ones. |
| 115 | + return str_replace( 'pre!>', 'pre>', $output->getText() ); |
115 | 116 | } |
116 | 117 | |
117 | 118 | protected function getParserHookDescription( $hookName, array $parameters, ParserHook $parserHook ) { |
— | — | @@ -118,6 +119,11 @@ |
119 | 120 | |
120 | 121 | $description = "<h2> {$hookName} </h2>\n\n"; |
121 | 122 | |
| 123 | + if ( $descriptionData['description'] !== false ) { |
| 124 | + $description .= wfMsgExt( 'validator-describe-descriptionmsg', 'parsemag', $descriptionData['description'] ); |
| 125 | + $description .= "\n\n"; |
| 126 | + } |
| 127 | + |
122 | 128 | $description .= $this->getParameterTable( $descriptionData['parameters'] ); |
123 | 129 | |
124 | 130 | if ( $parameters['pre'] ) { |
— | — | @@ -146,6 +152,7 @@ |
147 | 153 | {| class="wikitable sortable" |
148 | 154 | {$table} |
149 | 155 | |} |
| 156 | +<pre!>..</pre!> |
150 | 157 | EOT; |
151 | 158 | } |
152 | 159 | |
— | — | @@ -185,4 +192,11 @@ |
186 | 193 | return $className !== false && class_exists( $className ) ? new $className() : false; |
187 | 194 | } |
188 | 195 | |
| 196 | + /** |
| 197 | + * @see ParserHook::getDescription() |
| 198 | + */ |
| 199 | + public function getDescription() { |
| 200 | + return wfMsg( 'validator-describe-description' ); |
| 201 | + } |
| 202 | + |
189 | 203 | } |
\ No newline at end of file |
Index: trunk/extensions/Validator/includes/ParserHook.php |
— | — | @@ -401,6 +401,9 @@ |
402 | 402 | |
403 | 403 | /** |
404 | 404 | * Returns the data needed to describe the parser hook. |
| 405 | + * This is mainly needed because some of the individual get methods |
| 406 | + * that return the needed data are protected, and cannot be made |
| 407 | + * public without breaking b/c in a rather bad way. |
405 | 408 | * |
406 | 409 | * @since 0.4.3 |
407 | 410 | * |
— | — | @@ -410,11 +413,24 @@ |
411 | 414 | */ |
412 | 415 | public function getDescriptionData( $type ) { |
413 | 416 | return array( |
| 417 | + 'description' => $this->getDescription(), |
414 | 418 | 'parameters' => $this->getParameterInfo( $type ), |
415 | 419 | 'defaults' => $this->getDefaultParameters( $type ), |
416 | 420 | ); |
417 | 421 | } |
418 | 422 | |
| 423 | + /** |
| 424 | + * Returns a description message for the parser hook, or false when there is none. |
| 425 | + * Override in deriving classes to add a message. |
| 426 | + * |
| 427 | + * @since 0.4.3 |
| 428 | + * |
| 429 | + * @return mixed string or false |
| 430 | + */ |
| 431 | + public function getDescription() { |
| 432 | + return false; |
| 433 | + } |
| 434 | + |
419 | 435 | } |
420 | 436 | |
421 | 437 | /** |
Index: trunk/extensions/Validator/Validator.i18n.php |
— | — | @@ -42,7 +42,9 @@ |
43 | 43 | 'validator-listerrors-fatal' => 'Fatal', |
44 | 44 | |
45 | 45 | // Describe |
| 46 | + 'validator-describe-description' => 'Generates documentation for one or more parser hooks defined via Validator.', |
46 | 47 | 'validator-describe-notfound' => 'There is no parser hook that handles "$1".', |
| 48 | + 'validator-describe-descriptionmsg' => "'''Description''': $1", // Because it's 1360 < 3 |
47 | 49 | |
48 | 50 | // Criteria errors for single values |
49 | 51 | 'validator_error_empty_argument' => 'Parameter $1 can not have an empty value.', |