如何使用具有以下形式的 jsdoc 记录 API(单个文件)
// api.js
exports.addSocketEvents = function(socket) {
/**
* This will do that and ...
* @param {Object} data Some data
* @param {string} data.bla Something about bla
* @param {number} data.n Some number
*/
socket.on('something_1', function(data) { ... });
/**
* Another function that will do ..
* @param {string} id of something
*/
socket.on('something_2', function(id) { ... });
...
};
exports.addRoutes = function(app) {
/**
* PATCH /something/:id/juhu
* Will do this and that and will respond with ...
* @param {string} _id Id of bonus document
*/
app.patch('/something/:id/juhu', function(req, res) {...});
/**
* GET /something
* Will fetch and respond back with ...
*/
app.get('/something', function(req, res) {...});
...
};
我唯一的想法是在@namespace
导出和@lends
匿名函数之上添加,但这会导致文档为空。