10

我正在努力使用 jsdoc-toolkit 以以下格式记录代码。在我看来,我使用的标签应该会产生预期的结果,但事实并非如此。相反,它警告 Class 是未记录的(因为它仅在闭包内定义)并且不包括 Class 在命名空间的成员列表中。

如果可能的话,我想在不使用@name 标签的情况下记录这一点。任何人都可以帮忙吗?

/**
 * @namespace The original namespace
 */
var namespace = function () {
    // private
    /**
     * @private
     */
    function _privateMethod () {

    };

    /**
     * This is the detail about the constructor
     * @class This is the detail about the class
     * @param {Object} argone The first argument
     * @param {Object} argtwo The second argument
     */
    var Class = function (argone, argtwo) {
        /**
         * A public member variable
         */
        this.member = "a member";
    };

    /**
     * A public method
     * @param {Object} argone The first argument
     */
    Class.prototype.publicMethod = function (argone) {

    };

    return /** @lends namespace */ {
        Class: Class
    }
}();
4

2 回答 2

4

我尝试了很多不同的东西,这是我能想到的最好的。

第一部分...记录publicMethodon Class。先制作Class一个memberOf namespace,然后@lends在上使用Class.prototype。例子:

/**
 * @namespace The original namespace
 */
var namespace = function () {
    // private
    /**
     * @private
     */
    function _privateMethod () {

    };

    /**
     * This is the detail about the constructor
     * @class This is the detail about the class
     * @memberOf namespace
     * @param {Object} argone The first argument
     * @param {Object} argtwo The second argument
     */
    var Class = function (argone, argtwo) {
        /**
         * A public member variable
         */
        this.member = "a member";
    };

    Class.prototype = 
    /** @lends namespace.Class */ 
    {
        /** a public method
          * @param {Object} argone The first argument
        */
        publicMethod: function (argone) {

        }
    };

    return {
        Class: Class
    }
}();

现在,第二部分......Class开始出现在namespace. 我不知道该怎么做...对不起!它将显示namespace.Class在类索引中。

于 2013-01-08T05:08:41.283 回答
0

提示:jsdoc 2 充满了错误和不良做法。
根据项目的性质,考虑尝试 JSDOC3 -> https://github.com/jsdoc3/jsdoc或根本不尝试 jsdoc。

于 2013-02-05T22:04:02.757 回答