i am documenting a JavaScript API. I am following the google style guide but I found nothing about the order of the tags.
I usually document a variable like this:
/**
* @description Radius of the circle
* @private
* @memberOf Circle
* @type {Number}
* @default
*/
Circle.prototype._radius = 1;
As you can see, I write the tags using my own order, the one I find the most intuitive.
Here is the same documentation with the tags ordered alphabetically:
/**
* @default
* @description Radius of the circle
* @memberOf Circle
* @private
* @type {Number}
*/
Circle.prototype._radius = 1;
Despite, having a well defined order (alphabetically), I find this is a bit confusing, because it messes up with the natural order of the comments. That is why I am looking for a way to write the tags with a specific official order.
Is there even an official order for these tags?
Thanks
There's no official order for JSDoc tags. I tend to put more general tags first, followed by more specific tags, similar to your first example.
In general, JSDoc doesn't care about the tag order, but there are a few notable exceptions:
@desc
(or @description
) tag, as you did in your example.@param
tag to document function parameters, the parameters must use the same order as the function signature.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With