JSDoc3与Dojo和AMD

JSDoc3与Dojo和AMD,dojo,amd,jsdoc3,Dojo,Amd,Jsdoc3,我正在努力使我的JS文档正确。我使用的是Dojo,以及其他一些构建在它之上的复杂框架,我将省去这些细节。关键是这个框架使用的是AMD模块。我想让我的JSDoc工作 以下是我到目前为止的情况: /** * Creates a button instance that launches a document entry template selector * @module widgets/instance/AddButton */ define([ "dijit/_Templated

我正在努力使我的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);
            }));
        }
    });
});
/**
*创建启动文档输入模板选择器的按钮实例
*@modulewidgets/instance/AddButton
*/
定义([
“dijit/_TemplatedMixin”,
“dijit/_WidgetBase”,
“dojo/_base/declare”,
“dojo/_base/lang”,
“dojo/on”,
“kwcn/services/request”,
“kwcn/widgets/AddContentDialog”
],函数(_TemplatedMixin,_WidgetBase,declare,lang,on,request,AddContentDialog){
返回declare('AddButton',[\u WidgetBase,\u TemplatedMixin],/**@lends模块:widgets/instance/AddButton*/{
id:“添加按钮”,
contentList:null,
templateString:“添加文档”,
addContentItem:null,
类型:null,
/**
*@constructs
*@param args
*@param args.type{string}内容项的类型
*@param args.contentList{contentList}作用域中[contentList]{@link module:widgets/contentList/contentList}的实例
*/
构造函数:函数(args){
declare.safeMixin(本,args);
},
/**
*@私人
*/
后创建:函数(){
log(“创建添加内容按钮…”);
this.addContentItem=新建AddContentDialog({
存储库:request.repository(),
哈斯凯斯:错
});
this.own(在(this.domNode,'click',lang.hitch(this,'show'))上);
},
/**
*@公众
*/
显示:函数(){
request.inboundFolder().then(lang.hitch)(此函数为文件夹){
this.addContentItem.showAddDocument(空,文件夹);
}));
}
});
});
结果是:


这个结果还不错。但它推断我的成员是静态的。WebStorm似乎能正确地推断出它们是成员,但jsdoc3生成器却不能。从我读到的内容来看,我不必指定@memberof as@lends应该负责这个问题。我做错什么了吗?如有任何一般性建议,将不胜感激。我阅读了JSDoc3文档,但在将AMD添加到等式中时,许多构造看起来很模糊。

您需要将实例属性借给原型,而不是对象本身:
@lends module:widgets/instance/AddButton
。注意结尾的#,它是
.prototype
的缩写


还要注意的是,jsdoc3在处理非通用JS模块方面有很多bug,因此您可能需要做额外的黑客工作才能使其正常工作。

Beauty!正如你所说的那样。现在我明白了,这完全有道理。