我有一个名为 example.js
的文件,其中包含以下内容。当我运行时
jsdoc example.js
我按预期得到了一个 ./out
文件夹,但生成的文档不包含 foo.greeting
,仅包含 greeting
。
const foo = {};
/**
* greets with name in text
* @param {string} name - name
* @returns {string} - an IPC response object
*/
foo.greeting = (name) => {
return 'hello, ' + name;
};
/**
* greets with name in text
* @param {string} name - name
* @returns {string} - an IPC response object
*/
const greeting = (name) => {
return 'hello, ' + name;
};
是否可以让jsdoc识别对对象属性的匿名函数赋值?
我目前使用的是 JSDoc 3.6.6。
最佳答案
是的,您可以通过使用 @function
标记来做到这一点:
/**
* @function greeting
* @description greets with name in text
* @param {string} name - name
* @returns {string} - an IPC response object
*/
foo.greeting = (name) => {
return 'hello, ' + name;
};
这是否会产生您正在寻找的东西,很难说,但它至少会产生一些东西。
关于javascript - 如何让 JSDoc 识别分配给对象属性的匿名函数? (包含示例代码),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65738581/