Best way to document anonymous objects and functions with jsdoc

后端 未结 6 1164
北荒
北荒 2020-12-12 15:40

Edit: This is technically a 2 part question. I\'ve chosen the best answer that covers the question in general and linked to the answer that handles the specific question.

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-12 16:16

    You could use @see to link to another method within the same class. The method would never be used, it would just be there for documentation purposes.

    /**
     * @class {Page} Page Class specification
     */
    var Page = function() {
    
        /**
         * Get a page from the server
         * @param {PageRequest} pageRequest Info on the page you want to request
         * @param {function} callback Function executed when page is retrieved
         * @see #getPageCallback 
         */
        this.getPage = function (pageRequest, callback) {
        }; 
    
        /**
         * Called when page request completes 
         * @param {PageResponse} pageResponse The requested page
         * @param {PageRequestStatus} pageRequestStatus Status of the page
         */
        //#ifdef 0
        this.getPageCallback = function (pageResponse, pageRequestStatus) { };
        //#endif 
    };
    

    If you are using some kind of build system, the dummy method could easily be omitted from the build.

提交回复
热议问题