a blog for those who code

Tuesday 21 June 2016

Docco - A Node.js powered JavaScript Documentation Generator

In this post we will be discussing about Docco, a node.js powered JavaScript documentation generation tool. Docco is a quick and dirty documentation generator, which produces HTML document that displays your comments intermingles with your code.


As shown in the image above you can install Docco from NPM using the command npm install -g docco


Lets take an example. I have the following code where each segment is given a comment

//How to Convert Objects to XML

// At first require objects and xml2js
var objects = require('./objects'),
xml2js = require('xml2js');

// Build XML values using xml2js 
var xmlValues = new xml2js.Builder({rootname : 'objects'});
convertedObjects = xmlValues.buildObject(objects);
console.log(convertedObjects);

//Convert XML to Objects
xml2js.parseString (convertedObjects, {
  explicitArray: false,
  explicitRoot: false
}, function(err, obj) {
  console.log(obj);
});

//Done Conversion

When I run the conversion using docco convert.js it will give you a message like below :


When you open convert.html, you will see something like below :


Please Like and Share the CodingDefined Blog, if you find it interesting and helpful.

No comments:

Post a Comment