* Adding configuration files for jsduck. * Fixing our previously undocumented code documentation to comply with jsduck specifications .. for the following modules: - mediawiki - mediawiki.Title - mediawiki.util - mediawiki.notification - mediawiki.api (and plugins thereof) - jquery.localize I've choose these to show as many different examples for different types of modules and methods that we encounter in our code base. Hopefully with this as a start it will be easy for other people to extend the documentation for most (if not, all) other modules we have in MediaWiki core. Change-Id: Ieb8c5d2d2cb4672f1d6abc3f865c6fb1470d8feb
43 lines
941 B
JavaScript
43 lines
941 B
JavaScript
/**
|
|
* @class mw.Api.plugin.parse
|
|
*/
|
|
( function ( mw, $ ) {
|
|
|
|
$.extend( mw.Api.prototype, {
|
|
/**
|
|
* Convinience method for 'action=parse'.
|
|
*
|
|
* @param {string} wikitext
|
|
* @param {Function} [ok] Success callback (deprecated)
|
|
* @param {Function} [err] Error callback (deprecated)
|
|
* @return {jQuery.Promise}
|
|
* @return {Function} return.done
|
|
* @return {string} return.done.data Parsed HTML of `wikitext`.
|
|
*/
|
|
parse: function ( wikitext, ok, err ) {
|
|
var d = $.Deferred();
|
|
// Backwards compatibility (< MW 1.20)
|
|
d.done( ok );
|
|
d.fail( err );
|
|
|
|
this.get( {
|
|
action: 'parse',
|
|
text: wikitext
|
|
} )
|
|
.done( function ( data ) {
|
|
if ( data.parse && data.parse.text && data.parse.text['*'] ) {
|
|
d.resolve( data.parse.text['*'] );
|
|
}
|
|
} )
|
|
.fail( d.reject );
|
|
|
|
return d.promise();
|
|
}
|
|
} );
|
|
|
|
/**
|
|
* @class mw.Api
|
|
* @mixins mw.Api.plugin.parse
|
|
*/
|
|
|
|
}( mediaWiki, jQuery ) );
|