【发布时间】:2018-02-08 16:19:04
【问题描述】:
我有一个自定义对象 g3.hybrid,工厂函数 g3.Class 将使用它作为父对象来生成自定义类。
我的问题是,在这个对象填充工厂函数后,我无法让 JSDoc 识别我的函数/属性。
这是我的自定义对象:
/**
* @class g3.hybrid
* @classdesc
* A supplementary object used as parent for the class construction helper class
* (see {@link g3.Class}).
* bla-bla-bla
*/
g3.hybrid = function(myClass){ //<-No, this is NOT constructor!
return {
/**
* @lends g3.hybrid.
*/
STATIC: { //<-It's members WILL become static props!
/**
* @static
* @prop {Object} defaults Accessed as: g3[myClass].defaults
* @prop {string} defaults.name Name of stored object, should provide your own names
*/
defaults: {
name: 'g3hybrid'
}
},
/**
* @lends g3.hybrid.prototype
*/
prototype: { //<- It's members WILL become prototype members!
/**
* @public
* @function g3.hybrid.prototype.addLibrary
* It is called always implicitly from a library plugin of "g3[myClass]".
* bla-bla-bla
* @param {String} name A name of the library that each object stores in
* instance property libraries.
* @param {String} lib A reference of an object from a library.
* @return {} Undefined.
*/
addLibrary: function(name, lib){
}
},
/**
* @public
* @constructs g3.hybrid
* @function g3.hybrid.constructor
*
* The constructor function of "g3[myClass]".
* You should pass an object argument or it throws an error.
* bla-bla-bla
* @param {Object} options Object that contains as members "name" for the
* instance's name and default values that will overwrite static default
* members.
* @return {Object} An object of class g3[myClass].
*/
constructor: function(options){ //<- This IS the constructor!
}
};
}
然后在项目的根目录中输入cent@cent:~/plugins$ jsdoc -c ~/node/jsdoc/conf-1.json ./js/g3hybrid-1.js -d out-plugins,其中conf-1.json 是我在node 文件夹中的conf 文件,该文件是为该用户在本地安装的。
修改后的配置文件如下:
{
"plugins": [],
"recurseDepth": 10,
"source": {
"include": [ /* array of paths to files to generate documentation for */ ],
"exclude": [ /* array of paths to exclude */ ],
"includePattern": ".+\\.js(doc|x)?$",
"excludePattern": "(^|\\/|\\\\)_"
},
"sourceType": "module",
"plugins": [
"plugins/markdown",
"plugins/summarize"
],
"tags": {
"allowUnknownTags": true,
"dictionaries": ["jsdoc","closure"]
},
"templates": {
"cleverLinks": false,
"monospaceLinks": false
}
}
并且辅助函数function(myClass)被标记为构造函数!
cent@cent:~/plugins$ jsdoc -v
JSDoc 3.5.5 (Thu, 14 Sep 2017 02:51:54 GMT)
cent@cent:~/plugins$ node -v
v7.1.0
有什么想法可以让它变得漂亮吗?
【问题讨论】:
标签: javascript node.js documentation jsdoc