* Default output format for the API is now jsonfm.
* Simplified continuation will return a "batchcomplete" property in the result
when a batch of pages is complete.
+* Pretty-printed HTML output now has nicer formatting and (if available)
+ better syntax highlighting.
=== Action API internal changes in 1.25 ===
* ApiHelp has been rewritten to support i18n and paginated HTML output.
* Api formatters will no longer be asked to display the help screen on errors.
* ApiMain::getCredits() was removed. The credits are available in the
'api-credits' i18n message.
+* ApiFormatBase has been changed to support i18n and syntax highlighting via
+ extensions with the new 'ApiFormatHighlight' hook. Core syntax highlighting
+ has been removed.
+* ApiFormatBase now always buffers. Output is done when
+ ApiFormatBase::closePrinter is called.
* The following methods have been deprecated and may be removed in a future
release:
* ApiBase::getDescription
* ApiFormatBase::setUnescapeAmps
* ApiFormatBase::getWantsHelp
* ApiFormatBase::setHelp
+ * ApiFormatBase::formatHTML
+ * ApiFormatBase::setBufferResult
+ * ApiFormatBase::getDescription
* ApiMain::setHelp
* ApiMain::reallyMakeHelpMsg
* ApiMain::makeHelpMsgHeader
$text : the new text of the article (has yet to be saved)
&$resultArr : data in this array will be added to the API result
+'ApiFormatHighlight': Use to syntax-highlight API pretty-printed output. When
+highlighting, add output to $context->getOutput() and return false.
+$context: An IContextSource.
+$text: Text to be highlighted.
+$mime: MIME type of $text.
+$format: API format code for $text.
+
'APIGetAllowedParams': Use this hook to modify a module's parameters.
&$module: ApiBase Module object
&$params: Array of parameters
* @ingroup API
*/
abstract class ApiFormatBase extends ApiBase {
- private $mIsHtml, $mFormat, $mUnescapeAmps, $mHelp, $mCleared;
- private $mBufferResult = false, $mBuffer, $mDisabled = false;
+ private $mIsHtml, $mFormat, $mUnescapeAmps, $mHelp;
+ private $mBuffer, $mDisabled = false;
/**
* If $format ends with 'fm', pretty-print the output in HTML.
$this->mFormat = $format;
}
$this->mFormat = strtoupper( $this->mFormat );
- $this->mCleared = false;
}
/**
* Overriding class returns the MIME type that should be sent to the client.
- * This method is not called if getIsHtml() returns true.
+ *
+ * When getIsHtml() returns true, the return value here is used for syntax
+ * highlighting but the client sees text/html.
+ *
* @return string
*/
abstract public function getMimeType();
return $this->mFormat;
}
- /**
- * Specify whether or not sequences like " should be unescaped
- * to " . This should only be set to true for the help message
- * when rendered in the default (xmlfm) format. This is a temporary
- * special-case fix that should be removed once the help has been
- * reworked to use a fully HTML interface.
- *
- * @deprecated since 1.25
- * @param bool $b Whether or not ampersands should be escaped.
- */
- public function setUnescapeAmps( $b ) {
- wfDeprecated( __METHOD__, '1.25' );
- $this->mUnescapeAmps = $b;
- }
-
/**
* Returns true when the HTML pretty-printer should be used.
* The default implementation assumes that formats ending with 'fm'
}
/**
- * Whether this formatter can format the help message in a nice way.
- * By default, this returns the same as getIsHtml().
- * When action=help is set explicitly, the help will always be shown
- * @deprecated since 1.25
- * @return bool
- */
- public function getWantsHelp() {
- wfDeprecated( __METHOD__, '1.25' );
- return $this->getIsHtml();
- }
-
- /**
- * Disable the formatter completely. This causes calls to initPrinter(),
- * printText() and closePrinter() to be ignored.
+ * Disable the formatter.
+ *
+ * This causes calls to initPrinter() and closePrinter() to be ignored.
*/
public function disable() {
$this->mDisabled = true;
}
+ /**
+ * Whether the printer is disabled
+ * @return bool
+ */
public function isDisabled() {
return $this->mDisabled;
}
/**
- * Whether this formatter can handle printing API errors. If this returns
- * false, then on API errors the default printer will be instantiated.
+ * Whether this formatter can handle printing API errors.
+ *
+ * If this returns false, then on API errors the default printer will be
+ * instantiated.
* @since 1.23
* @return bool
*/
}
/**
- * Initialize the printer function and prepare the output headers, etc.
- * This method must be the first outputting method during execution.
- * A human-targeted notice about available formats is printed for the HTML-based output,
- * except for help screens (caused by either an error in the API parameters,
- * the calling of action=help, or requesting the root script api.php).
+ * Initialize the printer function and prepare the output headers.
* @param bool $unused Always false since 1.25
*/
function initPrinter( $unused ) {
if ( $this->mDisabled ) {
return;
}
- $isHtml = $this->getIsHtml();
- $mime = $isHtml ? 'text/html' : $this->getMimeType();
- $script = wfScript( 'api' );
+
+ $mime = $this->getIsHtml() ? 'text/html' : $this->getMimeType();
// Some printers (ex. Feed) do their own header settings,
// in which case $mime will be set to null
- if ( is_null( $mime ) ) {
+ if ( $mime === null ) {
return; // skip any initialization
}
if ( $apiFrameOptions ) {
$this->getMain()->getRequest()->response()->header( "X-Frame-Options: $apiFrameOptions" );
}
-
- if ( $isHtml ) {
-?>
-<!DOCTYPE HTML>
-<html>
-<head>
-<?php
- if ( $this->mUnescapeAmps ) {
-?> <title>MediaWiki API</title>
-<?php
- } else {
-?> <title>MediaWiki API Result</title>
-<?php
- }
-// @codingStandardsIgnoreStart Exclude long line from CodeSniffer checks
-?>
-</head>
-<body>
-<br />
-<small>
-You are looking at the HTML representation of the <?php echo $this->mFormat; ?> format.<br />
-HTML is good for debugging, but is unsuitable for application use.<br />
-Specify the format parameter to change the output format.<br />
-To see the non HTML representation of the <?php echo $this->mFormat; ?> format, set format=<?php echo strtolower( $this->mFormat ); ?>.<br />
-See the <a href='https://www.mediawiki.org/wiki/API'>complete documentation</a>, or
-<a href='<?php echo $script; ?>'>API help</a> for more information.
-</small>
-<pre style='white-space: pre-wrap;'>
-<?php
-// @codingStandardsIgnoreEnd
- }
}
/**
- * Finish printing. Closes HTML tags.
+ * Finish printing and output buffered data.
*/
public function closePrinter() {
if ( $this->mDisabled ) {
return;
}
- if ( $this->getIsHtml() ) {
-?>
-</pre>
-</body>
-</html>
-<?php
+ $mime = $this->getMimeType();
+ if ( $this->getIsHtml() && $mime !== null ) {
+ $format = $this->getFormat();
+ $result = $this->getBuffer();
+
+ $context = new DerivativeContext( $this->getMain() );
+ $context->setUser( new User ); // anon to avoid caching issues
+ $context->setSkin( SkinFactory::getDefaultInstance()->makeSkin( 'apioutput' ) );
+ $out = new OutputPage( $context );
+ $out->addModules( 'mediawiki.apipretty' );
+ $out->setPageTitle( $context->msg( 'api-format-title' ) );
+ $context->setOutput( $out );
+
+ $header = $context->msg( 'api-format-prettyprint-header' )
+ ->params( $format, strtolower( $format ) )
+ ->parseAsBlock();
+ $out->addHTML(
+ Html::rawElement( 'div', array( 'class' => 'api-pretty-header' ),
+ ApiHelp::fixHelpLinks( $header )
+ )
+ );
+
+ if ( wfRunHooks( 'ApiFormatHighlight', array( $context, $result, $mime, $format ) ) ) {
+ $out->addHTML(
+ Html::element( 'pre', array( 'class' => 'api-pretty-content' ), $result )
+ );
+ }
+
+ $out->output();
+ } else {
+ // For non-HTML output, clear all errors that might have been
+ // displayed if display_errors=On
+ ob_clean();
+
+ echo $this->getBuffer();
}
}
/**
- * The main format printing function. Call it to output the result
- * string to the user. This function will automatically output HTML
- * when format name ends in 'fm'.
+ * Append text to the output buffer.
* @param string $text
*/
public function printText( $text ) {
- if ( $this->mDisabled ) {
- return;
- }
- if ( $this->mBufferResult ) {
- $this->mBuffer = $text;
- } elseif ( $this->getIsHtml() ) {
- echo $this->formatHTML( $text );
- } else {
- // For non-HTML output, clear all errors that might have been
- // displayed if display_errors=On
- // Do this only once, of course
- if ( !$this->mCleared ) {
- ob_clean();
- $this->mCleared = true;
- }
- echo $text;
- }
+ $this->mBuffer .= $text;
}
/**
return $this->mBuffer;
}
+ public function getExamplesMessages() {
+ return array(
+ 'action=query&meta=siteinfo&siprop=namespaces&format=' . $this->getModuleName()
+ => array( 'apihelp-format-example-generic', $this->getFormat() )
+ );
+ }
+
+ public function getHelpUrls() {
+ return 'https://www.mediawiki.org/wiki/API:Data_formats';
+ }
+
/**
- * Set the flag to buffer the result instead of printing it.
- * @param bool $value
+ * To avoid code duplication with the deprecation of dbg, dump, txt, wddx,
+ * and yaml, this method is added to do the necessary work. It should be
+ * removed when those deprecated formats are removed.
*/
- public function setBufferResult( $value ) {
- $this->mBufferResult = $value;
+ protected function markDeprecated() {
+ $fm = $this->getIsHtml() ? 'fm' : '';
+ $name = $this->getModuleName();
+ $this->logFeatureUsage( "format=$name" );
+ $this->setWarning( "format=$name has been deprecated. Please use format=json$fm instead." );
+ }
+
+ /************************************************************************//**
+ * @name Deprecated
+ * @{
+ */
+
+ /**
+ * Specify whether or not sequences like &quot; should be unescaped
+ * to " . This should only be set to true for the help message
+ * when rendered in the default (xmlfm) format. This is a temporary
+ * special-case fix that should be removed once the help has been
+ * reworked to use a fully HTML interface.
+ *
+ * @deprecated since 1.25
+ * @param bool $b Whether or not ampersands should be escaped.
+ */
+ public function setUnescapeAmps( $b ) {
+ wfDeprecated( __METHOD__, '1.25' );
+ $this->mUnescapeAmps = $b;
+ }
+
+ /**
+ * Whether this formatter can format the help message in a nice way.
+ * By default, this returns the same as getIsHtml().
+ * When action=help is set explicitly, the help will always be shown
+ * @deprecated since 1.25
+ * @return bool
+ */
+ public function getWantsHelp() {
+ wfDeprecated( __METHOD__, '1.25' );
+ return $this->getIsHtml();
}
/**
/**
* Pretty-print various elements in HTML format, such as xml tags and
* URLs. This method also escapes characters like <
+ * @deprecated since 1.25
* @param string $text
* @return string
*/
protected function formatHTML( $text ) {
+ wfDeprecated( __METHOD__, '1.25' );
+
// Escape everything first for full coverage
$text = htmlspecialchars( $text );
return $text;
}
- public function getExamples() {
- return array(
- 'api.php?action=query&meta=siteinfo&siprop=namespaces&format=' . $this->getModuleName()
- => "Format the query result in the {$this->getModuleName()} format",
- );
- }
-
- public function getHelpUrls() {
- return 'https://www.mediawiki.org/wiki/API:Data_formats';
- }
-
+ /**
+ * @see ApiBase::getDescription
+ * @deprecated since 1.25
+ */
public function getDescription() {
return $this->getIsHtml() ? ' (pretty-print in HTML)' : '';
}
/**
- * To avoid code duplication with the deprecation of dbg, dump, txt, wddx,
- * and yaml, this method is added to do the necessary work. It should be
- * removed when those deprecated formats are removed.
+ * Set the flag to buffer the result instead of printing it.
+ * @deprecated since 1.25, output is always buffered
+ * @param bool $value
*/
- protected function markDeprecated() {
- $fm = $this->getIsHtml() ? 'fm' : '';
- $name = $this->getModuleName();
- $this->logFeatureUsage( "format=$name" );
- $this->setWarning( "format=$name has been deprecated. Please use format=json$fm instead." );
+ public function setBufferResult( $value ) {
}
+
+ /**@}*/
}
+
+/**
+ * For really cool vim folding this needs to be at the end:
+ * vim: foldmarker=@{,@} foldmethod=marker
+ */
$this->printText( var_export( $this->getResultData(), true ) );
}
- public function getDescription() {
- return 'Output data in PHP\'s var_export() format' . parent::getDescription();
- }
-
public function isDeprecated() {
return true;
}
$this->printText( $result );
}
- public function getDescription() {
- return 'Output data in PHP\'s var_dump() format' . parent::getDescription();
- }
-
public function isDeprecated() {
return true;
}
public function getAllowedParams() {
return array(
- 'callback' => null,
- 'utf8' => false,
+ 'callback' => array(
+ ApiBase::PARAM_HELP_MSG => 'apihelp-json-param-callback',
+ ),
+ 'utf8' => array(
+ ApiBase::PARAM_DFLT => false,
+ ApiBase::PARAM_HELP_MSG => 'apihelp-json-param-utf8',
+ ),
);
}
-
- public function getParamDescription() {
- return array(
- 'callback' => 'If specified, wraps the output into a given function ' .
- 'call. For safety, all user-specific data will be restricted.',
- 'utf8' => 'If specified, encodes most (but not all) non-ASCII ' .
- 'characters as UTF-8 instead of replacing them with hexadecimal escape sequences.',
- );
- }
-
- public function getDescription() {
- if ( $this->mIsRaw ) {
- return 'Output data with the debugging elements in JSON format' . parent::getDescription();
- }
-
- return 'Output data in JSON format' . parent::getDescription();
- }
}
public function execute() {
}
-
- public function getDescription() {
- return 'Output nothing' . parent::getDescription();
- }
}
public function execute() {
$this->printText( serialize( $this->getResultData() ) );
}
-
- public function getDescription() {
- return 'Output data in serialized PHP format' . parent::getDescription();
- }
}
*/
class ApiFormatRaw extends ApiFormatBase {
+ private $errorFallback;
+
/**
* @param ApiMain $main
* @param ApiFormatBase $errorFallback Object to fall back on for errors
*/
public function __construct( ApiMain $main, ApiFormatBase $errorFallback ) {
parent::__construct( $main, 'raw' );
- $this->mErrorFallback = $errorFallback;
+ $this->errorFallback = $errorFallback;
}
public function getMimeType() {
$data = $this->getResultData();
if ( isset( $data['error'] ) ) {
- return $this->mErrorFallback->getMimeType();
+ return $this->errorFallback->getMimeType();
}
if ( !isset( $data['mime'] ) ) {
return $data['mime'];
}
- public function execute() {
+ public function initPrinter( $unused ) {
+ $data = $this->getResultData();
+ if ( isset( $data['error'] ) ) {
+ $this->errorFallback->initPrinter( $unused );
+ } else {
+ parent::initPrinter( $unused );
+ }
+ }
+
+ public function closePrinter() {
$data = $this->getResultData();
if ( isset( $data['error'] ) ) {
- $this->mErrorFallback->execute();
+ $this->errorFallback->closePrinter();
+ } else {
+ parent::closePrinter();
+ }
+ }
+ public function execute() {
+ $data = $this->getResultData();
+ if ( isset( $data['error'] ) ) {
+ $this->errorFallback->execute();
return;
}
$this->printText( print_r( $this->getResultData(), true ) );
}
- public function getDescription() {
- return 'Output data in PHP\'s print_r() format' . parent::getDescription();
- }
-
public function isDeprecated() {
return true;
}
}
}
- public function getDescription() {
- return 'Output data in WDDX format' . parent::getDescription();
- }
-
public function isDeprecated() {
return true;
}
public function getAllowedParams() {
return array(
- 'xslt' => null,
- 'includexmlnamespace' => false,
+ 'xslt' => array(
+ ApiBase::PARAM_HELP_MSG => 'apihelp-json-param-callback',
+ ),
+ 'includexmlnamespace' => array(
+ ApiBase::PARAM_DFLT => false,
+ ApiBase::PARAM_HELP_MSG => 'apihelp-json-param-callback',
+ ),
);
}
-
- public function getParamDescription() {
- return array(
- 'xslt' => 'If specified, adds <xslt> as stylesheet. This should be a wiki page '
- . 'in the MediaWiki namespace whose page name ends with ".xsl"',
- 'includexmlnamespace' => 'If specified, adds an XML namespace'
- );
- }
-
- public function getDescription() {
- return 'Output data in XML format' . parent::getDescription();
- }
}
parent::execute();
}
- public function getDescription() {
- return 'Output data in YAML format' . ApiFormatBase::getDescription();
- }
-
public function isDeprecated() {
return true;
}
}
// Get the help
- $context = new RequestContext;
+ $context = new DerivativeContext( $this->getMain()->getContext() );
$context->setUser( new User ); // anon to avoid caching issues
$context->setSkin( SkinFactory::getDefaultInstance()->makeSkin( 'apioutput' ) );
$context->setLanguage( $this->getMain()->getLanguage() );
+ $out = new OutputPage( $context );
+ $context->setOutput( $out );
self::getHelp( $context, $modules, $params );
// avoid sending public cache headers for errors.
$this->sendCacheHeaders();
- if ( $this->mPrinter->getIsHtml() && !$this->mPrinter->isDisabled() ) {
- echo wfReportTime();
- }
-
ob_end_flush();
}
"apihelp-main-param-origin": "When accessing the API using a cross-domain AJAX request (CORS), set this to the originating domain. This must be included in any pre-flight request, and therefore must be part of the request URI (not the POST body). This must match one of the origins in the Origin: header exactly, so it has to be set to something like http://en.wikipedia.org or https://meta.wikimedia.org. If this parameter does not match the Origin: header, a 403 response will be returned. If this parameter matches the Origin: header and the origin is whitelisted, an Access-Control-Allow-Origin header will be set.",
"apihelp-main-param-uselang": "Language to use for message translations. A list of codes may be fetched from [[Special:ApiHelp/query+siteinfo|action=query&meta=siteinfo&siprop=languages]], or specify \"user\" to use the current user's language preference.",
+ "apihelp-format-example-generic": "Format the query result in the $1 format",
+ "apihelp-dbg-description": "Output data in PHP's var_export() format.",
+ "apihelp-dbgfm-description": "Output data in PHP's var_export() format (pretty-print in HTML).",
+ "apihelp-dump-description": "Output data in PHP's var_dump() format.",
+ "apihelp-dumpfm-description": "Output data in PHP's var_dump() format (pretty-print in HTML).",
+ "apihelp-json-description": "Output data in JSON format.",
+ "apihelp-json-param-callback": "If specified, wraps the output into a given function call. For safety, all user-specific data will be restricted.",
+ "apihelp-json-param-utf8": "If specified, encodes most (but not all) non-ASCII characters as UTF-8 instead of replacing them with hexadecimal escape sequences.",
+ "apihelp-jsonfm-description": "Output data in JSON format (pretty-print in HTML).",
+ "apihelp-none-description": "Output nothing.",
+ "apihelp-php-description": "Output data in serialized PHP format.",
+ "apihelp-phpfm-description": "Output data in serialized PHP format (pretty-print in HTML).",
+ "apihelp-rawfm-description": "Output data with the debugging elements in JSON format (pretty-print in HTML).",
+ "apihelp-txt-description": "Output data in PHP's print_r() format.",
+ "apihelp-txtfm-description": "Output data in PHP's print_r() format (pretty-print in HTML).",
+ "apihelp-wddx-description": "Output data in WDDX format.",
+ "apihelp-wddxfm-description": "Output data in WDDX format (pretty-print in HTML).",
+ "apihelp-xml-description": "Output data in XML format.",
+ "apihelp-xml-param-xslt": "If specified, adds <xslt> as stylesheet. This should be a wiki page in the MediaWiki namespace whose page name ends with \".xsl\".",
+ "apihelp-xml-param-includexmlnamespac": "If specified, adds an XML namespace.",
+ "apihelp-xmlfm-description": "Output data in XML format (pretty-print in HTML).",
+ "apihelp-yaml-description": "Output data in YAML format.",
+ "apihelp-yamlfm-description": "Output data in YAML format (pretty-print in HTML).",
+
"apihelp-help-description": "Display help for the specified modules.",
"apihelp-help-param-modules": "Modules to display help for (values of the action= and format= parameters, or \"main\"). Can specify submodules with a \"+\".",
"apihelp-help-param-submodules": "Include help for submodules of the named module.",
"apihelp-help-example-help": "Help for the help module itself",
"apihelp-help-example-query": "Help for two query submodules",
+ "api-format-title": "MediaWiki API result",
+ "api-format-prettyprint-header": "You are looking at the HTML representation of the $1 format. HTML is good for debugging, but is unsuitable for application use.\n\nSpecify the format parameter to change the output format. To see the non-HTML representation of the $1 format, set format=$2.\n\nSee the [https://www.mediawiki.org/wiki/API complete documentation], or [[Special:ApiHelp/main|API help]] for more information.",
+
"api-help-title": "MediaWiki API help",
"api-help-lead": "This is an auto-generated MediaWiki API documentation page.\n\nDocumentation and examples: https://www.mediawiki.org/wiki/API",
"api-help-main-header": "Main module",
"apihelp-main-param-origin": "{{doc-apihelp-param|main|origin}}",
"apihelp-main-param-uselang": "{{doc-apihelp-param|main|uselang}}",
+ "apihelp-format-example-generic": "{{doc-apihelp-example|format|params=* $1 - Format name|paramstart=2|noseealso=1}}",
+ "apihelp-dbg-description": "{{doc-apihelp-description|dbg|seealso=* {{msg-mw|apihelp-dbgfm-description}}}}",
+ "apihelp-dbgfm-description": "{{doc-apihelp-description|dbgfm|seealso=* {{msg-mw|apihelp-dbg-description}}}}",
+ "apihelp-dump-description": "{{doc-apihelp-description|dump|seealso=* {{msg-mw|apihelp-dumpfm-description}}}}",
+ "apihelp-dumpfm-description": "{{doc-apihelp-description|dumpfm|seealso=* {{msg-mw|apihelp-dump-description}}}}",
+ "apihelp-json-description": "{{doc-apihelp-description|json|seealso=* {{msg-mw|apihelp-jsonfm-description}}}}",
+ "apihelp-json-param-callback": "{{doc-apihelp-param|json|callback}}",
+ "apihelp-json-param-utf8": "{{doc-apihelp-param|json|utf8}}",
+ "apihelp-jsonfm-description": "{{doc-apihelp-description|jsonfm|seealso=* {{msg-mw|apihelp-json-description}}}}",
+ "apihelp-none-description": "{{doc-apihelp-description|none}}",
+ "apihelp-php-description": "{{doc-apihelp-description|php|seealso=* {{msg-mw|apihelp-phpfm-description}}}}",
+ "apihelp-phpfm-description": "{{doc-apihelp-description|phpfm|seealso=* {{msg-mw|apihelp-php-description}}}}",
+ "apihelp-rawfm-description": "{{doc-apihelp-description|rawfm|seealso=* {{msg-mw|apihelp-raw-description}}}}",
+ "apihelp-txt-description": "{{doc-apihelp-description|txt|seealso=* {{msg-mw|apihelp-txtfm-description}}}}",
+ "apihelp-txtfm-description": "{{doc-apihelp-description|txtfm|seealso=* {{msg-mw|apihelp-txt-description}}}}",
+ "apihelp-wddx-description": "{{doc-apihelp-description|wddx|seealso=* {{msg-mw|apihelp-wddxfm-description}}}}",
+ "apihelp-wddxfm-description": "{{doc-apihelp-description|wddxfm|seealso=* {{msg-mw|apihelp-wddx-description}}}}",
+ "apihelp-xml-description": "{{doc-apihelp-description|xml|seealso=* {{msg-mw|apihelp-xmlfm-description}}}}",
+ "apihelp-xml-param-xslt": "{{doc-apihelp-param|xml|xslt}}",
+ "apihelp-xml-param-includexmlnamespac": "{{doc-apihelp-param|xml|includexmlnamespac}}",
+ "apihelp-xmlfm-description": "{{doc-apihelp-description|xmlfm|seealso=* {{msg-mw|apihelp-xml-description}}}}",
+ "apihelp-yaml-description": "{{doc-apihelp-description|yaml|seealso=* {{msg-mw|apihelp-yamlfm-description}}}}",
+ "apihelp-yamlfm-description": "{{doc-apihelp-description|yamlfm|seealso=* {{msg-mw|apihelp-yaml-description}}}}",
+
"apihelp-help-description": "{{doc-apihelp-description|help}}",
"apihelp-help-param-modules": "{{doc-apihelp-param|help|modules}}",
"apihelp-help-param-submodules": "{{doc-apihelp-param|help|submodules}}",
"apihelp-help-example-help": "{{doc-apihelp-example|help}}",
"apihelp-help-example-query": "{{doc-apihelp-example|help}}",
+ "api-format-title": "Page title when API output is pretty-printed in HTML.",
+ "api-format-prettyprint-header": "{{technical}} Displayed as a header when API output is pretty-printed in HTML.\n\nParameters:\n* $1 - Format name\n* $2 - Non-pretty-printing module name",
+
"api-help-title": "Page title for the auto-generated help output",
"api-help-lead": "Text displayed at the top of the API help page",
"api-help-main-header": "Text for the header of the main module",
'mediawiki.hlist',
),
),
+ 'mediawiki.apipretty' => array(
+ 'styles' => 'resources/src/mediawiki/mediawiki.apipretty.css',
+ 'targets' => array( 'desktop', 'mobile' ),
+ ),
'mediawiki.api' => array(
'scripts' => 'resources/src/mediawiki.api/mediawiki.api.js',
'dependencies' => 'mediawiki.util',
--- /dev/null
+h1.firstHeading {
+ display: none;
+}
+
+.api-pretty-header {
+ font-size: small;
+}
+
+.api-pretty-content {
+ white-space: pre-wrap;
+}
$printer = $module->createPrinterByName( $format );
- $printer->initPrinter( false );
-
ob_start();
+ $printer->initPrinter( false );
$printer->execute();
- $out = ob_get_clean();
-
$printer->closePrinter();
+ $out = ob_get_clean();
return $out;
}