Gry-
Gry-

Reputation: 176

How to get jsdoc generation for parms of class methods that use arrow functions?

I'm a student who's capstone project/work intergrated learning is about to end. I'm working on producing technical documentation to hand off to the next team that will continue on with this work, but I've hit a snag.

My class methods that use arrow functions aren't generating params documentation when I create documentation using the jsdoc tool.

i.e.: Image of the documentation in source code. becomes Image of the resulting jsdoc output.

The documentation works as intended in visual studio code/intellisense: Image of the documentation correctly working in visual studio code for the param

I've been googling around to try and figure out what the problem was, but I failed to find anything.

I mean, my research yielded:

Of note is that I'm using the jsdoc-export-default-interop plugin so that jsdoc will actually generate things for export default [CLASS OR FUNCTION].

Upvotes: 2

Views: 1955

Answers (1)

Gry-
Gry-

Reputation: 176

I've found a solution that fits my requirements

However, while it is good enough for my purposes, I'm not entirely sure it's acurate and would be happy to hear critisims, other people's viewpoints and solutions. I'll explain the concerns I have at the end.

The problem: It looks like jsdoc cannot automatically detect if a member assignment is a function when parsing.

I have no idea why VSCode is able to detect it automatically, but it appears the JSDoc tool cannot. Here it is stated in the official documentation Image of documentation Link to documentation: (https://jsdoc.app/tags-function.html)

The solution: Document the member with the @function tag (or an alias like @method).

By documenting the class member with the @function tag like so: Image of the code documented with the @function tag

I am able to get the arrow function to generate as a class method, and get params documentation: Image of the generated documentation

My concerns

Well the biggest concern/annoyance is now I need to go through all the source code and add a bunch of @function tags. Ah whelp.

Other concerns are that I may have misunderstood the problem/I'm not quite sure if this is best practice.

And I'm not too certain if this documentation is accurate in terms of if there is actually a tangible difference between a class member arrow function and a class method that I need to capture in the API documentation.

Anyway, I think this will be what I go with, but I'll be monitoring this answer to read any input/feedback :)

Upvotes: 4

Related Questions