From ad0d48d6bc8e572b1c634e35d5f9521d535f691e Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 20 Dec 2011 22:11:29 +0000 Subject: [PATCH] Revert r106439, r106441 - bad formatting mushing separate lines together --- RELEASE-NOTES-1.19 | 1 - includes/api/ApiBase.php | 32 +----------------------- includes/api/ApiParamInfo.php | 30 ++++------------------ 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/ApiWatch.php | 4 +-- 15 files changed, 57 insertions(+), 104 deletions(-) diff --git a/RELEASE-NOTES-1.19 b/RELEASE-NOTES-1.19 index 4f90d99f5d..0109c4e36d 100644 --- a/RELEASE-NOTES-1.19 +++ b/RELEASE-NOTES-1.19 @@ -218,7 +218,6 @@ 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 efbf1c0f11..e1ba493ff3 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -267,29 +267,7 @@ abstract class ApiBase extends ContextSource { $msg .= "Parameters:\n$paramsMsg"; } - $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 { - if ( is_array( $v ) ) { - $msg .= implode( "\n", array_map( array( $this, 'indentExampleText' ), $v ) ); - } else { - $msg .= " $v"; - } - $msg .= "\n $k"; - } - } - } - - $msg .= "\n"; + $msg .= $this->makeHelpArrayToString( $lnPrfx, "Example", $this->getExamples() ); $msg .= $this->makeHelpArrayToString( $lnPrfx, "Help page", $this->getHelpUrls() ); if ( $this->getMain()->getShowVersions() ) { @@ -313,14 +291,6 @@ 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 diff --git a/includes/api/ApiParamInfo.php b/includes/api/ApiParamInfo.php index c5d4cba6e0..972641d065 100644 --- a/includes/api/ApiParamInfo.php +++ b/includes/api/ApiParamInfo.php @@ -114,9 +114,8 @@ class ApiParamInfo extends ApiBase { $result = $this->getResult(); $retval['classname'] = get_class( $obj ); $retval['description'] = implode( "\n", (array)$obj->getFinalDescription() ); - - $retval['examples'] = ''; - + $examples = (array)$obj->getExamples(); + $retval['examples'] = implode( "\n", $examples ); $retval['version'] = implode( "\n", (array)$obj->getVersion() ); $retval['prefix'] = $obj->getModulePrefix(); @@ -144,28 +143,9 @@ class ApiParamInfo extends ApiBase { } $result->setIndexedTagName( $retval['helpurls'], 'helpurl' ); - $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; - } + $retval['allexamples'] = $examples; + if ( isset( $retval['allexamples'][0] ) && $retval['allexamples'][0] === false ) { + $retval['allexamples'] = array(); } $result->setIndexedTagName( $retval['allexamples'], 'example' ); diff --git a/includes/api/ApiQueryAllimages.php b/includes/api/ApiQueryAllimages.php index ca344f7337..c39f93a18e 100644 --- a/includes/api/ApiQueryAllimages.php +++ b/includes/api/ApiQueryAllimages.php @@ -246,14 +246,12 @@ class ApiQueryAllimages extends ApiQueryGeneratorBase { public function getExamples() { return array( - '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"', - ), + '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', ); } diff --git a/includes/api/ApiQueryAllpages.php b/includes/api/ApiQueryAllpages.php index e003ee9115..0556a5093a 100644 --- a/includes/api/ApiQueryAllpages.php +++ b/includes/api/ApiQueryAllpages.php @@ -309,17 +309,14 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase { public function getExamples() { return array( - '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"', - ) + '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' ); } diff --git a/includes/api/ApiQueryCategories.php b/includes/api/ApiQueryCategories.php index 16f73fdc3c..9335a96ff3 100644 --- a/includes/api/ApiQueryCategories.php +++ b/includes/api/ApiQueryCategories.php @@ -251,8 +251,10 @@ class ApiQueryCategories extends ApiQueryGeneratorBase { public function getExamples() { return array( - '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]]:', + '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' ); } diff --git a/includes/api/ApiQueryCategoryMembers.php b/includes/api/ApiQueryCategoryMembers.php index fe86a2fca2..c273ad0575 100644 --- a/includes/api/ApiQueryCategoryMembers.php +++ b/includes/api/ApiQueryCategoryMembers.php @@ -389,8 +389,10 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { public function getExamples() { return array( - '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]]:', + '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', ); } diff --git a/includes/api/ApiQueryDeletedrevs.php b/includes/api/ApiQueryDeletedrevs.php index 3be0a7ac64..48da7dd702 100644 --- a/includes/api/ApiQueryDeletedrevs.php +++ b/includes/api/ApiQueryDeletedrevs.php @@ -393,14 +393,14 @@ class ApiQueryDeletedrevs extends ApiQueryBase { public function getExamples() { return array( - '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):', + '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=', ); } diff --git a/includes/api/ApiQueryExternalLinks.php b/includes/api/ApiQueryExternalLinks.php index 42281e87cb..7038fbc3ca 100644 --- a/includes/api/ApiQueryExternalLinks.php +++ b/includes/api/ApiQueryExternalLinks.php @@ -145,7 +145,8 @@ class ApiQueryExternalLinks extends ApiQueryBase { public function getExamples() { return array( - 'api.php?action=query&prop=extlinks&titles=Main%20Page' => 'Get a list of external links on the [[Main Page]]:', + 'Get a list of external links on the [[Main Page]]:', + ' api.php?action=query&prop=extlinks&titles=Main%20Page', ); } diff --git a/includes/api/ApiQueryFilearchive.php b/includes/api/ApiQueryFilearchive.php index be995f3086..17387c8786 100644 --- a/includes/api/ApiQueryFilearchive.php +++ b/includes/api/ApiQueryFilearchive.php @@ -282,10 +282,9 @@ class ApiQueryFilearchive extends ApiQueryBase { public function getExamples() { return array( - 'api.php?action=query&list=filearchive' => array( - 'Simple Use', - 'Show a list of all deleted files', - ), + 'Simple Use', + ' Show a list of all deleted files', + ' api.php?action=query&list=filearchive', ); } diff --git a/includes/api/ApiQueryIWLinks.php b/includes/api/ApiQueryIWLinks.php index be83db89e8..6e37d3e908 100644 --- a/includes/api/ApiQueryIWLinks.php +++ b/includes/api/ApiQueryIWLinks.php @@ -178,7 +178,8 @@ class ApiQueryIWLinks extends ApiQueryBase { public function getExamples() { return array( - 'api.php?action=query&prop=iwlinks&titles=Main%20Page' => 'Get interwiki links from the [[Main Page]]:', + 'Get interwiki links from the [[Main Page]]:', + ' api.php?action=query&prop=iwlinks&titles=Main%20Page', ); } diff --git a/includes/api/ApiQueryImages.php b/includes/api/ApiQueryImages.php index a9cf0b6ea5..ad1e8a6c5c 100644 --- a/includes/api/ApiQueryImages.php +++ b/includes/api/ApiQueryImages.php @@ -185,8 +185,10 @@ class ApiQueryImages extends ApiQueryGeneratorBase { public function getExamples() { return array( - '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]]:', + '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' ); } diff --git a/includes/api/ApiQueryLangLinks.php b/includes/api/ApiQueryLangLinks.php index 24258363e7..9d220ffa8a 100644 --- a/includes/api/ApiQueryLangLinks.php +++ b/includes/api/ApiQueryLangLinks.php @@ -171,7 +171,8 @@ class ApiQueryLangLinks extends ApiQueryBase { public function getExamples() { return array( - 'api.php?action=query&prop=langlinks&titles=Main%20Page&redirects=' => 'Get interlanguage links from the [[Main Page]]:', + 'Get interlanguage links from the [[Main Page]]:', + ' api.php?action=query&prop=langlinks&titles=Main%20Page&redirects=', ); } diff --git a/includes/api/ApiQueryLinks.php b/includes/api/ApiQueryLinks.php index 43b06543fd..3e55400f2d 100644 --- a/includes/api/ApiQueryLinks.php +++ b/includes/api/ApiQueryLinks.php @@ -231,12 +231,13 @@ class ApiQueryLinks extends ApiQueryGeneratorBase { } public function getExamples() { - $desc = $this->description; - $name = $this->getModuleName(); return array( - "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:", + "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" ); } diff --git a/includes/api/ApiWatch.php b/includes/api/ApiWatch.php index 4b448d6de2..839f2ea576 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' => 'Watch the page "Main Page"', - 'api.php?action=watch&title=Main_Page&unwatch=' => 'Unwatch the page "Main Page"', + 'api.php?action=watch&title=Main_Page', + 'api.php?action=watch&title=Main_Page&unwatch=', ); } -- 2.20.1