resourceloader: Improve moduleRegistry documentation
authorTimo Tijhof <krinklemail@gmail.com>
Fri, 28 Aug 2015 22:54:27 +0000 (00:54 +0200)
committerTimo Tijhof <krinklemail@gmail.com>
Mon, 31 Aug 2015 16:08:52 +0000 (18:08 +0200)
Rename local 'msgs' variable to 'messages' for consistency.

Change-Id: I5d035204ac5d22673a9b9a68ce9ea6cf23aaeba8

resources/src/mediawiki/mediawiki.js

index 6548896..99f824e 100644 (file)
                        /**
                         * Mapping of registered modules.
                         *
-                        * See #implement for exact details on support for script, style and messages.
+                        * See #implement and #execute for exact details on support for script, style and messages.
                         *
                         * Format:
                         *
                         *     {
                         *         'moduleName': {
-                        *             // From startup mdoule
-                        *             'version': '################' (Hash)
+                        *             // From mw.loader.register() in startup module
+                        *             'version': '########' (hash)
                         *             'dependencies': ['required.foo', 'bar.also', ...], (or) function () {}
                         *             'group': 'somegroup', (or) null
                         *             'source': 'local', (or) 'anotherwiki'
                         *             'skip': 'return !!window.Example', (or) null
+                        *
+                        *             // Set from execute() or mw.loader.state()
                         *             'state': 'registered', 'loaded', 'loading', 'ready', 'error', or 'missing'
                         *
-                        *             // Added during implementation
+                        *             // Optionally added at run-time by mw.loader.implement()
                         *             'skipped': true
-                        *             'script': ...
-                        *             'style': ...
-                        *             'messages': { 'key': 'value' }
+                        *             'script': closure, array of urls, or string
+                        *             'style': { ... } (see #execute)
+                        *             'messages': { 'key': 'value', ... }
                         *         }
                         *     }
                         *
                                 * The reason css strings are not concatenated anymore is bug 31676. We now check
                                 * whether it's safe to extend the stylesheet.
                                 *
-                                * @param {Object} [msgs] List of key/value pairs to be added to mw#messages.
+                                * @param {Object} [messages] List of key/value pairs to be added to mw#messages.
                                 * @param {Object} [templates] List of key/value pairs to be added to mw#templates.
                                 */
-                               implement: function ( module, script, style, msgs, templates ) {
+                               implement: function ( module, script, style, messages, templates ) {
                                        // Validate input
                                        if ( typeof module !== 'string' ) {
                                                throw new Error( 'module must be of type string, not ' + typeof module );
                                        if ( style && !$.isPlainObject( style ) ) {
                                                throw new Error( 'style must be of type object, not ' + typeof style );
                                        }
-                                       if ( msgs && !$.isPlainObject( msgs ) ) {
-                                               throw new Error( 'msgs must be of type object, not a ' + typeof msgs );
+                                       if ( messages && !$.isPlainObject( messages ) ) {
+                                               throw new Error( 'messages must be of type object, not a ' + typeof messages );
                                        }
                                        if ( templates && !$.isPlainObject( templates ) ) {
                                                throw new Error( 'templates must be of type object, not a ' + typeof templates );
                                        // Attach components
                                        registry[module].script = script || [];
                                        registry[module].style = style || {};
-                                       registry[module].messages = msgs || {};
+                                       registry[module].messages = messages || {};
                                        registry[module].templates = templates || {};
                                        // The module may already have been marked as erroneous
                                        if ( $.inArray( registry[module].state, ['error', 'missing'] ) === -1 ) {