diff --git a/.jsdoc.json b/.jsdoc.json index b17db1e61..e518998c9 100644 --- a/.jsdoc.json +++ b/.jsdoc.json @@ -33,7 +33,7 @@ "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" ] }, - "plugins": ["plugins/markdown"], + "plugins": ["plugins/markdown", "build/jsdoc-typeof-plugin"], "markdown": { "tags": ["example"], "idInHeadings": true diff --git a/build/jsdoc-typeof-plugin.js b/build/jsdoc-typeof-plugin.js new file mode 100644 index 000000000..70564825a --- /dev/null +++ b/build/jsdoc-typeof-plugin.js @@ -0,0 +1,12 @@ +/** + * The jsdoc plugin that will convert types like {typeof ClassName} into {Class} + */ +exports.handlers = { + jsdocCommentFound: event => { + event.comment = (event.comment || '').replace(/\{.*typeof\s+([^\s\|]+).*\}/g, typeExpression => { + return typeExpression.replace(/typeof\s+([^\s\|\}]+)/g, (expression, className) => { + return 'Class<' + className + '>'; + }); + }); + } +}; diff --git a/src/js/plugin.js b/src/js/plugin.js index 835c10a6b..d55698ad3 100644 --- a/src/js/plugin.js +++ b/src/js/plugin.js @@ -52,7 +52,7 @@ const pluginExists = (name) => pluginStorage.hasOwnProperty(name); * @param {string} name * The name of a plugin. * - * @return {Function|undefined} + * @return {typeof Plugin|Function|undefined} * The plugin (or undefined). */ const getPlugin = (name) => pluginExists(name) ? pluginStorage[name] : undefined; @@ -336,10 +336,10 @@ class Plugin { * must not match an existing plugin or a method on the `Player` * prototype. * - * @param {Function} plugin + * @param {typeof Plugin|Function} plugin * A sub-class of `Plugin` or a function for basic plugins. * - * @return {Function} + * @return {typeof Plugin|Function} * For advanced plugins, a factory function for that plugin. For * basic plugins, a wrapper function that initializes the plugin. */ @@ -444,7 +444,7 @@ class Plugin { * @param {string} name * The name of a plugin. * - * @returns {Function|undefined} + * @returns {typeof Plugin|Function|undefined} * The plugin (or `undefined`). */ Plugin.getPlugin = getPlugin;