2017-06-05 74 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

相關問題