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, 2022 in Node-js by Vaani
• 7,020 points
440 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, 2022 by Neha
• 8,940 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,840 points
472 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,840 points
1,023 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,840 points
453 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,840 points
2,364 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
1,205 views
0 votes
1 answer
+1 vote
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,450 points
818 views
0 votes
1 answer

What is Node.js? [closed]

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

answered Jun 7, 2022 in Node-js by Neha
• 8,940 points
115 views
0 votes
1 answer

How do I manage MongoDB connections in a Node.js web application?

When the Node.js application starts, create a ...READ MORE

answered Jun 10, 2022 in Node-js by Neha
• 8,940 points
744 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP