17
formu (tek bir dosya) Aşağıdaki etmiştir jsdoc
jsdoc socket.on belgelemek için uygun yolu ('olayı', function() {}) ve güzergahları işleyicisi
// 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) {...});
...
};
Benim tek fikir kullanarak API belgelemek için nasıl
dışa aktarma ve @lends
anonim işlevlerin yukarıda @namespace
eklemek için boş belgelere neden olur.
tüm anonim fonksiyonlar göz ardı kalır bu dosya (belgesiz) karşı jsdoc komutunu çalıştırma: gibi
Yani, yukarıdaki metin ile, bu görünebilir. Ayrıca, eğer kullanabiliyorsam, @class kullanmaktan kaçınmaya çalışacağım, bu durumda dokümantasyon, dokümanları okuyacak birine ipucu veren yeni socketio() içerecektir. – Srle
@class'ı neden istemediğini anlayabiliyorum. En son JSDoc'u mu kullanıyorsun? Ben de bu soruyu buldum. https://stackoverflow.com/questions/8071897/how-to-document-anonymous-functions-closure-with-jsdoc-toolkit –