Index: trunk/extensions/Validator/includes/parserHooks/Validator_Describe.php |
— | — | @@ -130,6 +130,8 @@ |
131 | 131 | * @return string |
132 | 132 | */ |
133 | 133 | protected function getParserHookDescription( $hookName, array $parameters, ParserHook $parserHook ) { |
| 134 | + global $wgLang; |
| 135 | + |
134 | 136 | $descriptionData = $parserHook->getDescriptionData( ParserHook::TYPE_TAG ); // TODO |
135 | 137 | |
136 | 138 | $description = "<h2> {$hookName} </h2>\n\n"; |
— | — | @@ -137,8 +139,35 @@ |
138 | 140 | if ( $descriptionData['description'] !== false ) { |
139 | 141 | $description .= wfMsgExt( 'validator-describe-descriptionmsg', 'parsemag', $descriptionData['description'] ); |
140 | 142 | $description .= "\n\n"; |
141 | | - } |
| 143 | + } |
142 | 144 | |
| 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 | + |
143 | 172 | $description .= $this->getParameterTable( $descriptionData['parameters'] ); |
144 | 173 | |
145 | 174 | if ( $parameters['pre'] ) { |
Index: trunk/extensions/Validator/includes/ParserHook.php |
— | — | @@ -68,14 +68,14 @@ |
69 | 69 | * |
70 | 70 | * @var boolean |
71 | 71 | */ |
72 | | - protected $forTagExtensions; |
| 72 | + public $forTagExtensions; |
73 | 73 | |
74 | 74 | /** |
75 | 75 | * @since 0.4 |
76 | 76 | * |
77 | 77 | * @var boolean |
78 | 78 | */ |
79 | | - protected $forParserFunctions; |
| 79 | + public $forParserFunctions; |
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Gets the name of the parser hook. |
— | — | @@ -121,9 +121,13 @@ |
122 | 122 | */ |
123 | 123 | public function init( Parser &$wgParser ) { |
124 | 124 | $className = get_class( $this ); |
| 125 | + $first = true; |
125 | 126 | |
126 | 127 | foreach ( $this->getNames() as $name ) { |
127 | | - self::$registeredHooks[$name] = $className; |
| 128 | + if ( $first ) { |
| 129 | + self::$registeredHooks[$name] = $className; |
| 130 | + $first = false; |
| 131 | + } |
128 | 132 | |
129 | 133 | if ( $this->forTagExtensions ) { |
130 | 134 | $wgParser->setHook( |
— | — | @@ -413,6 +417,7 @@ |
414 | 418 | */ |
415 | 419 | public function getDescriptionData( $type ) { |
416 | 420 | return array( |
| 421 | + 'names' => $this->getNames(), |
417 | 422 | 'description' => $this->getDescription(), |
418 | 423 | 'parameters' => $this->getParameterInfo( $type ), |
419 | 424 | 'defaults' => $this->getDefaultParameters( $type ), |
Index: trunk/extensions/Validator/Validator.i18n.php |
— | — | @@ -45,6 +45,10 @@ |
46 | 46 | 'validator-describe-description' => 'Generates documentation for one or more parser hooks defined via Validator.', |
47 | 47 | 'validator-describe-notfound' => 'There is no parser hook that handles "$1".', |
48 | 48 | '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.', |
49 | 53 | 'validator-describe-par-hooks' => 'The parser hooks for which to display documentation.', |
50 | 54 | 'validator-describe-par-pre' => 'Allows you to get the actual wikitext for the documentation, without it being rendered on the page.', |
51 | 55 | 'validator-describe-listtype' => 'List of $1 items', |