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: js-fix-jsdoc3description: Fix JSDoc errors and warnings from build/lint with content preservation4---5
6# JSDoc Documentation Standards
7
8**REFERENCE MODE**: This skill provides reference material. Load specific standards on-demand based on current task.
9
10## Overview
11
12Provides JSDoc documentation standards for CUI JavaScript projects covering functions, classes, modules, types, and web components.
13
14## Standards Documents
15
16- **jsdoc-essentials.md** - Core JSDoc syntax, required tags, ESLint setup, writing style
17- **jsdoc-patterns.md** - Documentation patterns for all code element types with examples
18
19## What This Skill Provides
20
21### JSDoc Essentials
22- ESLint plugin configuration and rules
23- 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 mistakes
29
30### Documentation Patterns
31- **Functions**: Simple, async, complex with nested parameters
32- **Classes**: Declaration, constructor, methods, inheritance
33- **Modules**: File overview, exports, constants
34- **Types**: Custom types (@typedef), callbacks, union/literal types
35- **Web Components**: Lit components, properties, events, CSS properties
36- **Quality Examples**: Good vs bad documentation patterns
37
38## When to Activate
39
40Use 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 integration
44- Reviewing code documentation quality
45- Updating documentation after refactoring
46
47## Workflow
48
491. **Identify what to document** - Check if element is mandatory (public APIs) or optional
502. **Apply appropriate pattern** - Use pattern from jsdoc-patterns.md for code element type
513. **Include required tags** - @param, @returns, @throws, @example for public functions
524. **Follow writing style** - Present tense, active voice, specific descriptions
535. **Validate** - Run ESLint to check documentation completeness
54
55## Quick Reference
56
57### Required for Public Functions
58- Brief description
59- @param (all parameters with types)
60- @returns (for non-void returns)
61- @throws (all possible errors)
62- @example (for complex functions)
63
64### Required for Classes
65- @class tag with description
66- Constructor documentation
67- Public method documentation
68
69### Required for Modules
70- @fileoverview
71- @module tag
72- Export documentation
73
74## Best Practices
75
761. Document as you code - Don't defer documentation
772. Be specific - Avoid vague descriptions
783. Document all errors - Use @throws for all exceptions
794. Provide examples - Show realistic usage
805. Keep synchronized - Update docs when code changes
816. Validate with ESLint - Run linting before commit
82
83## Common Mistakes
84
85- Missing @param, @returns, or @throws
86- Vague descriptions ("processes data")
87- Parameter names not matching function signature
88- No examples for complex functions
89- Outdated documentation after refactoring
90
91## Integration
92
93Works with:
94- **cui-javascript** skill - Core JavaScript development
95- **cui-javascript-unit-testing** skill - Test documentation
96- ESLint for automated validation
97- JSDoc CLI for documentation generation
98
99## Workflows
100
101### Workflow: Analyze JSDoc Violations
102
103Analyzes JavaScript files for JSDoc compliance violations and returns structured results for command orchestration.
104
105**When to use**: To identify missing or incomplete JSDoc documentation across files or directories.
106
107**Steps**:
108
1091. **Run violation analysis script**
110
111 Script: `pm-dev-frontend:cui-jsdoc` → `jsdoc.py`
112
113 ```bash
114 # Analyze entire directory
115 python3 .plan/execute-script.py pm-dev-frontend:cui-jsdoc:jsdoc analyze --directory src/
116
117 # Analyze single file
118 python3 .plan/execute-script.py pm-dev-frontend:cui-jsdoc:jsdoc analyze --file src/utils/formatter.js
119
120 # Analyze only for missing JSDoc (skip syntax checks)
121 python3 .plan/execute-script.py pm-dev-frontend:cui-jsdoc:jsdoc analyze --directory src/ --scope missing
122
123 # Analyze only JSDoc syntax issues
124 python3 .plan/execute-script.py pm-dev-frontend:cui-jsdoc:jsdoc analyze --directory src/ --scope syntax
125 ```
126
1272. **Process violation results**
128 - Review violations categorized by severity:
129 - **CRITICAL**: Exported/public API without JSDoc
130 - **WARNING**: Internal function without JSDoc, missing @param/@returns
131 - **SUGGESTION**: Missing optional tags (@example, @fileoverview)
132 - Note `fix_suggestion` for each violation
133
1343. **Prioritize fixes**
135 - Fix CRITICAL violations first (exported functions/classes)
136 - Address WARNING violations next
137 - SUGGESTION items are optional improvements
138
139**JSON Output Contract**:
140```json
141{
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": 20
164 }
165}
166```
167
168**Violation types detected**:
169- `missing_jsdoc` - Function/class entirely missing JSDoc
170- `missing_class_doc` - Class without documentation
171- `missing_constructor_doc` - Constructor with parameters undocumented
172- `missing_param` - @param tag missing for parameter
173- `missing_param_type` - Type annotation missing in @param
174- `missing_returns` - @returns tag missing for return value
175- `missing_fileoverview` - No @fileoverview at file level
176
177**Scope options**:
178- `all` - Check for missing JSDoc and syntax issues (default)
179- `missing` - Only check for missing JSDoc documentation
180- `syntax` - Only check JSDoc syntax and completeness