【发布时间】:2019-02-08 05:08:29
【问题描述】:
所以我有一个导出工厂函数的模块。工厂函数接受设置并返回绑定在该设置对象上的库。我一辈子都想不出如何用 jsdocs 来记录它;我一直在玩命名空间、typedef 和memberof,直到我头晕目眩。无论我做什么,它只是没有将函数列为库定义的一部分。帮忙?
如果我完全删除 memberof,我可以让它们显示为全局函数,但到目前为止我没有尝试过让它们显示为成员函数
示例代码:
/**
* @namespace ServerControl
*/
/**
* @typedef {Object} Library
*/
/**
* Factory function that constructs a lib
* @param {*} settings Settings for constructing a lib
* @param {*} rancher The rancher library to be used by the lib
* @returns {ServerControl~Library} The lib
*/
module.exports = function(settings, rancher) {
return {
/**
* Evacuate a host
* @memberof {...ServerControl~Library}
* @method evacuate
* @param {String} name The name of the host to evacuate
* @returns {Promise} A promise that fulfills when the evacuation is done
*/
evacuate: name => {
const server = settings.servers.filter(item => item.display === name)[0];
return rancher.evacuateHost(server.host, server.env);
}
// [more methods snipped]
}
【问题讨论】: