r106879 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106878‎ | r106879 | r106880 >
Date:22:11, 20 December 2011
Author:brion
Status:ok (Comments)
Tags:
Comment:

Revert r106439, r106441 - bad formatting mushing separate lines together
Modified paths:
  • /trunk/phase3/RELEASE-NOTES-1.19 (modified) (history)
  • /trunk/phase3/includes/api/ApiBase.php (modified) (history)
  • /trunk/phase3/includes/api/ApiParamInfo.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/ApiWatch.php (modified) (history)

Diff [purge]

Index: trunk/phase3/RELEASE-NOTES-1.19
@@ -218,7 +218,6 @@
219219 * (bug 32415) Empty page get no size attribute in API output.
220220 * (bug 31759) Undefined property notice in querypages API.
221221 * (bug 32495) API should allow purge by pageids.
222 -* (bug 33147) API examples should explain what they do.
223222
224223 === Languages updated in 1.19 ===
225224
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' => 'Watch the page "Main Page"',
119 - 'api.php?action=watch&title=Main_Page&unwatch=' => 'Unwatch the page "Main Page"',
 118+ 'api.php?action=watch&title=Main_Page',
 119+ 'api.php?action=watch&title=Main_Page&unwatch=',
120120 );
121121 }
122122
Index: trunk/phase3/includes/api/ApiQueryLinks.php
@@ -231,12 +231,13 @@
232232 }
233233
234234 public function getExamples() {
235 - $desc = $this->description;
236 - $name = $this->getModuleName();
237235 return array(
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:",
 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"
241242 );
242243 }
243244
Index: trunk/phase3/includes/api/ApiQueryAllpages.php
@@ -309,17 +309,14 @@
310310
311311 public function getExamples() {
312312 return array(
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 - )
 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'
324321 );
325322 }
326323
Index: trunk/phase3/includes/api/ApiQueryDeletedrevs.php
@@ -393,14 +393,14 @@
394394
395395 public function getExamples() {
396396 return array(
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):',
 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=',
405405 );
406406 }
407407
Index: trunk/phase3/includes/api/ApiQueryFilearchive.php
@@ -282,10 +282,9 @@
283283
284284 public function getExamples() {
285285 return array(
286 - 'api.php?action=query&list=filearchive' => array(
287 - 'Simple Use',
288 - 'Show a list of all deleted files',
289 - ),
 286+ 'Simple Use',
 287+ ' Show a list of all deleted files',
 288+ ' api.php?action=query&list=filearchive',
290289 );
291290 }
292291
Index: trunk/phase3/includes/api/ApiQueryCategoryMembers.php
@@ -389,8 +389,10 @@
390390
391391 public function getExamples() {
392392 return array(
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]]:',
 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',
395397 );
396398 }
397399
Index: trunk/phase3/includes/api/ApiQueryAllimages.php
@@ -246,14 +246,12 @@
247247
248248 public function getExamples() {
249249 return array(
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 - ),
 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',
258256 );
259257 }
260258
Index: trunk/phase3/includes/api/ApiQueryIWLinks.php
@@ -178,7 +178,8 @@
179179
180180 public function getExamples() {
181181 return array(
182 - 'api.php?action=query&prop=iwlinks&titles=Main%20Page' => 'Get interwiki links from the [[Main Page]]:',
 182+ 'Get interwiki links from the [[Main Page]]:',
 183+ ' api.php?action=query&prop=iwlinks&titles=Main%20Page',
183184 );
184185 }
185186
Index: trunk/phase3/includes/api/ApiQueryLangLinks.php
@@ -171,7 +171,8 @@
172172
173173 public function getExamples() {
174174 return array(
175 - 'api.php?action=query&prop=langlinks&titles=Main%20Page&redirects=' => 'Get interlanguage links from the [[Main Page]]:',
 175+ 'Get interlanguage links from the [[Main Page]]:',
 176+ ' api.php?action=query&prop=langlinks&titles=Main%20Page&redirects=',
176177 );
177178 }
178179
Index: trunk/phase3/includes/api/ApiQueryExternalLinks.php
@@ -145,7 +145,8 @@
146146
147147 public function getExamples() {
148148 return array(
149 - 'api.php?action=query&prop=extlinks&titles=Main%20Page' => 'Get a list of external links on the [[Main Page]]:',
 149+ 'Get a list of external links on the [[Main Page]]:',
 150+ ' api.php?action=query&prop=extlinks&titles=Main%20Page',
150151 );
151152 }
152153
Index: trunk/phase3/includes/api/ApiBase.php
@@ -267,29 +267,7 @@
268268 $msg .= "Parameters:\n$paramsMsg";
269269 }
270270
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 - if ( is_numeric( $k ) ) {
281 - $msg .= " $v\n";
282 - } else {
283 - if ( is_array( $v ) ) {
284 - $msg .= implode( "\n", array_map( array( $this, 'indentExampleText' ), $v ) );
285 - } else {
286 - $msg .= " $v";
287 - }
288 - $msg .= "\n $k";
289 - }
290 - }
291 - }
292 -
293 - $msg .= "\n";
 271+ $msg .= $this->makeHelpArrayToString( $lnPrfx, "Example", $this->getExamples() );
294272 $msg .= $this->makeHelpArrayToString( $lnPrfx, "Help page", $this->getHelpUrls() );
295273
296274 if ( $this->getMain()->getShowVersions() ) {
@@ -314,14 +292,6 @@
315293 }
316294
317295 /**
318 - * @param $item string
319 - * @return string
320 - */
321 - private function indentExampleText( $item ) {
322 - return " " . $item;
323 - }
324 -
325 - /**
326296 * @param $prefix string Text to split output items
327297 * @param $title string What is being output
328298 * @param $input string|array
Index: trunk/phase3/includes/api/ApiQueryCategories.php
@@ -251,8 +251,10 @@
252252
253253 public function getExamples() {
254254 return array(
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]]:',
 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'
257259 );
258260 }
259261
Index: trunk/phase3/includes/api/ApiParamInfo.php
@@ -114,9 +114,8 @@
115115 $result = $this->getResult();
116116 $retval['classname'] = get_class( $obj );
117117 $retval['description'] = implode( "\n", (array)$obj->getFinalDescription() );
118 -
119 - $retval['examples'] = '';
120 -
 118+ $examples = (array)$obj->getExamples();
 119+ $retval['examples'] = implode( "\n", $examples );
121120 $retval['version'] = implode( "\n", (array)$obj->getVersion() );
122121 $retval['prefix'] = $obj->getModulePrefix();
123122
@@ -144,28 +143,9 @@
145144 }
146145 $result->setIndexedTagName( $retval['helpurls'], 'helpurl' );
147146
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 - }
 147+ $retval['allexamples'] = $examples;
 148+ if ( isset( $retval['allexamples'][0] ) && $retval['allexamples'][0] === false ) {
 149+ $retval['allexamples'] = array();
170150 }
171151 $result->setIndexedTagName( $retval['allexamples'], 'example' );
172152
Index: trunk/phase3/includes/api/ApiQueryImages.php
@@ -185,8 +185,10 @@
186186
187187 public function getExamples() {
188188 return array(
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]]:',
 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'
191193 );
192194 }
193195

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
r106441Convert a few more descriptions...reedy15:45, 16 December 2011

Comments

#Comment by Reedy (talk | contribs)   22:16, 20 December 2011

Seriously? I don't see the urgent need to mass revert everything, especially when a developer is active. Even more so, when in this case we're arguing over a newline, it's not like the examples are completely broken or similar

In allimages, as below, the only thing I can see, is a missing newline


Examples:
  Simple Use
  Show a list of images starting at the letter "B"
    api.php?action=query&list=allimages&aifrom=B  Using as Generator
  Show info about 4 images starting at the letter "T"
    api.php?action=query&generator=allimages&gailimit=4&gaifrom=T&prop=imageinfo

Similar case for allpages

Examples:
  Simple Use
  Show a list of pages starting at the letter "B"
    api.php?action=query&list=allpages&apfrom=B  Using as Generator
  Show info about 4 pages starting at the letter "T"
    api.php?action=query&generator=allpages&gaplimit=4&gapfrom=T&prop=info  Show content of first 2 non-redirect pages begining at "Re"
    api.php?action=query&generator=allpages&gaplimit=2&gapfilterredir=nonredirects&gapfrom=Re&prop=revisions&rvprop=content
#Comment by Brion VIBBER (talk | contribs)   22:42, 20 December 2011

So commit it when it's working correctly, please.

#Comment by Reedy (talk | contribs)   16:24, 27 December 2011

All reverted back in by r107393

Status & tagging log