r79196 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79195‎ | r79196 | r79197 >
Date:19:59, 29 December 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Added method to add a description message to parser hooks
Modified paths:
  • /trunk/extensions/Validator/Validator.i18n.php (modified) (history)
  • /trunk/extensions/Validator/includes/ParserHook.php (modified) (history)
  • /trunk/extensions/Validator/includes/parserHooks/Validator_Describe.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Validator/includes/parserHooks/Validator_Describe.php
@@ -110,7 +110,8 @@
111111 false
112112 );
113113
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!&gt;', 'pre&gt;', $output->getText() );
115116 }
116117
117118 protected function getParserHookDescription( $hookName, array $parameters, ParserHook $parserHook ) {
@@ -118,6 +119,11 @@
119120
120121 $description = "<h2> {$hookName} </h2>\n\n";
121122
 123+ if ( $descriptionData['description'] !== false ) {
 124+ $description .= wfMsgExt( 'validator-describe-descriptionmsg', 'parsemag', $descriptionData['description'] );
 125+ $description .= "\n\n";
 126+ }
 127+
122128 $description .= $this->getParameterTable( $descriptionData['parameters'] );
123129
124130 if ( $parameters['pre'] ) {
@@ -146,6 +152,7 @@
147153 {| class="wikitable sortable"
148154 {$table}
149155 |}
 156+<pre!>..</pre!>
150157 EOT;
151158 }
152159
@@ -185,4 +192,11 @@
186193 return $className !== false && class_exists( $className ) ? new $className() : false;
187194 }
188195
 196+ /**
 197+ * @see ParserHook::getDescription()
 198+ */
 199+ public function getDescription() {
 200+ return wfMsg( 'validator-describe-description' );
 201+ }
 202+
189203 }
\ No newline at end of file
Index: trunk/extensions/Validator/includes/ParserHook.php
@@ -401,6 +401,9 @@
402402
403403 /**
404404 * 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.
405408 *
406409 * @since 0.4.3
407410 *
@@ -410,11 +413,24 @@
411414 */
412415 public function getDescriptionData( $type ) {
413416 return array(
 417+ 'description' => $this->getDescription(),
414418 'parameters' => $this->getParameterInfo( $type ),
415419 'defaults' => $this->getDefaultParameters( $type ),
416420 );
417421 }
418422
 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+
419435 }
420436
421437 /**
Index: trunk/extensions/Validator/Validator.i18n.php
@@ -42,7 +42,9 @@
4343 'validator-listerrors-fatal' => 'Fatal',
4444
4545 // Describe
 46+ 'validator-describe-description' => 'Generates documentation for one or more parser hooks defined via Validator.',
4647 'validator-describe-notfound' => 'There is no parser hook that handles "$1".',
 48+ 'validator-describe-descriptionmsg' => "'''Description''': $1", // Because it's 1360 < 3
4749
4850 // Criteria errors for single values
4951 'validator_error_empty_argument' => 'Parameter $1 can not have an empty value.',

Status & tagging log