r79192 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79191‎ | r79192 | r79193 >
Date:17:36, 29 December 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Follow up to r79190
Modified paths:
  • /trunk/extensions/Validator/includes/parserHooks/Validator_Describe.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Validator/includes/parserHooks/Validator_Describe.php
@@ -59,6 +59,9 @@
6060
6161 $params['hooks'] = new ListParameter( 'hooks' );
6262
 63+ $params['pre'] = new Parameter( 'pre', Parameter::TYPE_BOOLEAN );
 64+ $params['pre']->setDefault( 'off' );
 65+
6366 return $params;
6467 }
6568
@@ -94,19 +97,39 @@
9598 $parts[] = wfMsgExt( 'validator-describe-notfound', 'parsemag', $hookName );
9699 }
97100 else {
98 - $parts[] = $this->getParserHookDescription( $parserHook );
 101+ $parts[] = $this->getParserHookDescription( $hookName, $parameters, $parserHook );
99102 }
100103 }
101104
102 - return implode( "\n\n", $parts );
 105+ $output = $this->parser->parse(
 106+ implode( "\n\n", $parts ),
 107+ $this->parser->mTitle,
 108+ $this->parser->mOptions,
 109+ true,
 110+ false
 111+ );
 112+
 113+ return $output->getText();
103114 }
104115
105 - protected function getParserHookDescription( ParserHook $parserHook ) {
 116+ protected function getParserHookDescription( $hookName, array $parameters, ParserHook $parserHook ) {
106117 $descriptionData = $parserHook->getDescriptionData( ParserHook::TYPE_TAG ); // TODO
 118+
 119+ $description = "<h2> {$hookName} </h2>\n\n";
107120
 121+ $description .= $this->getParameterTable( $descriptionData['parameters'] );
 122+
 123+ if ( $parameters['pre'] ) {
 124+ $description = '<pre>' . $description . '</pre>';
 125+ }
 126+
 127+ return $description;
 128+ }
 129+
 130+ protected function getParameterTable( array $parameters ) {
108131 $tableRows = array();
109132
110 - foreach ( $descriptionData['parameters'] as $parameter ) {
 133+ foreach ( $parameters as $parameter ) {
111134 $tableRows[] = $this->getDescriptionRow( $parameter );
112135 }
113136
@@ -119,14 +142,13 @@
120143 $table = implode( "\n|-\n", $tableRows );
121144
122145 $table = <<<EOT
123 -{| class="wikitable sortable"'
 146+{| class="wikitable sortable"
124147 {$table}
125148 |}
126149 EOT;
127150 }
128151
129 - //return $table; // TODO
130 - return '<pre>' . $table . '</pre>';
 152+ return $table; // TODO
131153 }
132154
133155 protected function getDescriptionRow( Parameter $parameter ) {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r79190Added describe parser hook for automatic creation of parser hook documentation.jeroendedauw17:11, 29 December 2010

Status & tagging log