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,070 points
1,571 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.

To know more about Node JS, It's recommended to join Node JS Certification today.

answered Jun 16, 2022 by Neha
• 9,020 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
1,056 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,632 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
932 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
3,277 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,947 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,470 views
+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 ...READ MORE

answered Aug 6, 2018 in Blockchain by aryya
• 7,460 points
1,461 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
• 9,020 points
487 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
• 9,020 points
1,995 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