我正在努力使我的JS文档正确。我正在使用Dojo,以及在此基础上构建的其他复杂框架,我将不谈细节。关键是这个框架正在使用AMD模块。我想让我的JSDoc开始工作。
以下是我到目前为止所拥有的:
/**
* Creates a button instance that launches a document entry template selector
* @module widgets/instance/AddButton
*/
define([
"dijit/_TemplatedMixin",
"dijit/_WidgetBase",
"dojo/_base/declare",
"dojo/_base/lang",
"dojo/on",
"kwcn/services/request",
"kwcn/widgets/AddContentDialog"
], function (_TemplatedMixin, _WidgetBase, declare, lang, on, request, AddContentDialog) {
return declare('AddButton', [_WidgetBase, _TemplatedMixin], /** @lends module:widgets/instance/AddButton */{
id: 'add-button',
contentList: null,
templateString: '<button class="btn btn-link toolbar-link"><i class="fa fa-lg fa-file"></i> Add Document</button>',
addContentItem: null,
type: null,
/**
* @constructs
* @param args
* @param args.type {string} The type of content item
* @param args.contentList {ContentList} The instance of [ContentList]{@link module:widgets/contentList/ContentList} in scope
*/
constructor: function (args) {
declare.safeMixin(this, args);
},
/**
* @private
*/
postCreate: function () {
console.log("creating the add content button...");
this.addContentItem = new AddContentDialog({
repository: request.repository(),
hasCase: false
});
this.own(on(this.domNode, 'click', lang.hitch(this, 'show')));
},
/**
* @public
*/
show: function () {
request.inboundFolder().then(lang.hitch(this, function (folder) {
this.addContentItem.showAddDocument(null, folder);
}));
}
});
});结果:

这个结果还不错。但它推断我的成员是静态的。WebStorm似乎正确地推断了它们作为成员,但是jsdoc3生成器没有。根据我所读到的,我不应该指定@memberof as“lends”来处理这个问题。我做错什么了吗?如有任何一般性建议,将不胜感激。我阅读了JSDoc3文档,但是当将AMD添加到等式中时,很多构造看起来都很模糊。
发布于 2014-10-16 21:48:31
您需要将实例属性借给原型,而不是对象本身:@lends module:widgets/instance/AddButton#。请注意末尾的#,它是.prototype的缩写。
还要注意的是,jsdoc3在处理非CommonJS模块时有很多bug,因此您可能需要做额外的黑客操作才能使它正常工作。
https://stackoverflow.com/questions/26412807
复制相似问题