JSDoc3 with Dojo and AMD

I am trying to get my JS documentation right. I am using Dojo, and some other complicated framework built on top of it, I will spare the details. The point is that this framework is using AMD modules. I want my JSDoc to work.

Here is what I have so far:

/**
 * 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);
            }));
        }
    });
});

The result: 在这里输入图像描述

This result is not bad. But it infers that my members are static. WebStorm seem to infer them correctly as members, but the jsdoc3 generator does not. From what I read, I should not have to specify @memberof as @lends should be taking care of that. Is there anything that I am doing wrong? Any general recommendation would be appreciated. I read the JSDoc3 documentation, but a lot of constructs seem blurry when adding AMD to the equation.


You need to lend instance properties to the prototype, not the object itself: @lends module:widgets/instance/AddButton# . Note the # at the end, which is a shorthand for .prototype .

Also note that jsdoc3 has had quite a few bugs related to its handling of non-CommonJS modules, so you may need to do extra hacky stuff to make it work correctly.

链接地址: http://www.djcxy.com/p/70424.html

上一篇: AMD + Backbone + JSDoc3文件的最佳方式

下一篇: 带有Dojo和AMD的JSDoc3