JSDoc Documentation Standards
REFERENCE MODE: This skill provides reference material. Load specific standards on-demand based on current task.
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-jsdoc-23description: JSDoc documentation standards for JavaScript functions, classes, modules, and web components4---56# JSDoc Documentation Standards78**REFERENCE MODE**: This skill provides reference material. Load specific standards on-demand based on current task.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 Essentials2223- ESLint plugin configuration and rules24- Documentation requirements (mandatory vs optional)25- Required and optional tags (@param, @returns, @throws, @example, @since, @see, @deprecated)26- Type annotations (basic types, unions, custom types)27- Writing style guidelines (present tense, active voice, clear language)28- Build integration (npm scripts, jsdoc.conf.json)29- Validation and common mistakes3031### Documentation Patterns3233- **Functions**: Simple, async, complex with nested parameters34- **Classes**: Declaration, constructor, methods, inheritance35- **Modules**: File overview, exports, constants36- **Types**: Custom types (@typedef), callbacks, union/literal types37- **Web Components**: Lit components, properties, events, CSS properties38- **Quality Examples**: Good vs bad documentation patterns3940## When to Activate4142Use this skill when:4344- Documenting JavaScript code (functions, classes, modules)45- Building web components (Lit or vanilla custom elements)46- Setting up JSDoc and ESLint integration47- Reviewing code documentation quality48- Updating documentation after refactoring4950## Workflow51521. **Identify what to document** - Check if element is mandatory (public APIs) or optional532. **Apply appropriate pattern** - Use pattern from jsdoc-patterns.md for code element type543. **Include required tags** - @param, @returns, @throws, @example for public functions554. **Follow writing style** - Present tense, active voice, specific descriptions565. **Validate** - Run ESLint to check documentation completeness5758## Quick Reference5960### Required for Public Functions6162- Brief description63- @param (all parameters with types)64- @returns (for non-void returns)65- @throws (all possible errors)66- @example (for complex functions)6768### Required for Classes6970- @class tag with description71- Constructor documentation72- Public method documentation7374### Required for Modules7576- @fileoverview77- @module tag78- Export documentation7980## Best Practices81821. Document as you code - Don't defer documentation832. Be specific - Avoid vague descriptions843. Document all errors - Use @throws for all exceptions854. Provide examples - Show realistic usage865. Keep synchronized - Update docs when code changes876. Validate with ESLint - Run linting before commit8889## Common Mistakes9091- Missing @param, @returns, or @throws92- Vague descriptions ("processes data")93- Parameter names not matching function signature94- No examples for complex functions95- Outdated documentation after refactoring9697## Integration9899Works with:100101- **cui-javascript** skill - Core JavaScript development102- **cui-javascript-unit-testing** skill - Test documentation103- ESLint for automated validation104- JSDoc CLI for documentation generation105106## Workflows107108### Workflow: Analyze JSDoc Violations109110Analyzes JavaScript files for JSDoc compliance violations and returns structured results for command orchestration.111112**When to use**: To identify missing or incomplete JSDoc documentation across files or directories.113114**Steps**:1151161. **Run violation analysis script**117118 Script: `pm-dev-frontend:cui-jsdoc` → `jsdoc.py`119120 ```bash121 # Analyze entire directory122 python3 .plan/execute-script.py pm-dev-frontend:cui-jsdoc:jsdoc analyze --directory src/123124 # Analyze single file125 python3 .plan/execute-script.py pm-dev-frontend:cui-jsdoc:jsdoc analyze --file src/utils/formatter.js126127 # Analyze only for missing JSDoc (skip syntax checks)128 python3 .plan/execute-script.py pm-dev-frontend:cui-jsdoc:jsdoc analyze --directory src/ --scope missing129130 # Analyze only JSDoc syntax issues131 python3 .plan/execute-script.py pm-dev-frontend:cui-jsdoc:jsdoc analyze --directory src/ --scope syntax132 ```1331342. **Process violation results**135 - Review violations categorized by severity:136 - **CRITICAL**: Exported/public API without JSDoc137 - **WARNING**: Internal function without JSDoc, missing @param/@returns138 - **SUGGESTION**: Missing optional tags (@example, @fileoverview)139 - Note `fix_suggestion` for each violation1401413. **Prioritize fixes**142 - Fix CRITICAL violations first (exported functions/classes)143 - Address WARNING violations next144 - SUGGESTION items are optional improvements145146**JSON Output Contract**:147148```json149{150 "status": "violations_found",151 "data": {152 "violations": [153 {154 "file": "src/utils/validator.js",155 "line": 45,156 "type": "missing_jsdoc",157 "severity": "CRITICAL",158 "target": "function validateEmail",159 "message": "Exported function missing JSDoc documentation",160 "fix_suggestion": "Add JSDoc block with @param and @returns tags"161 }162 ],163 "files_analyzed": ["src/utils/validator.js", "..."]164 },165 "metrics": {166 "total_files": 15,167 "files_with_violations": 6,168 "critical": 5,169 "warnings": 12,170 "suggestions": 3,171 "total_violations": 20172 }173}174```175176**Violation types detected**:177178- `missing_jsdoc` - Function/class entirely missing JSDoc179- `missing_class_doc` - Class without documentation180- `missing_constructor_doc` - Constructor with parameters undocumented181- `missing_param` - @param tag missing for parameter182- `missing_param_type` - Type annotation missing in @param183- `missing_returns` - @returns tag missing for return value184- `missing_fileoverview` - No @fileoverview at file level185186**Scope options**:187188- `all` - Check for missing JSDoc and syntax issues (default)189- `missing` - Only check for missing JSDoc documentation190- `syntax` - Only check JSDoc syntax and completeness