From 6115b93df8e03951cbbcd894ec865b6742786142 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Tue, 27 Dec 2011 16:22:35 +0000 Subject: [PATCH] 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 --- RELEASE-NOTES-1.19 | 1 + includes/api/ApiBase.php | 55 ++++++++++++++++++------ includes/api/ApiComparePages.php | 2 +- includes/api/ApiDelete.php | 4 +- includes/api/ApiEditPage.php | 14 +++--- includes/api/ApiEmailUser.php | 2 +- includes/api/ApiFileRevert.php | 4 +- includes/api/ApiFormatBase.php | 5 ++- includes/api/ApiHelp.php | 15 +++---- includes/api/ApiImport.php | 4 +- includes/api/ApiLogout.php | 2 +- includes/api/ApiParamInfo.php | 30 ++++++++++--- includes/api/ApiPurge.php | 2 +- includes/api/ApiQueryAllimages.php | 14 +++--- includes/api/ApiQueryAllpages.php | 19 ++++---- includes/api/ApiQueryCategories.php | 6 +-- includes/api/ApiQueryCategoryMembers.php | 6 +-- includes/api/ApiQueryDeletedrevs.php | 16 +++---- includes/api/ApiQueryExternalLinks.php | 3 +- includes/api/ApiQueryFilearchive.php | 7 +-- includes/api/ApiQueryIWLinks.php | 3 +- includes/api/ApiQueryImages.php | 6 +-- includes/api/ApiQueryLangLinks.php | 3 +- includes/api/ApiQueryLinks.php | 11 +++-- includes/api/ApiQueryRevisions.php | 8 ++-- includes/api/ApiUpload.php | 8 ++-- includes/api/ApiWatch.php | 4 +- 27 files changed, 151 insertions(+), 103 deletions(-) diff --git a/RELEASE-NOTES-1.19 b/RELEASE-NOTES-1.19 index 182ef6d934..72cefb8a78 100644 --- a/RELEASE-NOTES-1.19 +++ b/RELEASE-NOTES-1.19 @@ -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 === diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index e1ba493ff3..efca658188 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -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 ) ); } diff --git a/includes/api/ApiComparePages.php b/includes/api/ApiComparePages.php index 6c22f18d8f..7328902436 100644 --- a/includes/api/ApiComparePages.php +++ b/includes/api/ApiComparePages.php @@ -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', ); } diff --git a/includes/api/ApiDelete.php b/includes/api/ApiDelete.php index 4ffa66cc55..9d850cc8a1 100644 --- a/includes/api/ApiDelete.php +++ b/includes/api/ApiDelete.php @@ -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"', ); } diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php index f45f9fde6f..216468cc99 100644 --- a/includes/api/ApiEditPage.php +++ b/includes/api/ApiEditPage.php @@ -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)', ); } diff --git a/includes/api/ApiEmailUser.php b/includes/api/ApiEmailUser.php index 5a01ae9776..004ca73601 100644 --- a/includes/api/ApiEmailUser.php +++ b/includes/api/ApiEmailUser.php @@ -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"', ); } diff --git a/includes/api/ApiFileRevert.php b/includes/api/ApiFileRevert.php index 0a21680954..7ef1da0af1 100644 --- a/includes/api/ApiFileRevert.php +++ b/includes/api/ApiFileRevert.php @@ -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', ); } diff --git a/includes/api/ApiFormatBase.php b/includes/api/ApiFormatBase.php index a0138ac366..7a53b64105 100644 --- a/includes/api/ApiFormatBase.php +++ b/includes/api/ApiFormatBase.php @@ -286,7 +286,10 @@ See complete documentation, 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() { diff --git a/includes/api/ApiHelp.php b/includes/api/ApiHelp.php index d94132a59d..97da786b1e 100644 --- a/includes/api/ApiHelp.php +++ b/includes/api/ApiHelp.php @@ -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', ); } diff --git a/includes/api/ApiImport.php b/includes/api/ApiImport.php index d38aaf8d5a..ade9f1f3fd 100644 --- a/includes/api/ApiImport.php +++ b/includes/api/ApiImport.php @@ -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', ); } diff --git a/includes/api/ApiLogout.php b/includes/api/ApiLogout.php index f530e87522..0e4ae5378f 100644 --- a/includes/api/ApiLogout.php +++ b/includes/api/ApiLogout.php @@ -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', ); } diff --git a/includes/api/ApiParamInfo.php b/includes/api/ApiParamInfo.php index 972641d065..c5d4cba6e0 100644 --- a/includes/api/ApiParamInfo.php +++ b/includes/api/ApiParamInfo.php @@ -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' ); diff --git a/includes/api/ApiPurge.php b/includes/api/ApiPurge.php index d2e0777744..6bf5cb8f25 100644 --- a/includes/api/ApiPurge.php +++ b/includes/api/ApiPurge.php @@ -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', ); } diff --git a/includes/api/ApiQueryAllimages.php b/includes/api/ApiQueryAllimages.php index c39f93a18e..ca344f7337 100644 --- a/includes/api/ApiQueryAllimages.php +++ b/includes/api/ApiQueryAllimages.php @@ -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"', + ), ); } diff --git a/includes/api/ApiQueryAllpages.php b/includes/api/ApiQueryAllpages.php index 0556a5093a..e003ee9115 100644 --- a/includes/api/ApiQueryAllpages.php +++ b/includes/api/ApiQueryAllpages.php @@ -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"', + ) ); } diff --git a/includes/api/ApiQueryCategories.php b/includes/api/ApiQueryCategories.php index 9335a96ff3..4e7e1b3e2c 100644 --- a/includes/api/ApiQueryCategories.php +++ b/includes/api/ApiQueryCategories.php @@ -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]]', ); } diff --git a/includes/api/ApiQueryCategoryMembers.php b/includes/api/ApiQueryCategoryMembers.php index c273ad0575..4b19b7e86e 100644 --- a/includes/api/ApiQueryCategoryMembers.php +++ b/includes/api/ApiQueryCategoryMembers.php @@ -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]]', ); } diff --git a/includes/api/ApiQueryDeletedrevs.php b/includes/api/ApiQueryDeletedrevs.php index 48da7dd702..0a0cc93d01 100644 --- a/includes/api/ApiQueryDeletedrevs.php +++ b/includes/api/ApiQueryDeletedrevs.php @@ -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):', ); } diff --git a/includes/api/ApiQueryExternalLinks.php b/includes/api/ApiQueryExternalLinks.php index 7038fbc3ca..a9fbc839d9 100644 --- a/includes/api/ApiQueryExternalLinks.php +++ b/includes/api/ApiQueryExternalLinks.php @@ -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]]', ); } diff --git a/includes/api/ApiQueryFilearchive.php b/includes/api/ApiQueryFilearchive.php index 17387c8786..be995f3086 100644 --- a/includes/api/ApiQueryFilearchive.php +++ b/includes/api/ApiQueryFilearchive.php @@ -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', + ), ); } diff --git a/includes/api/ApiQueryIWLinks.php b/includes/api/ApiQueryIWLinks.php index 6e37d3e908..13256ad89f 100644 --- a/includes/api/ApiQueryIWLinks.php +++ b/includes/api/ApiQueryIWLinks.php @@ -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]]', ); } diff --git a/includes/api/ApiQueryImages.php b/includes/api/ApiQueryImages.php index ad1e8a6c5c..c6b1005f70 100644 --- a/includes/api/ApiQueryImages.php +++ b/includes/api/ApiQueryImages.php @@ -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]]', ); } diff --git a/includes/api/ApiQueryLangLinks.php b/includes/api/ApiQueryLangLinks.php index 9d220ffa8a..fdba8465e3 100644 --- a/includes/api/ApiQueryLangLinks.php +++ b/includes/api/ApiQueryLangLinks.php @@ -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]]', ); } diff --git a/includes/api/ApiQueryLinks.php b/includes/api/ApiQueryLinks.php index 3e55400f2d..43b06543fd 100644 --- a/includes/api/ApiQueryLinks.php +++ b/includes/api/ApiQueryLinks.php @@ -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:", ); } diff --git a/includes/api/ApiQueryRevisions.php b/includes/api/ApiQueryRevisions.php index f8003a3b32..a89d501979 100644 --- a/includes/api/ApiQueryRevisions.php +++ b/includes/api/ApiQueryRevisions.php @@ -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', diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php index 0ac7fb42a6..e8fc52ade1 100644 --- a/includes/api/ApiUpload.php +++ b/includes/api/ApiUpload.php @@ -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', ); } diff --git a/includes/api/ApiWatch.php b/includes/api/ApiWatch.php index 839f2ea576..4b448d6de2 100644 --- a/includes/api/ApiWatch.php +++ b/includes/api/ApiWatch.php @@ -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"', ); } -- 2.20.1