Remove duplicate comments from platform code

Inherited methods don't need to repeat documentation.

Change-Id: I05c4efe8e4a394411922add5f11259d47d44e3bb
This commit is contained in:
Ed Sanders 2013-08-20 20:35:01 +01:00
parent e38bb7714f
commit cbe35632f1
3 changed files with 17 additions and 103 deletions

View file

@ -36,59 +36,35 @@ ve.inheritClass( ve.init.mw.Platform, ve.init.Platform );
/* Methods */ /* Methods */
/** /**
* Get a regular expression that matches allowed external link URLs.
*
* Uses the mw.config wgUrlProtocols variable. * Uses the mw.config wgUrlProtocols variable.
* * @inheritdoc
* @method
* @returns {RegExp} Regular expression object
*/ */
ve.init.mw.Platform.prototype.getExternalLinkUrlProtocolsRegExp = function () { ve.init.mw.Platform.prototype.getExternalLinkUrlProtocolsRegExp = function () {
return this.externalLinkUrlProtocolsRegExp; return this.externalLinkUrlProtocolsRegExp;
}; };
/** /**
* Get a remotely accessible URL to the modules directory.
*
* Uses MediaWiki's {wgExtensionAssetsPath} variable. * Uses MediaWiki's {wgExtensionAssetsPath} variable.
* * @inheritdoc
* @method
* @returns {string} Remote modules URL
*/ */
ve.init.mw.Platform.prototype.getModulesUrl = function () { ve.init.mw.Platform.prototype.getModulesUrl = function () {
return this.modulesUrl; return this.modulesUrl;
}; };
/** /**
* Add multiple messages to the localization system.
*
* Wrapper for mw.msg system. * Wrapper for mw.msg system.
* * @inheritdoc
* @method
* @param {Object} messages Map of message-key/message-string pairs
*/ */
ve.init.mw.Platform.prototype.addMessages = function ( messages ) { ve.init.mw.Platform.prototype.addMessages = function ( messages ) {
return mw.messages.set( messages ); return mw.messages.set( messages );
}; };
/** /**
* Get a message from the localization system.
*
* Wrapper for mw.msg system. * Wrapper for mw.msg system.
*
* @method
* @param {string} key Message key
* @param {Mixed...} [args] List of arguments which will be injected at $1, $2, etc. in the messaage
* @returns {string} Localized message (plain, unescaped)
*/ */
ve.init.mw.Platform.prototype.getMessage = ve.bind( mw.msg, mw ); ve.init.mw.Platform.prototype.getMessage = ve.bind( mw.msg, mw );
/** /** */
* Add multiple parsed messages to the localization system.
*
* @method
* @param {Object} messages Map of message-key/html pairs
*/
ve.init.mw.Platform.prototype.addParsedMessages = function ( messages ) { ve.init.mw.Platform.prototype.addParsedMessages = function ( messages ) {
for ( var key in messages ) { for ( var key in messages ) {
this.parsedMessages[key] = messages[key]; this.parsedMessages[key] = messages[key];
@ -96,14 +72,8 @@ ve.init.mw.Platform.prototype.addParsedMessages = function ( messages ) {
}; };
/** /**
* Get a parsed message as HTML string.
*
* Falls back to mw.messsage with .escaped(). * Falls back to mw.messsage with .escaped().
* Does not support $# replacements. * @inheritdoc
*
* @method
* @param {string} key Message key
* @returns {string} Parsed localized message as HTML string
*/ */
ve.init.mw.Platform.prototype.getParsedMessage = function ( key ) { ve.init.mw.Platform.prototype.getParsedMessage = function ( key ) {
if ( key in this.parsedMessages ) { if ( key in this.parsedMessages ) {
@ -114,22 +84,12 @@ ve.init.mw.Platform.prototype.getParsedMessage = function ( key ) {
return mw.message( key ).escaped(); return mw.message( key ).escaped();
}; };
/** /** */
* Gets client platform string from browser.
*
* @method
* @returns {string} Client platform string
*/
ve.init.mw.Platform.prototype.getSystemPlatform = function () { ve.init.mw.Platform.prototype.getSystemPlatform = function () {
return $.client.profile().platform; return $.client.profile().platform;
}; };
/** /** */
* Gets the user language from the browser.
*
* @method
* @returns {string} User language string
*/
ve.init.mw.Platform.prototype.getUserLanguage = function () { ve.init.mw.Platform.prototype.getUserLanguage = function () {
return mw.config.get( 'wgUserLanguage' ); return mw.config.get( 'wgUserLanguage' );
}; };

View file

@ -30,12 +30,7 @@ ve.inheritClass( ve.init.sa.Platform, ve.init.Platform );
/* Methods */ /* Methods */
/** /** */
* Get a regular expression that matches allowed external link URLs.
*
* @method
* @returns {RegExp} Regular expression object
*/
ve.init.sa.Platform.prototype.getExternalLinkUrlProtocolsRegExp = function () { ve.init.sa.Platform.prototype.getExternalLinkUrlProtocolsRegExp = function () {
return this.externalLinkUrlProtocolsRegExp; return this.externalLinkUrlProtocolsRegExp;
}; };
@ -50,36 +45,19 @@ ve.init.sa.Platform.prototype.setModulesUrl = function ( url ) {
this.modulesUrl = url; this.modulesUrl = url;
}; };
/** /** */
* Get a remotely accessible URL to the modules directory.
*
* @method
* @returns {string} Remote modules URL
*/
ve.init.sa.Platform.prototype.getModulesUrl = function () { ve.init.sa.Platform.prototype.getModulesUrl = function () {
return this.modulesUrl; return this.modulesUrl;
}; };
/** /** */
* Add multiple messages to the localization system.
*
* @method
* @param {Object} messages Map of message-key/message-string pairs
*/
ve.init.sa.Platform.prototype.addMessages = function ( messages ) { ve.init.sa.Platform.prototype.addMessages = function ( messages ) {
for ( var key in messages ) { for ( var key in messages ) {
this.messages[key] = messages[key]; this.messages[key] = messages[key];
} }
}; };
/** /** */
* Get a message from the localization system.
*
* @method
* @param {string} key Message key
* @param {Mixed...} [args] List of arguments which will be injected at $1, $2, etc. in the messaage
* @returns {string} Localized message
*/
ve.init.sa.Platform.prototype.getMessage = function ( key ) { ve.init.sa.Platform.prototype.getMessage = function ( key ) {
if ( key in this.messages ) { if ( key in this.messages ) {
// Simple message parser, does $N replacement and nothing else. // Simple message parser, does $N replacement and nothing else.
@ -92,28 +70,14 @@ ve.init.sa.Platform.prototype.getMessage = function ( key ) {
return '<' + key + '>'; return '<' + key + '>';
}; };
/** /** */
* Add multiple parsed messages to the localization system.
*
* @method
* @param {Object} messages Map of message-key/html pairs
*/
ve.init.sa.Platform.prototype.addParsedMessages = function ( messages ) { ve.init.sa.Platform.prototype.addParsedMessages = function ( messages ) {
for ( var key in messages ) { for ( var key in messages ) {
this.parsedMessages[key] = messages[key]; this.parsedMessages[key] = messages[key];
} }
}; };
/** /** */
* Get a parsed message as HTML string.
*
* Falls back to mw.messsage with .escaped().
* Does not support $# replacements.
*
* @method
* @param {string} key Message key
* @returns {string} Parsed localized message as HTML string
*/
ve.init.sa.Platform.prototype.getParsedMessage = function ( key ) { ve.init.sa.Platform.prototype.getParsedMessage = function ( key ) {
if ( key in this.parsedMessages ) { if ( key in this.parsedMessages ) {
// Prefer parsed results from VisualEditorMessagesModule.php if available. // Prefer parsed results from VisualEditorMessagesModule.php if available.
@ -136,12 +100,7 @@ ve.init.sa.Platform.prototype.getParsedMessage = function ( key ) {
} ); } );
}; };
/** /** */
* Gets client platform string from browser.
*
* @method
* @returns {string} Client platform string
*/
ve.init.sa.Platform.prototype.getSystemPlatform = function () { ve.init.sa.Platform.prototype.getSystemPlatform = function () {
var platforms = ['win', 'mac', 'linux', 'sunos', 'solaris', 'iphone'], var platforms = ['win', 'mac', 'linux', 'sunos', 'solaris', 'iphone'],
match = new RegExp( '(' + platforms.join( '|' ) + ')' ).exec( window.navigator.platform.toLowerCase() ); match = new RegExp( '(' + platforms.join( '|' ) + ')' ).exec( window.navigator.platform.toLowerCase() );
@ -150,12 +109,7 @@ ve.init.sa.Platform.prototype.getSystemPlatform = function () {
} }
}; };
/** /** */
* Gets the user language from the browser.
*
* @method
* @returns {string} User language string
*/
ve.init.sa.Platform.prototype.getUserLanguage = function () { ve.init.sa.Platform.prototype.getUserLanguage = function () {
// IE or Firefox Safari Opera // IE or Firefox Safari Opera
var lang = window.navigator.userLanguage || window.navigator.language; var lang = window.navigator.userLanguage || window.navigator.language;

View file

@ -75,7 +75,7 @@ ve.init.Platform.prototype.getMessage = function () {
* *
* @method * @method
* @abstract * @abstract
* @param {Object} messages Containing parsed html strings * @param {Object} messages Map of message-key/html pairs
*/ */
ve.init.Platform.prototype.addParsedMessages = function () { ve.init.Platform.prototype.addParsedMessages = function () {
throw new Error( 've.init.Platform.addParsedMessages must be overridden in subclass' ); throw new Error( 've.init.Platform.addParsedMessages must be overridden in subclass' );
@ -106,7 +106,7 @@ ve.init.Platform.prototype.getSystemPlatform = function () {
}; };
/** /**
* Gets the user language from the browser. * Gets the user language.
* *
* @method * @method
* @abstract * @abstract