19

次の形式の 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上記の匿名関数を追加することですが、その結果、空のドキュメントが作成されます。

4

1 に答える 1