如何使用jsdoc记录模块中的函数?

时间:2017-06-05 05:26:59

标签: documentation jsdoc jsdoc3

# Fix the version until https://github.com/rubys/nokogumbo/issues/25 gets fixed
gem 'nokogumbo', '= 1.4.11'

我试过这个,但html页面只显示了lib / help,然后是空白页面。我还想用@exports来提一下模块输出的内容。还有一种方法可以在JSDoc中记录对象的用途和概述。

1 个答案:

答案 0 :(得分:0)

JSDoc评论块应该在您的function声明之前......

    /**
    * Displays the list of autolab commands along with their functions.
    * @module lib/help
    */
    var Table = require('cli-table');
    var chalk = require('chalk');
    var helpjson = {
        'init': 'Initializes local repository and authenticates',
        'exit': 'Wipes off the credentials from the system',
        'git create': 'Creates a repository on Gitlab',
        'git delete': 'Deletes the specified repository from Gitlab',
        'git changeserver': 'To change the host of Gitlab',
        'git changelang': 'To change the language of the code submission',
        'git push': 'Adds, commits, pushes the code',
        'submit': 'To submit the code to JavaAutolab and fetch the results',
        'help': 'Print help manual'
    };
    /**
    * Displays the list of autolab commands along with their functions.
    * @function
    * @param {null}
    */
    module.exports = function () {
        console.log('\n' + chalk.blue('Usage:') + ' autolab [OPTIONS]');
        var table = new Table({
            head: ['Options:', ''],
            colWidths: [20, 70]
        });
        for (var key in helpjson)
            table.push(
                [key, helpjson[key]]
                );
        console.log(table.toString());
    };
  

还有一种方法可以在JSDoc

中记录对象的用途和概述

@file标记提供文件的描述。在文件开头的JSDoc注释中使用标记。

通过阅读更多文档,尝试熟悉JSDoc