Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I document a knockout.js view model with jsdoc?

I already tried to make use of namespaces and the @memberOf tag, but in the generated API doc I still have no class members or methods at all.

Here is some example code:

/**
 * Test file
 * @namespace test
 */

/**
 * my view model
 * @class MyViewModel
 * @memberOf test
 */
function MyViewModel() {
    var self = this;

    /**
     * test observable
     * @type {Object}
     * @memberOf test.MyViewModel#
     */
    self.testObservable = ko.observable();

    /**
     * test function
     * @memberOf test.MyViewModel#
     */
    self.testObservable = function() {
        // do something
    };
}
like image 566
user3493607 Avatar asked Oct 21 '22 11:10

user3493607


1 Answers

Your @memberof tags would work if you used @memberof!. The exclamation point forces jsdoc to follow what you give it. If you don't use the exclamation point, jsdoc will decide that it knows better than you do and ignore the tag. But using @memberof! still makes it look funky. What you can do is remove the @memberof tags and use @lends as follows:

/**
 * Test file
 * @namespace test
 */

/**
 * my view model
 * @class MyViewModel
 * @memberOf test
 */
function MyViewModel() {
    /** @lends test.MyViewModel# */
    var self = this;

    /**
     * test observable
     * @type {Object}
     */
    self.testObservable = ko.observable();

    /**
     * test function
     */
    self.testObservable = function() {
        // do something
    };
}
like image 162
Louis Avatar answered Oct 23 '22 03:10

Louis