Skip to content
Advertisement

Best way to document anonymous objects and functions with jsdoc

Edit: This is technically a 2 part question. I’ve chosen the best answer that covers the question in general and linked to the answer that handles the specific question.

What is the best way to document anonymous objects and functions with jsdoc?

JavaScript

Neither the PageRequest object or the callback exist in code. They will be provided to getPage() at runtime. But I would like to be able to define what the object and function are.

I can get away with creating the PageRequest object to document that:

JavaScript

And that’s fine (though I’m open to better ways to do this).

What is the best way to document the callback function? I want to make it know in the document that, for example, the callback function is in the form of:

JavaScript

Any ideas how to do this?

Advertisement

Answer

You can document stuff that doesnt exist in the code by using the @name tag.

JavaScript

Here is the @name tag documentation. You might find name paths useful too.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement