语法
🌐 Syntax
@exports <moduleName>
在 JSDoc 3.3.0 及更高版本中,<moduleName> 可以包含 module: 前缀。在较早的版本中,必须省略此前缀。
🌐 In JSDoc 3.3.0 and later, <moduleName> may include the module: prefix. In previous versions, you
must omit this prefix.
概述
🌐 Overview
在记录导出除“exports”对象或“module.exports”属性以外内容的 JavaScript 模块时,使用 @exports 标签。
🌐 Use the @exports tag when documenting JavaScript modules that export anything other than the "exports" object or the "module.exports" property.
示例
🌐 Examples
在使用特殊 "exports" 对象的模块中,@exports 标签从不需要。JSDoc 会自动识别该对象的成员正在被导出。同样地,JSDoc 也会自动识别 Node.js 模块中的特殊 "module.exports" 属性。
🌐 In modules where you are using the special "exports" object, the @exports tag is never needed. JSDoc automatically recognizes that this object's members are being exported. Similarly, JSDoc automatically recognizes the special "module.exports" property in Node.js modules.
/**
* A module that says hello!
* @module hello/world
*/
/** Say hello. */
exports.sayHello = function() {
return 'Hello world';
};
/**
* A module that shouts hello!
* @module hello/world
*/
/** SAY HELLO. */
module.exports = function() {
return "HELLO WORLD";
};
define(function() {
/**
* A module that whispers hello!
* @module hello/world
*/
var exports = {};
/** say hello. */
exports.sayHello = function() {
return 'hello world';
};
return exports;
});
define(function() {
/**
* A module that creates greeters.
* @module greeter
*/
/**
* @constructor
* @param {string} subject - The subject to greet.
*/
var exports = function(subject) {
this.subject = subject || 'world';
};
/** Say hello to the subject. */
exports.prototype.sayHello = function() {
return 'Hello ' + this.subject;
};
return exports;
});
如果你的模块导出一个名为“exports”或“module.exports”以外的对象,请使用 @exports 标签来指明正在导出的内容。
🌐 If your module exports an object named anything other than "exports" or "module.exports", use the @exports tag to indicate what is being exported.
define(function () {
/**
* A module that says hello!
* @exports hello/world
*/
var ns = {};
/** Say hello. */
ns.sayHello = function() {
return 'Hello world';
};
return ns;
});