Re-instate most of the revisions for bug 33147 "API examples should explain what...
authorSam Reed <reedy@users.mediawiki.org>
Tue, 27 Dec 2011 16:22:35 +0000 (16:22 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Tue, 27 Dec 2011 16:22:35 +0000 (16:22 +0000)
Using this to sync up my working copies

Should have the little niggles tidied up though

27 files changed:
RELEASE-NOTES-1.19
includes/api/ApiBase.php
includes/api/ApiComparePages.php
includes/api/ApiDelete.php
includes/api/ApiEditPage.php
includes/api/ApiEmailUser.php
includes/api/ApiFileRevert.php
includes/api/ApiFormatBase.php
includes/api/ApiHelp.php
includes/api/ApiImport.php
includes/api/ApiLogout.php
includes/api/ApiParamInfo.php
includes/api/ApiPurge.php
includes/api/ApiQueryAllimages.php
includes/api/ApiQueryAllpages.php
includes/api/ApiQueryCategories.php
includes/api/ApiQueryCategoryMembers.php
includes/api/ApiQueryDeletedrevs.php
includes/api/ApiQueryExternalLinks.php
includes/api/ApiQueryFilearchive.php
includes/api/ApiQueryIWLinks.php
includes/api/ApiQueryImages.php
includes/api/ApiQueryLangLinks.php
includes/api/ApiQueryLinks.php
includes/api/ApiQueryRevisions.php
includes/api/ApiUpload.php
includes/api/ApiWatch.php

index 182ef6d..72cefb8 100644 (file)
@@ -226,6 +226,7 @@ production.
 * (bug 32415) Empty page get no size attribute in API output.
 * (bug 31759) Undefined property notice in querypages API.
 * (bug 32495) API should allow purge by pageids.
+* (bug 33147) API examples should explain what they do.
 
 === Languages updated in 1.19 ===
 
index e1ba493..efca658 100644 (file)
@@ -267,7 +267,30 @@ abstract class ApiBase extends ContextSource {
                                $msg .= "Parameters:\n$paramsMsg";
                        }
 
-                       $msg .= $this->makeHelpArrayToString( $lnPrfx, "Example", $this->getExamples() );
+                       $examples = $this->getExamples();
+                       if ( $examples !== false ) {
+                               if ( !is_array( $examples ) ) {
+                                       $examples = array(
+                                               $examples
+                                       );
+                               }
+                               $msg .= "Example" . ( count( $examples ) > 1 ? 's' : '' ) . ":\n";
+                               foreach( $examples as $k => $v ) {
+
+                                       if ( is_numeric( $k ) ) {
+                                               $msg .= "  $v\n";
+                                       } else {
+                                               $v .= ":";
+                                               if ( is_array( $v ) ) {
+                                                       $msgExample = implode( "\n", array_map( array( $this, 'indentExampleText' ), $v ) );
+                                               } else {
+                                                       $msgExample = "  $v";
+                                               }
+                                               $msg .= wordwrap( $msgExample, 100, "\n" ) . "\n    $k\n";
+                                       }
+                               }
+                       }
+
                        $msg .= $this->makeHelpArrayToString( $lnPrfx, "Help page", $this->getHelpUrls() );
 
                        if ( $this->getMain()->getShowVersions() ) {
@@ -291,6 +314,14 @@ abstract class ApiBase extends ContextSource {
                return $msg;
        }
 
+       /**
+        * @param $item string
+        * @return string
+        */
+       private function indentExampleText( $item ) {
+               return "  " . $item;
+       }
+
        /**
         * @param $prefix string Text to split output items
         * @param $title string What is being output
@@ -341,13 +372,13 @@ abstract class ApiBase extends ContextSource {
                                }
 
                                $deprecated = isset( $paramSettings[self::PARAM_DEPRECATED] ) ?
-                                       $paramSettings[self::PARAM_DEPRECATED] : false;
+                                               $paramSettings[self::PARAM_DEPRECATED] : false;
                                if ( $deprecated ) {
                                        $desc = "DEPRECATED! $desc";
                                }
 
                                $required = isset( $paramSettings[self::PARAM_REQUIRED] ) ?
-                                       $paramSettings[self::PARAM_REQUIRED] : false;
+                                               $paramSettings[self::PARAM_REQUIRED] : false;
                                if ( $required ) {
                                        $desc .= $paramPrefix . "This parameter is required";
                                }
@@ -411,7 +442,7 @@ abstract class ApiBase extends ContextSource {
                                                        if ( !$isArray
                                                                        || $isArray && count( $paramSettings[self::PARAM_TYPE] ) > self::LIMIT_SML1 ) {
                                                                $desc .= $paramPrefix . "Maximum number of values " .
-                                                                       self::LIMIT_SML1 . " (" . self::LIMIT_SML2 . " for bots)";
+                                                                               self::LIMIT_SML1 . " (" . self::LIMIT_SML2 . " for bots)";
                                                        }
                                                }
                                        }
@@ -465,8 +496,8 @@ abstract class ApiBase extends ContextSource {
                // returning the version string for ApiBase work
                if ( $path ) {
                        return "{$matches[0]}\n   https://svn.wikimedia.org/" .
-                               "viewvc/mediawiki/trunk/" . dirname( $path ) .
-                               "/{$matches[2]}";
+                                       "viewvc/mediawiki/trunk/" . dirname( $path ) .
+                                       "/{$matches[2]}";
                }
                return $matches[0];
        }
@@ -601,7 +632,7 @@ abstract class ApiBase extends ContextSource {
                array_shift( $required );
 
                $intersection = array_intersect( array_keys( array_filter( $params,
-                               array( $this, "parameterNotEmpty" ) ) ), $required );
+                       array( $this, "parameterNotEmpty" ) ) ), $required );
 
                if ( count( $intersection ) > 1 ) {
                        $this->dieUsage( 'The parameters ' . implode( ', ', $intersection ) . ' can not be used together', 'invalidparammix' );
@@ -636,7 +667,7 @@ abstract class ApiBase extends ContextSource {
                array_shift( $required );
 
                $intersection = array_intersect( array_keys( array_filter( $params,
-                               array( $this, "parameterNotEmpty" ) ) ), $required );
+                       array( $this, "parameterNotEmpty" ) ) ), $required );
 
                if ( count( $intersection ) > 1 ) {
                        $this->dieUsage( 'The parameters ' . implode( ', ', $intersection ) . ' can not be used together', 'invalidparammix' );
@@ -705,7 +736,7 @@ abstract class ApiBase extends ContextSource {
                                # If no user option was passed, use watchdefault or watchcreation
                                if ( is_null( $userOption ) ) {
                                        $userOption = $titleObj->exists()
-                                               ? 'watchdefault' : 'watchcreations';
+                                                       ? 'watchdefault' : 'watchcreations';
                                }
                                # Watch the article based on the user preference
                                return (bool)$this->getUser()->getOption( $userOption );
@@ -921,7 +952,7 @@ abstract class ApiBase extends ContextSource {
                // This is a bit awkward, but we want to avoid calling canApiHighLimits() because it unstubs $wgUser
                $valuesList = explode( '|', $value, self::LIMIT_SML2 + 1 );
                $sizeLimit = count( $valuesList ) > self::LIMIT_SML1 && $this->mMainModule->canApiHighLimits() ?
-                       self::LIMIT_SML2 : self::LIMIT_SML1;
+                               self::LIMIT_SML2 : self::LIMIT_SML1;
 
                if ( self::truncateArray( $valuesList, $sizeLimit ) ) {
                        $this->setWarning( "Too many values supplied for parameter '$valueName': the limit is $sizeLimit" );
@@ -1242,8 +1273,8 @@ abstract class ApiBase extends ContextSource {
 
                if ( isset( self::$messageMap[$key] ) ) {
                        return array( 'code' =>
-                               wfMsgReplaceArgs( self::$messageMap[$key]['code'], $error ),
-                                       'info' =>
+                       wfMsgReplaceArgs( self::$messageMap[$key]['code'], $error ),
+                               'info' =>
                                wfMsgReplaceArgs( self::$messageMap[$key]['info'], $error )
                        );
                }
index 6c22f18..7328902 100644 (file)
@@ -120,7 +120,7 @@ class ApiComparePages extends ApiBase {
 
        public function getExamples() {
                return array(
-                       'api.php?action=compare&fromrev=1&torev=2',
+                       'api.php?action=compare&fromrev=1&torev=2' => 'Creates a diff between revision 1 and 2',
                );
        }
 
index 4ffa66c..9d850cc 100644 (file)
@@ -263,8 +263,8 @@ class ApiDelete extends ApiBase {
 
        public function getExamples() {
                return array(
-                       'api.php?action=delete&title=Main%20Page&token=123ABC',
-                       'api.php?action=delete&title=Main%20Page&token=123ABC&reason=Preparing%20for%20move'
+                       'api.php?action=delete&title=Main%20Page&token=123ABC' => 'Deletes the Main Page',
+                       'api.php?action=delete&title=Main%20Page&token=123ABC&reason=Preparing%20for%20move' => 'Deletes the Main Page with the reason "Preparing for move"',
                );
        }
 
index f45f9fd..216468c 100644 (file)
@@ -502,12 +502,14 @@ class ApiEditPage extends ApiBase {
 
        public function getExamples() {
                return array(
-                       'Edit a page (anonymous user):',
-                       '    api.php?action=edit&title=Test&summary=test%20summary&text=article%20content&basetimestamp=20070824123454&token=%2B\\',
-                       'Prepend __NOTOC__ to a page (anonymous user):',
-                       '    api.php?action=edit&title=Test&summary=NOTOC&minor=&prependtext=__NOTOC__%0A&basetimestamp=20070824123454&token=%2B\\',
-                       'Undo r13579 through r13585 with autosummary (anonymous user):',
-                       '    api.php?action=edit&title=Test&undo=13585&undoafter=13579&basetimestamp=20070824123454&token=%2B\\',
+
+                       'api.php?action=edit&title=Test&summary=test%20summary&text=article%20content&basetimestamp=20070824123454&token=%2B\\'
+                               => 'Edit a page (anonymous user)',
+
+                       'api.php?action=edit&title=Test&summary=NOTOC&minor=&prependtext=__NOTOC__%0A&basetimestamp=20070824123454&token=%2B\\'
+                               => 'Prepend __NOTOC__ to a page (anonymous user)',
+                       'api.php?action=edit&title=Test&undo=13585&undoafter=13579&basetimestamp=20070824123454&token=%2B\\'
+                               => 'Undo r13579 through r13585 with autosummary (anonymous user)',
                );
        }
 
index 5a01ae9..004ca73 100644 (file)
@@ -133,7 +133,7 @@ class ApiEmailUser extends ApiBase {
 
        public function getExamples() {
                return array(
-                       'api.php?action=emailuser&target=WikiSysop&text=Content'
+                       'api.php?action=emailuser&target=WikiSysop&text=Content' => 'Sends an email to the User "WikiSysop" with the text "Content"',
                );
        }
 
index 0a21680..7ef1da0 100644 (file)
@@ -171,8 +171,8 @@ class ApiFileRevert extends ApiBase {
 
        public function getExamples() {
                return array(
-                       'Revert Wiki.png to the version of 20110305152740:',
-                       '    api.php?action=filerevert&filename=Wiki.png&comment=Revert&archivename=20110305152740!Wiki.png&token=+\\',
+                       'api.php?action=filerevert&filename=Wiki.png&comment=Revert&archivename=20110305152740!Wiki.png&token=+\\'
+                               => 'Revert Wiki.png to the version of 20110305152740',
                );
        }
 
index a0138ac..7a53b64 100644 (file)
@@ -286,7 +286,10 @@ See <a href='https://www.mediawiki.org/wiki/API'>complete documentation</a>, or
        }
 
        public function getExamples() {
-               return 'api.php?action=query&meta=siteinfo&siprop=namespaces&format=' . $this->getModuleName();
+               return array(
+                       'api.php?action=query&meta=siteinfo&siprop=namespaces&format=' . $this->getModuleName()
+                               => "Formats the query result in the {$this->getModuleName()} format",
+               );
        }
 
        public function getHelpUrls() {
index d94132a..97da786 100644 (file)
@@ -136,16 +136,11 @@ class ApiHelp extends ApiBase {
 
        public function getExamples() {
                return array(
-                       'Whole help page:',
-                       '  api.php?action=help',
-                       'Module (action) help page:',
-                       '  api.php?action=help&modules=protect',
-                       'Query (list) modules help page:',
-                       '  api.php?action=help&querymodules=categorymembers',
-                       'Query (prop) modules help page:',
-                       '  api.php?action=help&querymodules=info',
-                       'Query (meta) modules help page:',
-                       '  api.php?action=help&querymodules=siteinfo',
+                       'api.php?action=help' => 'Whole help page',
+                       'api.php?action=help&modules=protect' => 'Module (action) help page',
+                       'api.php?action=help&querymodules=categorymembers' => 'Query (list) modules help page',
+                       'api.php?action=help&querymodules=info' => 'Query (prop) modules help page',
+                       'api.php?action=help&querymodules=siteinfo' => 'Query (meta) modules help page',
                );
        }
 
index d38aaf8..ade9f1f 100644 (file)
@@ -154,8 +154,8 @@ class ApiImport extends ApiBase {
 
        public function getExamples() {
                return array(
-                       'Import [[meta:Help:Parserfunctions]] to namespace 100 with full history:',
-                       '  api.php?action=import&interwikisource=meta&interwikipage=Help:ParserFunctions&namespace=100&fullhistory=&token=123ABC',
+                       'api.php?action=import&interwikisource=meta&interwikipage=Help:ParserFunctions&namespace=100&fullhistory=&token=123ABC'
+                               => 'Import [[meta:Help:Parserfunctions]] to namespace 100 with full history',
                );
        }
 
index f530e87..0e4ae53 100644 (file)
@@ -64,7 +64,7 @@ class ApiLogout extends ApiBase {
 
        public function getExamples() {
                return array(
-                       'api.php?action=logout'
+                       'api.php?action=logout' => 'Logs the current user out',
                );
        }
 
index 972641d..c5d4cba 100644 (file)
@@ -114,8 +114,9 @@ class ApiParamInfo extends ApiBase {
                $result = $this->getResult();
                $retval['classname'] = get_class( $obj );
                $retval['description'] = implode( "\n", (array)$obj->getFinalDescription() );
-               $examples = (array)$obj->getExamples();
-               $retval['examples'] = implode( "\n", $examples );
+
+               $retval['examples'] = '';
+
                $retval['version'] = implode( "\n", (array)$obj->getVersion() );
                $retval['prefix'] = $obj->getModulePrefix();
 
@@ -143,9 +144,28 @@ class ApiParamInfo extends ApiBase {
                }
                $result->setIndexedTagName( $retval['helpurls'], 'helpurl' );
 
-               $retval['allexamples'] = $examples;
-               if ( isset( $retval['allexamples'][0] ) && $retval['allexamples'][0] === false ) {
-                       $retval['allexamples'] = array();
+               $examples = $obj->getExamples();
+               $retval['allexamples'] = array();
+               if ( $examples !== false ) {
+                       foreach( $examples as $k => $v ) {
+                               if ( strlen( $retval['examples'] ) ) {
+                                       $retval['examples'] .= ' ';
+                               }
+                               $item = array();
+                               if ( is_numeric( $k ) ) {
+                                       $retval['examples'] .= $v;
+                                       $result->setContent( $item, $v );
+                               } else {
+                                       if ( !is_array( $v ) ) {
+                                               $item['description'] = $v;
+                                       } else {
+                                               $item['description'] = implode( $v, "\n" );
+                                       }
+                                       $retval['examples'] .= $item['description'] . ' ' . $k;
+                                       $result->setContent( $item, $k );
+                               }
+                               $retval['allexamples'][] = $item;
+                       }
                }
                $result->setIndexedTagName( $retval['allexamples'], 'example' );
 
index d2e0777..6bf5cb8 100644 (file)
@@ -149,7 +149,7 @@ class ApiPurge extends ApiBase {
 
        public function getExamples() {
                return array(
-                       'api.php?action=purge&titles=Main_Page|API'
+                       'api.php?action=purge&titles=Main_Page|API' => 'Purges the "Main Page" and the "API" page',
                );
        }
 
index c39f93a..ca344f7 100644 (file)
@@ -246,12 +246,14 @@ class ApiQueryAllimages extends ApiQueryGeneratorBase {
 
        public function getExamples() {
                return array(
-                       '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',
+                       'api.php?action=query&list=allimages&aifrom=B' => array(
+                               'Simple Use',
+                               'Show a list of images starting at the letter "B"',
+                       ),
+                       'api.php?action=query&generator=allimages&gailimit=4&gaifrom=T&prop=imageinfo' => array(
+                               'Using as Generator',
+                               'Show info about 4 images starting at the letter "T"',
+                       ),
                );
        }
 
index 0556a50..e003ee9 100644 (file)
@@ -309,14 +309,17 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase {
 
        public function getExamples() {
                return array(
-                       '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'
+                       'api.php?action=query&list=allpages&apfrom=B' => array(
+                               'Simple Use',
+                               'Show a list of pages starting at the letter "B"',
+                       ),
+                       'api.php?action=query&generator=allpages&gaplimit=4&gapfrom=T&prop=info' => array(
+                               'Using as Generator',
+                               'Show info about 4 pages starting at the letter "T"',
+                       ),
+                       'api.php?action=query&generator=allpages&gaplimit=2&gapfilterredir=nonredirects&gapfrom=Re&prop=revisions&rvprop=content' => array(
+                               'Show content of first 2 non-redirect pages begining at "Re"',
+                       )
                );
        }
 
index 9335a96..4e7e1b3 100644 (file)
@@ -251,10 +251,8 @@ class ApiQueryCategories extends ApiQueryGeneratorBase {
 
        public function getExamples() {
                return array(
-                       'Get a list of categories [[Albert Einstein]] belongs to:',
-                       '  api.php?action=query&prop=categories&titles=Albert%20Einstein',
-                       'Get information about all categories used in the [[Albert Einstein]]:',
-                       '  api.php?action=query&generator=categories&titles=Albert%20Einstein&prop=info'
+                       'api.php?action=query&prop=categories&titles=Albert%20Einstein' => 'Get a list of categories [[Albert Einstein]] belongs to',
+                       'api.php?action=query&generator=categories&titles=Albert%20Einstein&prop=info' => 'Get information about all categories used in the [[Albert Einstein]]',
                );
        }
 
index c273ad0..4b19b7e 100644 (file)
@@ -389,10 +389,8 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase {
 
        public function getExamples() {
                return array(
-                       'Get first 10 pages in [[Category:Physics]]:',
-                       '  api.php?action=query&list=categorymembers&cmtitle=Category:Physics',
-                       'Get page info about first 10 pages in [[Category:Physics]]:',
-                       '  api.php?action=query&generator=categorymembers&gcmtitle=Category:Physics&prop=info',
+                       'api.php?action=query&list=categorymembers&cmtitle=Category:Physics' => 'Get first 10 pages in [[Category:Physics]]',
+                       'api.php?action=query&generator=categorymembers&gcmtitle=Category:Physics&prop=info' => 'Get page info about first 10 pages in [[Category:Physics]]',
                );
        }
 
index 48da7dd..0a0cc93 100644 (file)
@@ -393,14 +393,14 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
 
        public function getExamples() {
                return array(
-                       'List the last deleted revisions of Main Page and Talk:Main Page, with content (mode 1):',
-                       '  api.php?action=query&list=deletedrevs&titles=Main%20Page|Talk:Main%20Page&drprop=user|comment|content',
-                       'List the last 50 deleted contributions by Bob (mode 2):',
-                       '  api.php?action=query&list=deletedrevs&druser=Bob&drlimit=50',
-                       'List the first 50 deleted revisions in the main namespace (mode 3):',
-                       '  api.php?action=query&list=deletedrevs&drdir=newer&drlimit=50',
-                       'List the first 50 deleted pages in the Talk namespace (mode 3):',
-                       '  api.php?action=query&list=deletedrevs&drdir=newer&drlimit=50&drnamespace=1&drunique=',
+                       'api.php?action=query&list=deletedrevs&titles=Main%20Page|Talk:Main%20Page&drprop=user|comment|content'
+                               => 'List the last deleted revisions of Main Page and Talk:Main Page, with content (mode 1)',
+                       'api.php?action=query&list=deletedrevs&druser=Bob&drlimit=50'
+                               => 'List the last 50 deleted contributions by Bob (mode 2)',
+                       'api.php?action=query&list=deletedrevs&drdir=newer&drlimit=50'
+                               => 'List the first 50 deleted revisions in the main namespace (mode 3)',
+                       'api.php?action=query&list=deletedrevs&drdir=newer&drlimit=50&drnamespace=1&drunique='
+                               => 'List the first 50 deleted pages in the Talk namespace (mode 3):',
                );
        }
 
index 7038fbc..a9fbc83 100644 (file)
@@ -145,8 +145,7 @@ class ApiQueryExternalLinks extends ApiQueryBase {
 
        public function getExamples() {
                return array(
-                       'Get a list of external links on the [[Main Page]]:',
-                       '  api.php?action=query&prop=extlinks&titles=Main%20Page',
+                       'api.php?action=query&prop=extlinks&titles=Main%20Page' => 'Get a list of external links on the [[Main Page]]',
                );
        }
 
index 17387c8..be995f3 100644 (file)
@@ -282,9 +282,10 @@ class ApiQueryFilearchive extends ApiQueryBase {
 
        public function getExamples() {
                return array(
-                       'Simple Use',
-                       ' Show a list of all deleted files',
-                       '  api.php?action=query&list=filearchive',
+                       'api.php?action=query&list=filearchive' => array(
+                               'Simple Use',
+                               'Show a list of all deleted files',
+                       ),
                );
        }
 
index 6e37d3e..13256ad 100644 (file)
@@ -178,8 +178,7 @@ class ApiQueryIWLinks extends ApiQueryBase {
 
        public function getExamples() {
                return array(
-                       'Get interwiki links from the [[Main Page]]:',
-                       '  api.php?action=query&prop=iwlinks&titles=Main%20Page',
+                       'api.php?action=query&prop=iwlinks&titles=Main%20Page' => 'Get interwiki links from the [[Main Page]]',
                );
        }
 
index ad1e8a6..c6b1005 100644 (file)
@@ -185,10 +185,8 @@ class ApiQueryImages extends ApiQueryGeneratorBase {
 
        public function getExamples() {
                return array(
-                       'Get a list of images used in the [[Main Page]]:',
-                       '  api.php?action=query&prop=images&titles=Main%20Page',
-                       'Get information about all images used in the [[Main Page]]:',
-                       '  api.php?action=query&generator=images&titles=Main%20Page&prop=info'
+                       'api.php?action=query&prop=images&titles=Main%20Page' => 'Get a list of images used in the [[Main Page]]',
+                       'api.php?action=query&generator=images&titles=Main%20Page&prop=info' => 'Get information about all images used in the [[Main Page]]',
                );
        }
 
index 9d220ff..fdba846 100644 (file)
@@ -171,8 +171,7 @@ class ApiQueryLangLinks extends ApiQueryBase {
 
        public function getExamples() {
                return array(
-                       'Get interlanguage links from the [[Main Page]]:',
-                       '  api.php?action=query&prop=langlinks&titles=Main%20Page&redirects=',
+                       'api.php?action=query&prop=langlinks&titles=Main%20Page&redirects=' => 'Get interlanguage links from the [[Main Page]]',
                );
        }
 
index 3e55400..43b0654 100644 (file)
@@ -231,13 +231,12 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
        }
 
        public function getExamples() {
+               $desc = $this->description;
+               $name = $this->getModuleName();
                return array(
-                       "Get {$this->description}s from the [[Main Page]]:",
-                       "  api.php?action=query&prop={$this->getModuleName()}&titles=Main%20Page",
-                       "Get information about the {$this->description} pages in the [[Main Page]]:",
-                       "  api.php?action=query&generator={$this->getModuleName()}&titles=Main%20Page&prop=info",
-                       "Get {$this->description}s from the Main Page in the User and Template namespaces:",
-                       "  api.php?action=query&prop={$this->getModuleName()}&titles=Main%20Page&{$this->prefix}namespace=2|10"
+                       "api.php?action=query&prop={$name}&titles=Main%20Page" => "Get {$desc}s from the [[Main Page]]:",
+                       "api.php?action=query&generator={$name}&titles=Main%20Page&prop=info" => "Get information about the {$desc} pages in the [[Main Page]]:",
+                       "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:",
                );
        }
 
index f8003a3..a89d501 100644 (file)
@@ -664,13 +664,13 @@ class ApiQueryRevisions extends ApiQueryBase {
 
        public function getExamples() {
                return array(
-                       'Get data with content for the last revision of titles "API" and "Main Page":',
+                       'Get data with content for the last revision of titles "API" and "Main Page"',
                        '  api.php?action=query&prop=revisions&titles=API|Main%20Page&rvprop=timestamp|user|comment|content',
-                       'Get last 5 revisions of the "Main Page":',
+                       'Get last 5 revisions of the "Main Page"',
                        '  api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment',
-                       'Get first 5 revisions of the "Main Page":',
+                       'Get first 5 revisions of the "Main Page"',
                        '  api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment&rvdir=newer',
-                       'Get first 5 revisions of the "Main Page" made after 2006-05-01:',
+                       'Get first 5 revisions of the "Main Page" made after 2006-05-01',
                        '  api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment&rvdir=newer&rvstart=20060501000000',
                        'Get first 5 revisions of the "Main Page" that were not made made by anonymous user "127.0.0.1"',
                        '  api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment&rvexcludeuser=127.0.0.1',
index 0ac7fb4..e8fc52a 100644 (file)
@@ -646,10 +646,10 @@ class ApiUpload extends ApiBase {
 
        public function getExamples() {
                return array(
-                       'Upload from a URL:',
-                       '    api.php?action=upload&filename=Wiki.png&url=http%3A//upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png',
-                       'Complete an upload that failed due to warnings:',
-                       '    api.php?action=upload&filename=Wiki.png&filekey=filekey&ignorewarnings=1',
+                       'api.php?action=upload&filename=Wiki.png&url=http%3A//upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png'
+                               => 'Upload from a URL',
+                       'api.php?action=upload&filename=Wiki.png&filekey=filekey&ignorewarnings=1'
+                               => 'Complete an upload that failed due to warnings',
                );
        }
 
index 839f2ea..4b448d6 100644 (file)
@@ -114,8 +114,8 @@ class ApiWatch extends ApiBase {
 
        public function getExamples() {
                return array(
-                       'api.php?action=watch&title=Main_Page',
-                       'api.php?action=watch&title=Main_Page&unwatch=',
+                       'api.php?action=watch&title=Main_Page' => 'Watch the page "Main Page"',
+                       'api.php?action=watch&title=Main_Page&unwatch=' => 'Unwatch the page "Main Page"',
                );
        }