2017-06-05 68 views
0
/** 
* 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' 
}; 
module.exports = function() { 
    /** 
    * Displays the list of autolab commands along with their functions. 
    * @function 
    * @param {null} 
    */ 
    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()); 
}; 

我试过这个,但html页面只显示lib/help,然后是空白页。我也想用@exports来说明模块导出的内容。还有一种方法可以记录JSDoc中对象的用途和概述。如何使用jsdoc记录模块中的函数?

回答

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()); 
    }; 

也就是有办法

@file标签文档的对象的目的和概述在JSDoc提供文件的描述。在文件开头的JSDoc注释中使用标签。

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

相关问题