我试图找到一种方法来记录使用JSDoc3的AMD模块。
/**
* Module description.
*
* @module path/to/module
*/
define(['jquery', 'underscore'], function (jQuery, _) {
/**
* @param {string} foo Foo-Description
* @param {object} bar Bar-Description
*/
return function (foo, bar) {
// insert code here
};
});遗憾的是,http://usejsdoc.org/howto-commonjs-modules.html上列出的任何模式都不适合我。
如何生成适当的文档,列出模块导出的函数的参数和返回值?
发布于 2014-06-02 15:23:36
以下内容似乎产生了一个看上去相当可以接受的结果:
/**
* Module description
*
* @module path/to/module
*/
define(['jquery', 'underscore'], function (jQuery, _) {
/**
* Description for function.
*
* @param {string} foo Foo-Description
* @param {object} bar Bar-Description
*/
var exports = function () {
// insert code here
};
return exports;
});描述该模块和函数的方法如下:
require("path/to/module")(foo, bar)这对于AMD模块来说并不完美,但我认为文档的读者能够理解模块输出的内容。
发布于 2014-05-28 12:20:19
在最新的稳定版本(3.2.2)中,我不认为有一种方法可以使用jsdoc来生成文档来显示模块本身接受参数并返回一些值。最接近理想的是:
/**
* Module description.
*
* @module path/to/module
*/
define(['jquery', 'underscore'], /** @lends module:path/to/module */
function (jQuery, _) {
/**
* The following function documents the parameters that the module
* takes and its return value. Do not call as
* <code>module.self(...)</code> but as <code>module()</code>.
*
* @param {string} foo Foo-Description
* @param {object} bar Bar-Description
*/
return function self(foo, bar) {
// insert code here
};
});为模块生成的文档将有一个名为self的额外内部函数。
https://stackoverflow.com/questions/23824970
复制相似问题