@exports
Содержание
Синтаксис
@exports <moduleName>
В JSDoc 3.3.0 и более поздних версиях, <moduleName> может включать префикс module:. В предыдущих версиях этот префикс нужно опустить.
Обзор
Используйте тег @exports при документировании JavaScript модулей, которые экспортируют что-либо помимо объекта "exports" или свойства "module.exports".
Примеры
В модулях, где вы используете специальный объект "exports", тег @exports не нужен. JSDoc автоматически распознаёт, что члены этого объекта экспортируются. Аналогично, JSDoc автоматически распознаёт специальное свойство "module.exports" в модулях Node.js.
/**
* 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, чтобы указать, что экспортируется.
define(function () {
/**
* A module that says hello!
* @exports hello/world
*/
var ns = {};
/** Say hello. */
ns.sayHello = function() {
return 'Hello world';
};
return ns;
});
Связанные ссылки
© 2011–2017 the contributors to the JSDoc 3 documentation project
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://jsdoc.app/tags-exports.html