mediawiki.inspect: Fix doc index for inspect.grep()
authorTimo Tijhof <krinklemail@gmail.com>
Tue, 26 Jun 2018 17:11:13 +0000 (18:11 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Tue, 26 Jun 2018 17:11:13 +0000 (18:11 +0100)
Because this was positioned linearly after the sub-object for
`mw.inspect.reports.*`, JSDuck was indexing this as part of that
object instead of the outer `mw.inspect.*` scope.

This could be fixed by adding `@member mw.inspect` on this method,
or by re-starting the `@class mw.inspect` scope, but really
this should've been declared closer to the rest of that class,
which naturally avoids the index issue.

Change-Id: Ib2c9dc861f7f062c05bc059643a1a676906d338f

resources/src/mediawiki.inspect.js

index 8ef83d9..cf94083 100644 (file)
                } );
        };
 
+       /**
+        * Perform a string search across the JavaScript and CSS source code
+        * of all loaded modules and return an array of the names of the
+        * modules that matched.
+        *
+        * @param {string|RegExp} pattern String or regexp to match.
+        * @return {Array} Array of the names of modules that matched.
+        */
+       inspect.grep = function ( pattern ) {
+               if ( typeof pattern.test !== 'function' ) {
+                       pattern = new RegExp( mw.RegExp.escape( pattern ), 'g' );
+               }
+
+               return inspect.getLoadedModules().filter( function ( moduleName ) {
+                       var module = mw.loader.moduleRegistry[ moduleName ];
+
+                       // Grep module's JavaScript
+                       if ( $.isFunction( module.script ) && pattern.test( module.script.toString() ) ) {
+                               return true;
+                       }
+
+                       // Grep module's CSS
+                       if (
+                               $.isPlainObject( module.style ) && Array.isArray( module.style.css ) &&
+                               pattern.test( module.style.css.join( '' ) )
+                       ) {
+                               // Module's CSS source matches
+                               return true;
+                       }
+
+                       return false;
+               } );
+       };
+
        /**
         * @class mw.inspect.reports
         * @singleton
                }
        };
 
-       /**
-        * Perform a string search across the JavaScript and CSS source code
-        * of all loaded modules and return an array of the names of the
-        * modules that matched.
-        *
-        * @param {string|RegExp} pattern String or regexp to match.
-        * @return {Array} Array of the names of modules that matched.
-        */
-       inspect.grep = function ( pattern ) {
-               if ( typeof pattern.test !== 'function' ) {
-                       pattern = new RegExp( mw.RegExp.escape( pattern ), 'g' );
-               }
-
-               return inspect.getLoadedModules().filter( function ( moduleName ) {
-                       var module = mw.loader.moduleRegistry[ moduleName ];
-
-                       // Grep module's JavaScript
-                       if ( $.isFunction( module.script ) && pattern.test( module.script.toString() ) ) {
-                               return true;
-                       }
-
-                       // Grep module's CSS
-                       if (
-                               $.isPlainObject( module.style ) && Array.isArray( module.style.css ) &&
-                               pattern.test( module.style.css.join( '' ) )
-                       ) {
-                               // Module's CSS source matches
-                               return true;
-                       }
-
-                       return false;
-               } );
-       };
-
        if ( mw.config.get( 'debug' ) ) {
                mw.log( 'mw.inspect: reports are not available in debug mode.' );
        }