Index: trunk/extensions/Validator/includes/parserHooks/Validator_Describe.php |
— | — | @@ -59,9 +59,11 @@ |
60 | 60 | |
61 | 61 | $params['hooks'] = new ListParameter( 'hooks' ); |
62 | 62 | $params['hooks']->setDefault( array_keys( ParserHook::getRegisteredParserHooks() ) ); |
| 63 | + $params['hooks']->setDescription( wfMsg( 'validator-describe-par-hooks' ) ); |
63 | 64 | |
64 | 65 | $params['pre'] = new Parameter( 'pre', Parameter::TYPE_BOOLEAN ); |
65 | 66 | $params['pre']->setDefault( 'off' ); |
| 67 | + $params['pre']->setDescription( wfMsg( 'validator-describe-par-pre' ) ); |
66 | 68 | |
67 | 69 | return $params; |
68 | 70 | } |
— | — | @@ -162,11 +164,12 @@ |
163 | 165 | $tableRows[] = $this->getDescriptionRow( $parameter ); |
164 | 166 | } |
165 | 167 | |
166 | | - if ( count( $tableRows ) > 0 ) { |
| 168 | + if ( count( $tableRows ) > 0 ) { // i18n |
167 | 169 | $tableRows = array_merge( array( '! Parameter |
168 | 170 | ! Aliases |
| 171 | +! Type |
169 | 172 | ! Default |
170 | | -! Usage' ), $tableRows ); |
| 173 | +! Description' ), $tableRows ); |
171 | 174 | |
172 | 175 | $table = implode( "\n|-\n", $tableRows ); |
173 | 176 | |
— | — | @@ -174,11 +177,10 @@ |
175 | 178 | {| class="wikitable sortable" |
176 | 179 | {$table} |
177 | 180 | |} |
178 | | -<pre!>..</pre!> |
179 | 181 | EOT; |
180 | 182 | } |
181 | 183 | |
182 | | - return $table; // TODO |
| 184 | + return $table; |
183 | 185 | } |
184 | 186 | |
185 | 187 | /** |
— | — | @@ -198,13 +200,19 @@ |
199 | 201 | if ( is_array( $default ) ) $default = implode( ', ', $default ); |
200 | 202 | if ( $default === '' ) $default = "''empty''"; |
201 | 203 | |
202 | | - // TODO |
| 204 | + $description = $parameter->getDescription(); |
| 205 | + if ( $description === false ) $description = '-'; |
203 | 206 | |
| 207 | + // TODO: some mapping to make the type names more user-friendly |
| 208 | + $type = $parameter->getType(); |
| 209 | + if ( $parameter->isList() ) $type = wfMsgExt( 'validator-describe-listtype', 'parsemag', $type ); |
| 210 | + |
204 | 211 | return <<<EOT |
205 | 212 | | {$parameter->getName()} |
206 | 213 | | {$aliases} |
| 214 | +| {$type} |
207 | 215 | | {$default} |
208 | | -| Description be here. |
| 216 | +| {$description} |
209 | 217 | EOT; |
210 | 218 | } |
211 | 219 | |
Index: trunk/extensions/Validator/includes/Parameter.php |
— | — | @@ -178,6 +178,16 @@ |
179 | 179 | protected $defaulted = false; |
180 | 180 | |
181 | 181 | /** |
| 182 | + * A description for the parameter or false when there is none. |
| 183 | + * Can be obtained via getDescription and set via setDescription. |
| 184 | + * |
| 185 | + * @since 0.4.3 |
| 186 | + * |
| 187 | + * @var mixed string or false |
| 188 | + */ |
| 189 | + protected $description = false; |
| 190 | + |
| 191 | + /** |
182 | 192 | * Constructor. |
183 | 193 | * |
184 | 194 | * @since 0.4 |
— | — | @@ -449,6 +459,17 @@ |
450 | 460 | } |
451 | 461 | |
452 | 462 | /** |
| 463 | + * Returns the type of the parameter. |
| 464 | + * |
| 465 | + * @since 0.4.3 |
| 466 | + * |
| 467 | + * @return string element of the Parameter::TYPE_ enum |
| 468 | + */ |
| 469 | + public function getType() { |
| 470 | + return $this->type; |
| 471 | + } |
| 472 | + |
| 473 | + /** |
453 | 474 | * Returns a list of dependencies the parameter has, in the form of |
454 | 475 | * other parameter names. |
455 | 476 | * |
— | — | @@ -722,6 +743,29 @@ |
723 | 744 | } |
724 | 745 | |
725 | 746 | return false; |
726 | | - } |
| 747 | + } |
| 748 | + |
| 749 | + /** |
| 750 | + * Returns a description message for the parameter, or false when there is none. |
| 751 | + * Override in deriving classes to add a message. |
| 752 | + * |
| 753 | + * @since 0.4.3 |
| 754 | + * |
| 755 | + * @return mixed string or false |
| 756 | + */ |
| 757 | + public function getDescription() { |
| 758 | + return $this->description; |
| 759 | + } |
727 | 760 | |
| 761 | + /** |
| 762 | + * Sets a description message for the parameter. |
| 763 | + * |
| 764 | + * @since 0.4.3 |
| 765 | + * |
| 766 | + * @param string $descriptionMessage |
| 767 | + */ |
| 768 | + public function setDescription( $descriptionMessage ) { |
| 769 | + $this->description = $descriptionMessage; |
| 770 | + } |
| 771 | + |
728 | 772 | } |
\ No newline at end of file |
Index: trunk/extensions/Validator/Validator.i18n.php |
— | — | @@ -45,6 +45,9 @@ |
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-par-hooks' => 'The parser hooks for which to display documentation.', |
| 50 | + 'validator-describe-par-pre' => 'Allows you to get the actual wikitext for the documentation, without it being rendered on the page.', |
| 51 | + 'validator-describe-listtype' => 'List of $1 items', |
49 | 52 | |
50 | 53 | // Criteria errors for single values |
51 | 54 | 'validator_error_empty_argument' => 'Parameter $1 can not have an empty value.', |