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

I tried this but the html page only shows lib/help and then a blank page. I also wanted to use @exports to mention what the module exports. Also is there a way to document the purpose and overview of the object in JSDoc.

Vaibhav Garg
  • 107
  • 1
  • 8

1 Answers1

0

JSDoc comment block should be before your function declaration...

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

Also is there a way to document the purpose and overview of the object in JSDoc

The @file tag provides a description for a file. Use the tag in a JSDoc comment at the beginning of the file.

Try to get familiar with JSDoc by reading a bit more of documentation.

Slava Ivanov
  • 6,666
  • 2
  • 23
  • 34