r79205 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79204‎ | r79205 | r79206 >
Date:21:28, 29 December 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Added parser hook aliases listing and a description of how they are implemented
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
@@ -130,6 +130,8 @@
131131 * @return string
132132 */
133133 protected function getParserHookDescription( $hookName, array $parameters, ParserHook $parserHook ) {
 134+ global $wgLang;
 135+
134136 $descriptionData = $parserHook->getDescriptionData( ParserHook::TYPE_TAG ); // TODO
135137
136138 $description = "<h2> {$hookName} </h2>\n\n";
@@ -137,8 +139,35 @@
138140 if ( $descriptionData['description'] !== false ) {
139141 $description .= wfMsgExt( 'validator-describe-descriptionmsg', 'parsemag', $descriptionData['description'] );
140142 $description .= "\n\n";
141 - }
 143+ }
142144
 145+ if ( count( $descriptionData['names'] ) > 1 ) {
 146+ $aliases = array();
 147+
 148+ foreach ( $descriptionData['names'] as $name ) {
 149+ if ( $name != $hookName ) {
 150+ $aliases[] = $name;
 151+ }
 152+ }
 153+
 154+ $description .= wfMsgExt( 'validator-describe-aliases', 'parsemag', $wgLang->listToText( $aliases ) );
 155+ $description .= "\n\n";
 156+ }
 157+
 158+ if ( $parserHook->forTagExtensions || $parserHook->forParserFunctions ) {
 159+ if ( $parserHook->forTagExtensions && $parserHook->forParserFunctions ) {
 160+ $description .= wfMsg( 'validator-describe-bothhooks' );
 161+ }
 162+ else if ( $parserHook->forTagExtensions ) {
 163+ $description .= wfMsg( 'validator-describe-tagextension' );
 164+ }
 165+ else { // if $parserHook->forParserFunctions
 166+ $description .= wfMsg( 'validator-describe-parserfunction' );
 167+ }
 168+
 169+ $description .= "\n\n";
 170+ }
 171+
143172 $description .= $this->getParameterTable( $descriptionData['parameters'] );
144173
145174 if ( $parameters['pre'] ) {
Index: trunk/extensions/Validator/includes/ParserHook.php
@@ -68,14 +68,14 @@
6969 *
7070 * @var boolean
7171 */
72 - protected $forTagExtensions;
 72+ public $forTagExtensions;
7373
7474 /**
7575 * @since 0.4
7676 *
7777 * @var boolean
7878 */
79 - protected $forParserFunctions;
 79+ public $forParserFunctions;
8080
8181 /**
8282 * Gets the name of the parser hook.
@@ -121,9 +121,13 @@
122122 */
123123 public function init( Parser &$wgParser ) {
124124 $className = get_class( $this );
 125+ $first = true;
125126
126127 foreach ( $this->getNames() as $name ) {
127 - self::$registeredHooks[$name] = $className;
 128+ if ( $first ) {
 129+ self::$registeredHooks[$name] = $className;
 130+ $first = false;
 131+ }
128132
129133 if ( $this->forTagExtensions ) {
130134 $wgParser->setHook(
@@ -413,6 +417,7 @@
414418 */
415419 public function getDescriptionData( $type ) {
416420 return array(
 421+ 'names' => $this->getNames(),
417422 'description' => $this->getDescription(),
418423 'parameters' => $this->getParameterInfo( $type ),
419424 'defaults' => $this->getDefaultParameters( $type ),
Index: trunk/extensions/Validator/Validator.i18n.php
@@ -45,6 +45,10 @@
4646 'validator-describe-description' => 'Generates documentation for one or more parser hooks defined via Validator.',
4747 'validator-describe-notfound' => 'There is no parser hook that handles "$1".',
4848 'validator-describe-descriptionmsg' => "'''Description''': $1", // Because it's 1360 < 3
 49+ 'validator-describe-aliases' => "'''Aliases''': $1",
 50+ 'validator-describe-parserfunction' => 'Implemented only as parser function.',
 51+ 'validator-describe-tagextension' => 'Implemented only as tag extension.',
 52+ 'validator-describe-bothhooks' => 'Implemented as both parser function and as tag extension.',
4953 'validator-describe-par-hooks' => 'The parser hooks for which to display documentation.',
5054 'validator-describe-par-pre' => 'Allows you to get the actual wikitext for the documentation, without it being rendered on the page.',
5155 'validator-describe-listtype' => 'List of $1 items',

Follow-up revisions

RevisionCommit summaryAuthorDate
r79248Follow-up r79205: Add PLURALraymond12:29, 30 December 2010

Status & tagging log