首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >带有Dojo和AMD的JSDoc3

带有Dojo和AMD的JSDoc3
EN

Stack Overflow用户
提问于 2014-10-16 19:57:43
回答 1查看 288关注 0票数 0

我正在努力使我的JS文档正确。我正在使用Dojo,以及在此基础上构建的其他复杂框架,我将不谈细节。关键是这个框架正在使用AMD模块。我想让我的JSDoc开始工作。

以下是我到目前为止所拥有的:

代码语言:javascript
复制
/**
 * 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添加到等式中时,很多构造看起来都很模糊。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-10-16 21:48:31

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

还要注意的是,jsdoc3在处理非CommonJS模块时有很多bug,因此您可能需要做额外的黑客操作才能使它正常工作。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26412807

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档