Documenting Node js projects

0 votes

I'm presently documenting my code with JSDoc Toolkit, but it's not quite right - in particular, it seems to struggle with accurately specifying namespaces. Let's say each of their files contains two simple classes:

lib/database/foo.js:

/** @class */
function Foo(...) {...}

/** @function ... */
Foo.prototype.init(..., cb) { return cb(null, ...); };

module.exports = foo;

And then something inherited lib/database/bar.js:

var Foo = require('./foo');

/**
 * @class
 * @augments Foo
 */
function Bar(....) {...}

util.inherits(Bar, Foo);

Bar.prototype.moreInit(..., cb) { return cb(null, ...); };

This is displayed simply as Foo and Bar in the generated documentation, without the leading database (or lib.database), which is required when you don't have everything in a global scope.

I've tried both the @namespace and @name databases.

It's a waste of time, but it doesn't turn out well.

Any suggestions for improving JSDoc's output or finding a new tool that works better with Node.js? (I skimmed over Natural Docs and JSDuck, as well as a few others that appeared to be out of date...)

Jun 15 in Node-js by Vaani
• 7,020 points
10 views

1 answer to this question.

0 votes
JSDoc is a JavaDoc port. As a result, the documentation assumes traditional OOP, which is incompatible with JavaScript.

Personally, I would suggest annotating your source code with docco. Underscore, backbone, and docco are all examples of it.

Groc is a decent alternative to docco.

In terms of actual API documentation, I personally believe that auto-generated documentation based on comments does not work well with JavaScript and that you should create your API documentation by hand.

Underscore API, Express API, nodejs API, and socket.io documentation are other examples.
answered Jun 16 by Neha
• 8,560 points

Related Questions In Node-js

+2 votes
1 answer

How do I debug Node.js applications?

Hello @kartik, Use node-inspector  from any browser supporting WebSocket. Breakpoints, ...READ MORE

answered Jul 8, 2020 in Node-js by Niroj
• 82,720 points
346 views
0 votes
1 answer

How to read environment variables in Node.js?

Hello @kartik, Yes,you can read environment variables in Node.js ...READ MORE

answered Jul 8, 2020 in Node-js by Niroj
• 82,720 points
765 views
0 votes
1 answer

How to write files in Node.js?

Hello @kartik, Currently there are three ways to ...READ MORE

answered Jul 8, 2020 in Node-js by Niroj
• 82,720 points
331 views
0 votes
1 answer

How to get GET (query string) variables in Express.js on Node.js?

Hello @kartik, Since you've mentioned Express.js in your ...READ MORE

answered Jul 8, 2020 in Node-js by Niroj
• 82,720 points
1,860 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
967 views
0 votes
1 answer
0 votes
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured by TLS encryption in hashgraph architecture-hashgraph, ...READ MORE

answered Aug 6, 2018 in Blockchain by aryya
• 7,440 points
622 views
0 votes
1 answer

What is Node.js? [closed]

At work, I use Node.js and find ...READ MORE

answered Jun 7 in Node-js by Neha
• 8,560 points
15 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP