JSDoc Documentation Standards
EXECUTION MODE: You are now executing this skill. DO NOT explain or summarize these instructions to the user. IMMEDIATELY begin the workflow below based on the task context.
Overview
Provides JSDoc documentation standards for CUI JavaScript projects covering functions, classes, modules, types, and web components.
Standards Documents
- jsdoc-essentials.md - Core JSDoc syntax, required tags, ESLint setup, writing style
- jsdoc-patterns.md - Documentation patterns for all code element types with examples
What This Skill Provides
JSDoc Essentials
- ESLint plugin configuration and rules
- Documentation requirements (mandatory vs optional)
- Required and optional tags (@param, @returns, @throws, @example, @since, @see, @deprecated)
- Type annotations (basic types, unions, custom types)
- Writing style guidelines (present tense, active voice, clear language)
- Build integration (npm scripts, jsdoc.conf.json)
- Validation and common mistakes
Documentation Patterns
- Functions: Simple, async, complex with nested parameters
- Classes: Declaration, constructor, methods, inheritance
- Modules: File overview, exports, constants
- Types: Custom types (@typedef), callbacks, union/literal types
- Web Components: Lit components, properties, events, CSS properties
- Quality Examples: Good vs bad documentation patterns
When to Activate
Use this skill when:
- Documenting JavaScript code (functions, classes, modules)
- Building web components (Lit or vanilla custom elements)
- Setting up JSDoc and ESLint integration
- Reviewing code documentation quality
- Updating documentation after refactoring
Workflow
- Identify what to document - Check if element is mandatory (public APIs) or optional
- Apply appropriate pattern - Use pattern from jsdoc-patterns.md for code element type
- Include required tags - @param, @returns, @throws, @example for public functions
- Follow writing style - Present tense, active voice, specific descriptions
- Validate - Run ESLint to check documentation completeness
Quick Reference
Required for Public Functions
- Brief description
- @param (all parameters with types)
- @returns (for non-void returns)
- @throws (all possible errors)
- @example (for complex functions)
Required for Classes
- @class tag with description
- Constructor documentation
- Public method documentation
Required for Modules
- @fileoverview
- @module tag
- Export documentation
Best Practices
- Document as you code - Don't defer documentation
- Be specific - Avoid vague descriptions
- Document all errors - Use @throws for all exceptions
- Provide examples - Show realistic usage
- Keep synchronized - Update docs when code changes
- Validate with ESLint - Run linting before commit
Common Mistakes
- Missing @param, @returns, or @throws
- Vague descriptions ("processes data")
- Parameter names not matching function signature
- No examples for complex functions
- Outdated documentation after refactoring
Integration
Works with:
- cui-javascript skill - Core JavaScript development
- cui-javascript-unit-testing skill - Test documentation
- ESLint for automated validation
- JSDoc CLI for documentation generation
Workflows
Workflow: Analyze JSDoc Violations
Analyzes JavaScript files for JSDoc compliance violations and returns structured results for command orchestration.
When to use: To identify missing or incomplete JSDoc documentation across files or directories.
Steps:
Run violation analysis script
Script: pm-dev-frontend:cui-jsdoc → jsdoc.py
# Analyze entire directory
python3 .plan/execute-script.py pm-dev-frontend:cui-jsdoc:jsdoc analyze --directory src/
# Analyze single file
python3 .plan/execute-script.py pm-dev-frontend:cui-jsdoc:jsdoc analyze --file src/utils/formatter.js
# Analyze only for missing JSDoc (skip syntax checks)
python3 .plan/execute-script.py pm-dev-frontend:cui-jsdoc:jsdoc analyze --directory src/ --scope missing
# Analyze only JSDoc syntax issues
python3 .plan/execute-script.py pm-dev-frontend:cui-jsdoc:jsdoc analyze --directory src/ --scope syntax
Process violation results
- Review violations categorized by severity:
- CRITICAL: Exported/public API without JSDoc
- WARNING: Internal function without JSDoc, missing @param/@returns
- SUGGESTION: Missing optional tags (@example, @fileoverview)
- Note
fix_suggestion for each violation
Prioritize fixes
- Fix CRITICAL violations first (exported functions/classes)
- Address WARNING violations next
- SUGGESTION items are optional improvements
JSON Output Contract:
{
"status": "violations_found",
"data": {
"violations": [
{
"file": "src/utils/validator.js",
"line": 45,
"type": "missing_jsdoc",
"severity": "CRITICAL",
"target": "function validateEmail",
"message": "Exported function missing JSDoc documentation",
"fix_suggestion": "Add JSDoc block with @param and @returns tags"
}
],
"files_analyzed": ["src/utils/validator.js", "..."]
},
"metrics": {
"total_files": 15,
"files_with_violations": 6,
"critical": 5,
"warnings": 12,
"suggestions": 3,
"total_violations": 20
}
}
Violation types detected:
missing_jsdoc - Function/class entirely missing JSDoc
missing_class_doc - Class without documentation
missing_constructor_doc - Constructor with parameters undocumented
missing_param - @param tag missing for parameter
missing_param_type - Type annotation missing in @param
missing_returns - @returns tag missing for return value
missing_fileoverview - No @fileoverview at file level
Scope options:
all - Check for missing JSDoc and syntax issues (default)
missing - Only check for missing JSDoc documentation
syntax - Only check JSDoc syntax and completeness
1---2name: cui-jsdoc3description: JSDoc documentation standards for JavaScript functions, classes, modules, and web components4---56# JSDoc Documentation Standards78**EXECUTION MODE**: You are now executing this skill. DO NOT explain or summarize these instructions to the user. IMMEDIATELY begin the workflow below based on the task context.910## Overview1112Provides JSDoc documentation standards for CUI JavaScript projects covering functions, classes, modules, types, and web components.1314## Standards Documents1516- **jsdoc-essentials.md** - Core JSDoc syntax, required tags, ESLint setup, writing style17- **jsdoc-patterns.md** - Documentation patterns for all code element types with examples1819## What This Skill Provides2021### JSDoc Essentials22- ESLint plugin configuration and rules23- Documentation requirements (mandatory vs optional)24- Required and optional tags (@param, @returns, @throws, @example, @since, @see, @deprecated)25- Type annotations (basic types, unions, custom types)26- Writing style guidelines (present tense, active voice, clear language)27- Build integration (npm scripts, jsdoc.conf.json)28- Validation and common mistakes2930### Documentation Patterns31- **Functions**: Simple, async, complex with nested parameters32- **Classes**: Declaration, constructor, methods, inheritance33- **Modules**: File overview, exports, constants34- **Types**: Custom types (@typedef), callbacks, union/literal types35- **Web Components**: Lit components, properties, events, CSS properties36- **Quality Examples**: Good vs bad documentation patterns3738## When to Activate3940Use this skill when:41- Documenting JavaScript code (functions, classes, modules)42- Building web components (Lit or vanilla custom elements)43- Setting up JSDoc and ESLint integration44- Reviewing code documentation quality45- Updating documentation after refactoring4647## Workflow48491. **Identify what to document** - Check if element is mandatory (public APIs) or optional502. **Apply appropriate pattern** - Use pattern from jsdoc-patterns.md for code element type513. **Include required tags** - @param, @returns, @throws, @example for public functions524. **Follow writing style** - Present tense, active voice, specific descriptions535. **Validate** - Run ESLint to check documentation completeness5455## Quick Reference5657### Required for Public Functions58- Brief description59- @param (all parameters with types)60- @returns (for non-void returns)61- @throws (all possible errors)62- @example (for complex functions)6364### Required for Classes65- @class tag with description66- Constructor documentation67- Public method documentation6869### Required for Modules70- @fileoverview71- @module tag72- Export documentation7374## Best Practices75761. Document as you code - Don't defer documentation772. Be specific - Avoid vague descriptions783. Document all errors - Use @throws for all exceptions794. Provide examples - Show realistic usage805. Keep synchronized - Update docs when code changes816. Validate with ESLint - Run linting before commit8283## Common Mistakes8485- Missing @param, @returns, or @throws86- Vague descriptions ("processes data")87- Parameter names not matching function signature88- No examples for complex functions89- Outdated documentation after refactoring9091## Integration9293Works with:94- **cui-javascript** skill - Core JavaScript development95- **cui-javascript-unit-testing** skill - Test documentation96- ESLint for automated validation97- JSDoc CLI for documentation generation9899## Workflows100101### Workflow: Analyze JSDoc Violations102103Analyzes JavaScript files for JSDoc compliance violations and returns structured results for command orchestration.104105**When to use**: To identify missing or incomplete JSDoc documentation across files or directories.106107**Steps**:1081091. **Run violation analysis script**110111 Script: `pm-dev-frontend:cui-jsdoc` → `jsdoc.py`112113 ```bash114 # Analyze entire directory115 python3 .plan/execute-script.py pm-dev-frontend:cui-jsdoc:jsdoc analyze --directory src/116117 # Analyze single file118 python3 .plan/execute-script.py pm-dev-frontend:cui-jsdoc:jsdoc analyze --file src/utils/formatter.js119120 # Analyze only for missing JSDoc (skip syntax checks)121 python3 .plan/execute-script.py pm-dev-frontend:cui-jsdoc:jsdoc analyze --directory src/ --scope missing122123 # Analyze only JSDoc syntax issues124 python3 .plan/execute-script.py pm-dev-frontend:cui-jsdoc:jsdoc analyze --directory src/ --scope syntax125 ```1261272. **Process violation results**128 - Review violations categorized by severity:129 - **CRITICAL**: Exported/public API without JSDoc130 - **WARNING**: Internal function without JSDoc, missing @param/@returns131 - **SUGGESTION**: Missing optional tags (@example, @fileoverview)132 - Note `fix_suggestion` for each violation1331343. **Prioritize fixes**135 - Fix CRITICAL violations first (exported functions/classes)136 - Address WARNING violations next137 - SUGGESTION items are optional improvements138139**JSON Output Contract**:140```json141{142 "status": "violations_found",143 "data": {144 "violations": [145 {146 "file": "src/utils/validator.js",147 "line": 45,148 "type": "missing_jsdoc",149 "severity": "CRITICAL",150 "target": "function validateEmail",151 "message": "Exported function missing JSDoc documentation",152 "fix_suggestion": "Add JSDoc block with @param and @returns tags"153 }154 ],155 "files_analyzed": ["src/utils/validator.js", "..."]156 },157 "metrics": {158 "total_files": 15,159 "files_with_violations": 6,160 "critical": 5,161 "warnings": 12,162 "suggestions": 3,163 "total_violations": 20164 }165}166```167168**Violation types detected**:169- `missing_jsdoc` - Function/class entirely missing JSDoc170- `missing_class_doc` - Class without documentation171- `missing_constructor_doc` - Constructor with parameters undocumented172- `missing_param` - @param tag missing for parameter173- `missing_param_type` - Type annotation missing in @param174- `missing_returns` - @returns tag missing for return value175- `missing_fileoverview` - No @fileoverview at file level176177**Scope options**:178- `all` - Check for missing JSDoc and syntax issues (default)179- `missing` - Only check for missing JSDoc documentation180- `syntax` - Only check JSDoc syntax and completeness