From cd13aea297f127ff244b11b29fea28367e2c8ed7 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Tue, 26 Jun 2018 18:11:13 +0100 Subject: [PATCH] mediawiki.inspect: Fix doc index for inspect.grep() 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 | 68 +++++++++++++++--------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/resources/src/mediawiki.inspect.js b/resources/src/mediawiki.inspect.js index 8ef83d9ffa..cf94083676 100644 --- a/resources/src/mediawiki.inspect.js +++ b/resources/src/mediawiki.inspect.js @@ -212,6 +212,40 @@ } ); }; + /** + * 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 @@ -294,40 +328,6 @@ } }; - /** - * 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.' ); } -- 2.20.1