r107393 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107392‎ | r107393 | r107394 >
Date:16:22, 27 December 2011
Author:reedy
Status:ok
Tags:
Comment:
Re-instate most of the revisions for bug 33147 "API examples should explain what they do"

Using this to sync up my working copies

Should have the little niggles tidied up though
Modified paths:
  • /trunk/phase3/RELEASE-NOTES-1.19 (modified) (history)
  • /trunk/phase3/includes/api/ApiBase.php (modified) (history)
  • /trunk/phase3/includes/api/ApiComparePages.php (modified) (history)
  • /trunk/phase3/includes/api/ApiDelete.php (modified) (history)
  • /trunk/phase3/includes/api/ApiEditPage.php (modified) (history)
  • /trunk/phase3/includes/api/ApiEmailUser.php (modified) (history)
  • /trunk/phase3/includes/api/ApiFileRevert.php (modified) (history)
  • /trunk/phase3/includes/api/ApiFormatBase.php (modified) (history)
  • /trunk/phase3/includes/api/ApiHelp.php (modified) (history)
  • /trunk/phase3/includes/api/ApiImport.php (modified) (history)
  • /trunk/phase3/includes/api/ApiLogout.php (modified) (history)
  • /trunk/phase3/includes/api/ApiParamInfo.php (modified) (history)
  • /trunk/phase3/includes/api/ApiPurge.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryAllimages.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryAllpages.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryCategories.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryCategoryMembers.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryDeletedrevs.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryExternalLinks.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryFilearchive.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryIWLinks.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryImages.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryLangLinks.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryLinks.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryRevisions.php (modified) (history)
  • /trunk/phase3/includes/api/ApiUpload.php (modified) (history)
  • /trunk/phase3/includes/api/ApiWatch.php (modified) (history)

Diff [purge]

Index: trunk/phase3/RELEASE-NOTES-1.19
@@ -226,6 +226,7 @@
227227 * (bug 32415) Empty page get no size attribute in API output.
228228 * (bug 31759) Undefined property notice in querypages API.
229229 * (bug 32495) API should allow purge by pageids.
 230+* (bug 33147) API examples should explain what they do.
230231
231232 === Languages updated in 1.19 ===
232233
Index: trunk/phase3/includes/api/ApiComparePages.php
@@ -120,7 +120,7 @@
121121
122122 public function getExamples() {
123123 return array(
124 - 'api.php?action=compare&fromrev=1&torev=2',
 124+ 'api.php?action=compare&fromrev=1&torev=2' => 'Creates a diff between revision 1 and 2',
125125 );
126126 }
127127
Index: trunk/phase3/includes/api/ApiQueryLangLinks.php
@@ -171,8 +171,7 @@
172172
173173 public function getExamples() {
174174 return array(
175 - 'Get interlanguage links from the [[Main Page]]:',
176 - ' api.php?action=query&prop=langlinks&titles=Main%20Page&redirects=',
 175+ 'api.php?action=query&prop=langlinks&titles=Main%20Page&redirects=' => 'Get interlanguage links from the [[Main Page]]',
177176 );
178177 }
179178
Index: trunk/phase3/includes/api/ApiParamInfo.php
@@ -114,8 +114,9 @@
115115 $result = $this->getResult();
116116 $retval['classname'] = get_class( $obj );
117117 $retval['description'] = implode( "\n", (array)$obj->getFinalDescription() );
118 - $examples = (array)$obj->getExamples();
119 - $retval['examples'] = implode( "\n", $examples );
 118+
 119+ $retval['examples'] = '';
 120+
120121 $retval['version'] = implode( "\n", (array)$obj->getVersion() );
121122 $retval['prefix'] = $obj->getModulePrefix();
122123
@@ -143,9 +144,28 @@
144145 }
145146 $result->setIndexedTagName( $retval['helpurls'], 'helpurl' );
146147
147 - $retval['allexamples'] = $examples;
148 - if ( isset( $retval['allexamples'][0] ) && $retval['allexamples'][0] === false ) {
149 - $retval['allexamples'] = array();
 148+ $examples = $obj->getExamples();
 149+ $retval['allexamples'] = array();
 150+ if ( $examples !== false ) {
 151+ foreach( $examples as $k => $v ) {
 152+ if ( strlen( $retval['examples'] ) ) {
 153+ $retval['examples'] .= ' ';
 154+ }
 155+ $item = array();
 156+ if ( is_numeric( $k ) ) {
 157+ $retval['examples'] .= $v;
 158+ $result->setContent( $item, $v );
 159+ } else {
 160+ if ( !is_array( $v ) ) {
 161+ $item['description'] = $v;
 162+ } else {
 163+ $item['description'] = implode( $v, "\n" );
 164+ }
 165+ $retval['examples'] .= $item['description'] . ' ' . $k;
 166+ $result->setContent( $item, $k );
 167+ }
 168+ $retval['allexamples'][] = $item;
 169+ }
150170 }
151171 $result->setIndexedTagName( $retval['allexamples'], 'example' );
152172
Index: trunk/phase3/includes/api/ApiQueryDeletedrevs.php
@@ -393,14 +393,14 @@
394394
395395 public function getExamples() {
396396 return array(
397 - 'List the last deleted revisions of Main Page and Talk:Main Page, with content (mode 1):',
398 - ' api.php?action=query&list=deletedrevs&titles=Main%20Page|Talk:Main%20Page&drprop=user|comment|content',
399 - 'List the last 50 deleted contributions by Bob (mode 2):',
400 - ' api.php?action=query&list=deletedrevs&druser=Bob&drlimit=50',
401 - 'List the first 50 deleted revisions in the main namespace (mode 3):',
402 - ' api.php?action=query&list=deletedrevs&drdir=newer&drlimit=50',
403 - 'List the first 50 deleted pages in the Talk namespace (mode 3):',
404 - ' api.php?action=query&list=deletedrevs&drdir=newer&drlimit=50&drnamespace=1&drunique=',
 397+ 'api.php?action=query&list=deletedrevs&titles=Main%20Page|Talk:Main%20Page&drprop=user|comment|content'
 398+ => 'List the last deleted revisions of Main Page and Talk:Main Page, with content (mode 1)',
 399+ 'api.php?action=query&list=deletedrevs&druser=Bob&drlimit=50'
 400+ => 'List the last 50 deleted contributions by Bob (mode 2)',
 401+ 'api.php?action=query&list=deletedrevs&drdir=newer&drlimit=50'
 402+ => 'List the first 50 deleted revisions in the main namespace (mode 3)',
 403+ 'api.php?action=query&list=deletedrevs&drdir=newer&drlimit=50&drnamespace=1&drunique='
 404+ => 'List the first 50 deleted pages in the Talk namespace (mode 3):',
405405 );
406406 }
407407
Index: trunk/phase3/includes/api/ApiWatch.php
@@ -114,8 +114,8 @@
115115
116116 public function getExamples() {
117117 return array(
118 - 'api.php?action=watch&title=Main_Page',
119 - 'api.php?action=watch&title=Main_Page&unwatch=',
 118+ 'api.php?action=watch&title=Main_Page' => 'Watch the page "Main Page"',
 119+ 'api.php?action=watch&title=Main_Page&unwatch=' => 'Unwatch the page "Main Page"',
120120 );
121121 }
122122
Index: trunk/phase3/includes/api/ApiQueryFilearchive.php
@@ -282,9 +282,10 @@
283283
284284 public function getExamples() {
285285 return array(
286 - 'Simple Use',
287 - ' Show a list of all deleted files',
288 - ' api.php?action=query&list=filearchive',
 286+ 'api.php?action=query&list=filearchive' => array(
 287+ 'Simple Use',
 288+ 'Show a list of all deleted files',
 289+ ),
289290 );
290291 }
291292
Index: trunk/phase3/includes/api/ApiQueryRevisions.php
@@ -664,13 +664,13 @@
665665
666666 public function getExamples() {
667667 return array(
668 - 'Get data with content for the last revision of titles "API" and "Main Page":',
 668+ 'Get data with content for the last revision of titles "API" and "Main Page"',
669669 ' api.php?action=query&prop=revisions&titles=API|Main%20Page&rvprop=timestamp|user|comment|content',
670 - 'Get last 5 revisions of the "Main Page":',
 670+ 'Get last 5 revisions of the "Main Page"',
671671 ' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment',
672 - 'Get first 5 revisions of the "Main Page":',
 672+ 'Get first 5 revisions of the "Main Page"',
673673 ' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment&rvdir=newer',
674 - 'Get first 5 revisions of the "Main Page" made after 2006-05-01:',
 674+ 'Get first 5 revisions of the "Main Page" made after 2006-05-01',
675675 ' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment&rvdir=newer&rvstart=20060501000000',
676676 'Get first 5 revisions of the "Main Page" that were not made made by anonymous user "127.0.0.1"',
677677 ' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment&rvexcludeuser=127.0.0.1',
Index: trunk/phase3/includes/api/ApiQueryExternalLinks.php
@@ -145,8 +145,7 @@
146146
147147 public function getExamples() {
148148 return array(
149 - 'Get a list of external links on the [[Main Page]]:',
150 - ' api.php?action=query&prop=extlinks&titles=Main%20Page',
 149+ 'api.php?action=query&prop=extlinks&titles=Main%20Page' => 'Get a list of external links on the [[Main Page]]',
151150 );
152151 }
153152
Index: trunk/phase3/includes/api/ApiQueryAllpages.php
@@ -309,14 +309,17 @@
310310
311311 public function getExamples() {
312312 return array(
313 - 'Simple Use',
314 - ' Show a list of pages starting at the letter "B"',
315 - ' api.php?action=query&list=allpages&apfrom=B',
316 - 'Using as Generator',
317 - ' Show info about 4 pages starting at the letter "T"',
318 - ' api.php?action=query&generator=allpages&gaplimit=4&gapfrom=T&prop=info',
319 - ' Show content of first 2 non-redirect pages begining at "Re"',
320 - ' api.php?action=query&generator=allpages&gaplimit=2&gapfilterredir=nonredirects&gapfrom=Re&prop=revisions&rvprop=content'
 313+ 'api.php?action=query&list=allpages&apfrom=B' => array(
 314+ 'Simple Use',
 315+ 'Show a list of pages starting at the letter "B"',
 316+ ),
 317+ 'api.php?action=query&generator=allpages&gaplimit=4&gapfrom=T&prop=info' => array(
 318+ 'Using as Generator',
 319+ 'Show info about 4 pages starting at the letter "T"',
 320+ ),
 321+ 'api.php?action=query&generator=allpages&gaplimit=2&gapfilterredir=nonredirects&gapfrom=Re&prop=revisions&rvprop=content' => array(
 322+ 'Show content of first 2 non-redirect pages begining at "Re"',
 323+ )
321324 );
322325 }
323326
Index: trunk/phase3/includes/api/ApiQueryCategoryMembers.php
@@ -389,10 +389,8 @@
390390
391391 public function getExamples() {
392392 return array(
393 - 'Get first 10 pages in [[Category:Physics]]:',
394 - ' api.php?action=query&list=categorymembers&cmtitle=Category:Physics',
395 - 'Get page info about first 10 pages in [[Category:Physics]]:',
396 - ' api.php?action=query&generator=categorymembers&gcmtitle=Category:Physics&prop=info',
 393+ 'api.php?action=query&list=categorymembers&cmtitle=Category:Physics' => 'Get first 10 pages in [[Category:Physics]]',
 394+ 'api.php?action=query&generator=categorymembers&gcmtitle=Category:Physics&prop=info' => 'Get page info about first 10 pages in [[Category:Physics]]',
397395 );
398396 }
399397
Index: trunk/phase3/includes/api/ApiPurge.php
@@ -149,7 +149,7 @@
150150
151151 public function getExamples() {
152152 return array(
153 - 'api.php?action=purge&titles=Main_Page|API'
 153+ 'api.php?action=purge&titles=Main_Page|API' => 'Purges the "Main Page" and the "API" page',
154154 );
155155 }
156156
Index: trunk/phase3/includes/api/ApiEditPage.php
@@ -502,12 +502,14 @@
503503
504504 public function getExamples() {
505505 return array(
506 - 'Edit a page (anonymous user):',
507 - ' api.php?action=edit&title=Test&summary=test%20summary&text=article%20content&basetimestamp=20070824123454&token=%2B\\',
508 - 'Prepend __NOTOC__ to a page (anonymous user):',
509 - ' api.php?action=edit&title=Test&summary=NOTOC&minor=&prependtext=__NOTOC__%0A&basetimestamp=20070824123454&token=%2B\\',
510 - 'Undo r13579 through r13585 with autosummary (anonymous user):',
511 - ' api.php?action=edit&title=Test&undo=13585&undoafter=13579&basetimestamp=20070824123454&token=%2B\\',
 506+
 507+ 'api.php?action=edit&title=Test&summary=test%20summary&text=article%20content&basetimestamp=20070824123454&token=%2B\\'
 508+ => 'Edit a page (anonymous user)',
 509+
 510+ 'api.php?action=edit&title=Test&summary=NOTOC&minor=&prependtext=__NOTOC__%0A&basetimestamp=20070824123454&token=%2B\\'
 511+ => 'Prepend __NOTOC__ to a page (anonymous user)',
 512+ 'api.php?action=edit&title=Test&undo=13585&undoafter=13579&basetimestamp=20070824123454&token=%2B\\'
 513+ => 'Undo r13579 through r13585 with autosummary (anonymous user)',
512514 );
513515 }
514516
Index: trunk/phase3/includes/api/ApiUpload.php
@@ -646,10 +646,10 @@
647647
648648 public function getExamples() {
649649 return array(
650 - 'Upload from a URL:',
651 - ' api.php?action=upload&filename=Wiki.png&url=http%3A//upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png',
652 - 'Complete an upload that failed due to warnings:',
653 - ' api.php?action=upload&filename=Wiki.png&filekey=filekey&ignorewarnings=1',
 650+ 'api.php?action=upload&filename=Wiki.png&url=http%3A//upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png'
 651+ => 'Upload from a URL',
 652+ 'api.php?action=upload&filename=Wiki.png&filekey=filekey&ignorewarnings=1'
 653+ => 'Complete an upload that failed due to warnings',
654654 );
655655 }
656656
Index: trunk/phase3/includes/api/ApiQueryLinks.php
@@ -231,13 +231,12 @@
232232 }
233233
234234 public function getExamples() {
 235+ $desc = $this->description;
 236+ $name = $this->getModuleName();
235237 return array(
236 - "Get {$this->description}s from the [[Main Page]]:",
237 - " api.php?action=query&prop={$this->getModuleName()}&titles=Main%20Page",
238 - "Get information about the {$this->description} pages in the [[Main Page]]:",
239 - " api.php?action=query&generator={$this->getModuleName()}&titles=Main%20Page&prop=info",
240 - "Get {$this->description}s from the Main Page in the User and Template namespaces:",
241 - " api.php?action=query&prop={$this->getModuleName()}&titles=Main%20Page&{$this->prefix}namespace=2|10"
 238+ "api.php?action=query&prop={$name}&titles=Main%20Page" => "Get {$desc}s from the [[Main Page]]:",
 239+ "api.php?action=query&generator={$name}&titles=Main%20Page&prop=info" => "Get information about the {$desc} pages in the [[Main Page]]:",
 240+ "api.php?action=query&prop={$name}&titles=Main%20Page&{$this->prefix}namespace=2|10" => "Get {$desc}s from the Main Page in the User and Template namespaces:",
242241 );
243242 }
244243
Index: trunk/phase3/includes/api/ApiQueryIWLinks.php
@@ -178,8 +178,7 @@
179179
180180 public function getExamples() {
181181 return array(
182 - 'Get interwiki links from the [[Main Page]]:',
183 - ' api.php?action=query&prop=iwlinks&titles=Main%20Page',
 182+ 'api.php?action=query&prop=iwlinks&titles=Main%20Page' => 'Get interwiki links from the [[Main Page]]',
184183 );
185184 }
186185
Index: trunk/phase3/includes/api/ApiFileRevert.php
@@ -171,8 +171,8 @@
172172
173173 public function getExamples() {
174174 return array(
175 - 'Revert Wiki.png to the version of 20110305152740:',
176 - ' api.php?action=filerevert&filename=Wiki.png&comment=Revert&archivename=20110305152740!Wiki.png&token=+\\',
 175+ 'api.php?action=filerevert&filename=Wiki.png&comment=Revert&archivename=20110305152740!Wiki.png&token=+\\'
 176+ => 'Revert Wiki.png to the version of 20110305152740',
177177 );
178178 }
179179
Index: trunk/phase3/includes/api/ApiLogout.php
@@ -64,7 +64,7 @@
6565
6666 public function getExamples() {
6767 return array(
68 - 'api.php?action=logout'
 68+ 'api.php?action=logout' => 'Logs the current user out',
6969 );
7070 }
7171
Index: trunk/phase3/includes/api/ApiQueryCategories.php
@@ -251,10 +251,8 @@
252252
253253 public function getExamples() {
254254 return array(
255 - 'Get a list of categories [[Albert Einstein]] belongs to:',
256 - ' api.php?action=query&prop=categories&titles=Albert%20Einstein',
257 - 'Get information about all categories used in the [[Albert Einstein]]:',
258 - ' api.php?action=query&generator=categories&titles=Albert%20Einstein&prop=info'
 255+ 'api.php?action=query&prop=categories&titles=Albert%20Einstein' => 'Get a list of categories [[Albert Einstein]] belongs to',
 256+ 'api.php?action=query&generator=categories&titles=Albert%20Einstein&prop=info' => 'Get information about all categories used in the [[Albert Einstein]]',
259257 );
260258 }
261259
Index: trunk/phase3/includes/api/ApiHelp.php
@@ -136,16 +136,11 @@
137137
138138 public function getExamples() {
139139 return array(
140 - 'Whole help page:',
141 - ' api.php?action=help',
142 - 'Module (action) help page:',
143 - ' api.php?action=help&modules=protect',
144 - 'Query (list) modules help page:',
145 - ' api.php?action=help&querymodules=categorymembers',
146 - 'Query (prop) modules help page:',
147 - ' api.php?action=help&querymodules=info',
148 - 'Query (meta) modules help page:',
149 - ' api.php?action=help&querymodules=siteinfo',
 140+ 'api.php?action=help' => 'Whole help page',
 141+ 'api.php?action=help&modules=protect' => 'Module (action) help page',
 142+ 'api.php?action=help&querymodules=categorymembers' => 'Query (list) modules help page',
 143+ 'api.php?action=help&querymodules=info' => 'Query (prop) modules help page',
 144+ 'api.php?action=help&querymodules=siteinfo' => 'Query (meta) modules help page',
150145 );
151146 }
152147
Index: trunk/phase3/includes/api/ApiQueryImages.php
@@ -185,10 +185,8 @@
186186
187187 public function getExamples() {
188188 return array(
189 - 'Get a list of images used in the [[Main Page]]:',
190 - ' api.php?action=query&prop=images&titles=Main%20Page',
191 - 'Get information about all images used in the [[Main Page]]:',
192 - ' api.php?action=query&generator=images&titles=Main%20Page&prop=info'
 189+ 'api.php?action=query&prop=images&titles=Main%20Page' => 'Get a list of images used in the [[Main Page]]',
 190+ 'api.php?action=query&generator=images&titles=Main%20Page&prop=info' => 'Get information about all images used in the [[Main Page]]',
193191 );
194192 }
195193
Index: trunk/phase3/includes/api/ApiDelete.php
@@ -263,8 +263,8 @@
264264
265265 public function getExamples() {
266266 return array(
267 - 'api.php?action=delete&title=Main%20Page&token=123ABC',
268 - 'api.php?action=delete&title=Main%20Page&token=123ABC&reason=Preparing%20for%20move'
 267+ 'api.php?action=delete&title=Main%20Page&token=123ABC' => 'Deletes the Main Page',
 268+ 'api.php?action=delete&title=Main%20Page&token=123ABC&reason=Preparing%20for%20move' => 'Deletes the Main Page with the reason "Preparing for move"',
269269 );
270270 }
271271
Index: trunk/phase3/includes/api/ApiImport.php
@@ -154,8 +154,8 @@
155155
156156 public function getExamples() {
157157 return array(
158 - 'Import [[meta:Help:Parserfunctions]] to namespace 100 with full history:',
159 - ' api.php?action=import&interwikisource=meta&interwikipage=Help:ParserFunctions&namespace=100&fullhistory=&token=123ABC',
 158+ 'api.php?action=import&interwikisource=meta&interwikipage=Help:ParserFunctions&namespace=100&fullhistory=&token=123ABC'
 159+ => 'Import [[meta:Help:Parserfunctions]] to namespace 100 with full history',
160160 );
161161 }
162162
Index: trunk/phase3/includes/api/ApiBase.php
@@ -267,7 +267,30 @@
268268 $msg .= "Parameters:\n$paramsMsg";
269269 }
270270
271 - $msg .= $this->makeHelpArrayToString( $lnPrfx, "Example", $this->getExamples() );
 271+ $examples = $this->getExamples();
 272+ if ( $examples !== false ) {
 273+ if ( !is_array( $examples ) ) {
 274+ $examples = array(
 275+ $examples
 276+ );
 277+ }
 278+ $msg .= "Example" . ( count( $examples ) > 1 ? 's' : '' ) . ":\n";
 279+ foreach( $examples as $k => $v ) {
 280+
 281+ if ( is_numeric( $k ) ) {
 282+ $msg .= " $v\n";
 283+ } else {
 284+ $v .= ":";
 285+ if ( is_array( $v ) ) {
 286+ $msgExample = implode( "\n", array_map( array( $this, 'indentExampleText' ), $v ) );
 287+ } else {
 288+ $msgExample = " $v";
 289+ }
 290+ $msg .= wordwrap( $msgExample, 100, "\n" ) . "\n $k\n";
 291+ }
 292+ }
 293+ }
 294+
272295 $msg .= $this->makeHelpArrayToString( $lnPrfx, "Help page", $this->getHelpUrls() );
273296
274297 if ( $this->getMain()->getShowVersions() ) {
@@ -292,6 +315,14 @@
293316 }
294317
295318 /**
 319+ * @param $item string
 320+ * @return string
 321+ */
 322+ private function indentExampleText( $item ) {
 323+ return " " . $item;
 324+ }
 325+
 326+ /**
296327 * @param $prefix string Text to split output items
297328 * @param $title string What is being output
298329 * @param $input string|array
@@ -341,13 +372,13 @@
342373 }
343374
344375 $deprecated = isset( $paramSettings[self::PARAM_DEPRECATED] ) ?
345 - $paramSettings[self::PARAM_DEPRECATED] : false;
 376+ $paramSettings[self::PARAM_DEPRECATED] : false;
346377 if ( $deprecated ) {
347378 $desc = "DEPRECATED! $desc";
348379 }
349380
350381 $required = isset( $paramSettings[self::PARAM_REQUIRED] ) ?
351 - $paramSettings[self::PARAM_REQUIRED] : false;
 382+ $paramSettings[self::PARAM_REQUIRED] : false;
352383 if ( $required ) {
353384 $desc .= $paramPrefix . "This parameter is required";
354385 }
@@ -411,7 +442,7 @@
412443 if ( !$isArray
413444 || $isArray && count( $paramSettings[self::PARAM_TYPE] ) > self::LIMIT_SML1 ) {
414445 $desc .= $paramPrefix . "Maximum number of values " .
415 - self::LIMIT_SML1 . " (" . self::LIMIT_SML2 . " for bots)";
 446+ self::LIMIT_SML1 . " (" . self::LIMIT_SML2 . " for bots)";
416447 }
417448 }
418449 }
@@ -465,8 +496,8 @@
466497 // returning the version string for ApiBase work
467498 if ( $path ) {
468499 return "{$matches[0]}\n https://svn.wikimedia.org/" .
469 - "viewvc/mediawiki/trunk/" . dirname( $path ) .
470 - "/{$matches[2]}";
 500+ "viewvc/mediawiki/trunk/" . dirname( $path ) .
 501+ "/{$matches[2]}";
471502 }
472503 return $matches[0];
473504 }
@@ -601,7 +632,7 @@
602633 array_shift( $required );
603634
604635 $intersection = array_intersect( array_keys( array_filter( $params,
605 - array( $this, "parameterNotEmpty" ) ) ), $required );
 636+ array( $this, "parameterNotEmpty" ) ) ), $required );
606637
607638 if ( count( $intersection ) > 1 ) {
608639 $this->dieUsage( 'The parameters ' . implode( ', ', $intersection ) . ' can not be used together', 'invalidparammix' );
@@ -636,7 +667,7 @@
637668 array_shift( $required );
638669
639670 $intersection = array_intersect( array_keys( array_filter( $params,
640 - array( $this, "parameterNotEmpty" ) ) ), $required );
 671+ array( $this, "parameterNotEmpty" ) ) ), $required );
641672
642673 if ( count( $intersection ) > 1 ) {
643674 $this->dieUsage( 'The parameters ' . implode( ', ', $intersection ) . ' can not be used together', 'invalidparammix' );
@@ -705,7 +736,7 @@
706737 # If no user option was passed, use watchdefault or watchcreation
707738 if ( is_null( $userOption ) ) {
708739 $userOption = $titleObj->exists()
709 - ? 'watchdefault' : 'watchcreations';
 740+ ? 'watchdefault' : 'watchcreations';
710741 }
711742 # Watch the article based on the user preference
712743 return (bool)$this->getUser()->getOption( $userOption );
@@ -921,7 +952,7 @@
922953 // This is a bit awkward, but we want to avoid calling canApiHighLimits() because it unstubs $wgUser
923954 $valuesList = explode( '|', $value, self::LIMIT_SML2 + 1 );
924955 $sizeLimit = count( $valuesList ) > self::LIMIT_SML1 && $this->mMainModule->canApiHighLimits() ?
925 - self::LIMIT_SML2 : self::LIMIT_SML1;
 956+ self::LIMIT_SML2 : self::LIMIT_SML1;
926957
927958 if ( self::truncateArray( $valuesList, $sizeLimit ) ) {
928959 $this->setWarning( "Too many values supplied for parameter '$valueName': the limit is $sizeLimit" );
@@ -1242,8 +1273,8 @@
12431274
12441275 if ( isset( self::$messageMap[$key] ) ) {
12451276 return array( 'code' =>
1246 - wfMsgReplaceArgs( self::$messageMap[$key]['code'], $error ),
1247 - 'info' =>
 1277+ wfMsgReplaceArgs( self::$messageMap[$key]['code'], $error ),
 1278+ 'info' =>
12481279 wfMsgReplaceArgs( self::$messageMap[$key]['info'], $error )
12491280 );
12501281 }
Index: trunk/phase3/includes/api/ApiFormatBase.php
@@ -286,7 +286,10 @@
287287 }
288288
289289 public function getExamples() {
290 - return 'api.php?action=query&meta=siteinfo&siprop=namespaces&format=' . $this->getModuleName();
 290+ return array(
 291+ 'api.php?action=query&meta=siteinfo&siprop=namespaces&format=' . $this->getModuleName()
 292+ => "Formats the query result in the {$this->getModuleName()} format",
 293+ );
291294 }
292295
293296 public function getHelpUrls() {
Index: trunk/phase3/includes/api/ApiQueryAllimages.php
@@ -246,12 +246,14 @@
247247
248248 public function getExamples() {
249249 return array(
250 - 'Simple Use',
251 - ' Show a list of images starting at the letter "B"',
252 - ' api.php?action=query&list=allimages&aifrom=B',
253 - 'Using as Generator',
254 - ' Show info about 4 images starting at the letter "T"',
255 - ' api.php?action=query&generator=allimages&gailimit=4&gaifrom=T&prop=imageinfo',
 250+ 'api.php?action=query&list=allimages&aifrom=B' => array(
 251+ 'Simple Use',
 252+ 'Show a list of images starting at the letter "B"',
 253+ ),
 254+ 'api.php?action=query&generator=allimages&gailimit=4&gaifrom=T&prop=imageinfo' => array(
 255+ 'Using as Generator',
 256+ 'Show info about 4 images starting at the letter "T"',
 257+ ),
256258 );
257259 }
258260
Index: trunk/phase3/includes/api/ApiEmailUser.php
@@ -133,7 +133,7 @@
134134
135135 public function getExamples() {
136136 return array(
137 - 'api.php?action=emailuser&target=WikiSysop&text=Content'
 137+ 'api.php?action=emailuser&target=WikiSysop&text=Content' => 'Sends an email to the User "WikiSysop" with the text "Content"',
138138 );
139139 }
140140

Follow-up revisions

RevisionCommit summaryAuthorDate
r107681Followup r107393, treat '' the same as getting false from getExamples, the de...reedy00:22, 31 December 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r106439Prep work for * (bug 33147) API examples should explain what they do...reedy15:28, 16 December 2011

Status & tagging log