-1

I am writing below docblock for one of my app routers. Is it right? also, tell me the meaning of each line as I don't know exactly.

/** * Router serving Activity log page. * @name get/activity_log * @function * @memberof module:routers/activity_log * @inner * @param {string} path - Activity log path * @param {callback} middlewear - Express middlewear. */

router.get('/', function(req, res) {

var async = require('async');
var telemetry = require(modulePath)(req.dbquery,req.nosql);
telemetry.getTelemetryLog(function(err, data) {
    console.log(data);
    if(err) {
        res.send(error);
    } else {
        res.render('_admin/activity_log', {
            title: 'App Admin',
            username: req.session.user.name,
            notifications: req.session.notifications,
            tasks: req.session.tasks,
            telemetry: data
        });
    }
});

});

saurabh r
  • 1
  • 2
  • You need to insert comment code inside code block here. If need more test explain the research you made to reach this point. So that we know what steps you made and can help with the next ones. – dpetrini Dec 11 '17 at 11:06
  • Comment code inserted – saurabh r Dec 12 '17 at 07:05

1 Answers1

0

OK, as for the comments in upper part of code, they are docblock documentation parameters. You can use a documentation generator tool like JSDoc in case of Javascript, if it is meaningful to you.

You can find meaning of the tags like @name, @function, and others in links below:

http://usejsdoc.org/tags-name.html

http://usejsdoc.org/tags-function.html

http://usejsdoc.org/tags-inner.html

http://usejsdoc.org/tags-param.html

and so on.

After all code, or at least part is documented like that, you can generate a HTML content to browse your documentation clearly with hyperlinks. To do this you need to install the JSDoc NPM package:

npm install -g jsdoc

Then you run the command line inside your main code directory indicating all you js files:

jsdoc *.js folder1/*.js folder2/*.js

This command will generate the HTML files for you code documentation in the out/ directory. Open out/index.html to view the documentation.

dpetrini
  • 1,169
  • 1
  • 12
  • 25
  • I know how to use JSDoc but unable to find out their meaning as I found above code in google but I want to use such type docblock in my code, which will make my code more readable. – saurabh r Dec 13 '17 at 11:59
  • Is your doubt about how to use docblock or how to understand the code? If about the code, which lines? – dpetrini Dec 13 '17 at 17:05
  • callback function line and memberof line – saurabh r Dec 15 '17 at 05:20