JSDoc Guide
What is JSDoc?
JSDoc is a standard for documenting JavaScript/TypeScript code using special comments. It helps generate documentation and improves code readability and editor intellisense.
How to Use
- Add JSDoc comments above functions, classes, and modules.
- Use
/** ... */syntax.
Example
typescript
/**
* Returns the sum of two numbers.
* @param {number} a - First number
* @param {number} b - Second number
* @returns {number} Sum of a and b
*/
function add(a: number, b: number): number {
return a + b;
}Generating Docs
Install JSDoc (optional, for JS projects):
shnpm install --save-dev jsdocRun JSDoc to generate HTML docs:
shnpx jsdoc src -r -d docs/jsdoc(For TypeScript, consider TypeDoc.)
Tips
- Document all public functions and classes.
- Use
@param,@returns, and@exampletags. - Keep comments up to date as code changes.
