Hi all, I'd like to discuss documentation comment conventions for classes as part of the migration to JSDoc. In JSDoc, specifically for classes:
- The main description in the documentation comment (or the
@description
tag) is interpreted as the description of the constructor - The
@classdesc
tag is interpreted as the description of the class[1]
These two description fields appear in the documentation site as:
# mw.MyClass
Class description
## Constructor
### new mw.MyClass()
Constructor description
There are two ways this can be formatted in the comment:
1. Constructor description first: Simpler but in reverse order from how the information appears on the documentation site
/**
* Constructor description first line.
*
* Constructor description continued...
*
* @classdesc Class description first line.
*
* Class description continued...
*
* @param string myParam
*/
2. Class description first: More verbose but reflects the same order as the documentation site
/**
* @classdesc Class description first line.
*
* Class description continued...
*
* @description Constructor description first line.
*
* Constructor description continued...
*
* @param string myParam
*/
The empty lines aren't required by JSDoc, but I've included them for readability and consistency with Manual:Coding conventions/Documentation.
Which option should we standardize on? Ideally, we'd be able to use @constructor
instead of @description
, but JSDoc doesn't support that. Of the two options, I think option 2 is the least ambiguous and easiest to reason about.