我正在尝试自动化 JS 库中的特定模块,但陷入了我想要定义一组属性的点(假设一个对象作为类的构造参数)。
/**
* This function initiates world peace!
* @constructor
* @param {object} defaults - The options to initiate peace.
* @param {number} defaults.issues - The number of issues being taken up.
* @param {string} defaults.source - The name of the location where process starts.
*/
var WorldPeace = function (defaults) {
// code here
};
Run Code Online (Sandbox Code Playgroud)
如果构造的所有属性都在一个位置定义,那就太好了。不幸的是,我的代码有许多模块有助于构建属性。可以说,在代码的其他部分(在后面的文件中)会导致具有更多属性
* @param {Date} defaults.start - The date when the process started.
* @param {Date} defaults.stop - The date when the process …Run Code Online (Sandbox Code Playgroud) javascript code-documentation google-closure google-closure-compiler jsdoc
我正在使用JSDoc,我想将信息添加到我的文档中,参数应该具有哪个值。
在此示例中,您可以看到该参数operator具有字符串类型。但是此外,参数只能存在open或close为有效值
/**
* Description
* @param {string='open','close'} operator
*/
Run Code Online (Sandbox Code Playgroud)
什么是正确的语法来添加这些信息?