CUI JavaDoc Documentation Skill
Standards for writing high-quality JavaDoc documentation in CUI Java projects, ensuring consistency, completeness, and maintainability.
Workflow
Step 1: Load Applicable JavaDoc Standards
CRITICAL: Load current JavaDoc standards to use as enforcement criteria.
Always load foundational JavaDoc standards:
Read: standards/javadoc-core.md
This provides core JavaDoc principles, mandatory documentation requirements, basic tag usage, tag order, anti-patterns, and maintenance guidelines that apply to all JavaDoc documentation.
Conditional loading based on documentation context:
A. If documenting classes, interfaces, packages, enums, or annotations:
Read: standards/javadoc-class-documentation.md
Provides comprehensive standards for package-info.java files, class/interface documentation, abstract classes, enums, annotations, inheritance, serialization, and generic types.
B. If documenting methods or fields:
Read: standards/javadoc-method-documentation.md
Covers method documentation (public, private, overridden), field documentation, constructors, special method patterns (builders, factories, fluent APIs), generic methods, and varargs.
C. If adding code examples or complex formatting:
Read: standards/javadoc-code-examples.md
Provides standards for inline code ({@code}, {@literal}), code blocks (<pre><code>), links ({@link}), HTML formatting, tables, lists, and complete code examples.
Extract key requirements from all loaded standards
Store in working memory for use during task execution
Step 2: Analyze Existing Documentation (if applicable)
If working with existing JavaDoc:
Identify documentation gaps:
- Check which public/protected APIs lack documentation
- Identify incomplete parameter/return/exception documentation
- Find "stating the obvious" documentation that should be improved or removed
- Locate outdated documentation that doesn't match current code
Assess documentation quality:
- Review clarity and usefulness of descriptions
- Check if examples are complete and compilable
- Verify all {@link} references are valid
- Assess tag order and completeness
- Check for proper HTML tag closure
Review consistency:
- Verify consistent terminology across related classes
- Check consistent tag ordering
- Ensure uniform documentation style
- Validate similar APIs are documented similarly
Step 3: Write/Update JavaDoc According to Standards
When writing or updating JavaDoc:
Apply core principles:
- Start with clear purpose statement (what and why)
- Avoid stating the obvious
- Focus on behavior, not implementation
- Document contracts, not code details
- Keep documentation synchronized with code
Use proper tag structure (if applicable):
- Document all parameters with validation rules (@param)
- Document return values with guarantees (@return)
- Document all exceptions with conditions (@throws)
- Add cross-references with @see
- Include version information (@since for public APIs)
- Provide migration path for deprecated APIs (@deprecated)
- Follow standard tag order
Apply class-level documentation (if applicable):
- Create or update package-info.java files
- Document class purpose and behavior
- Include thread-safety statements
- Provide usage examples for complex classes
- Document inheritance relationships
- Document serialization if applicable
Apply method-level documentation (if applicable):
- Document all public/protected methods
- Include parameter constraints and validation rules
- Document return value guarantees and null handling
- Document exception conditions
- Show examples for complex methods
- Document overridden methods if they add behavior
- Use builders/factories/fluent API patterns appropriately
Add code examples and formatting (if applicable):
- Use
{@code} for inline code
- Use
{@literal} for special characters
- Use
{@link} for class/method references
- Create complete, compilable code blocks with
<pre><code>
- Include error handling in examples
- Use HTML formatting (lists, paragraphs, headings) appropriately
- Ensure all HTML tags are properly closed
Step 4: Verify Documentation Quality
Before completing the task:
Verify standards compliance:
Verify completeness:
Generate and review JavaDoc:
# Generate JavaDoc to check for warnings/errors
./mvnw javadoc:javadoc
# Check generated HTML for formatting
open target/site/apidocs/index.html
Verify formatting:
Step 5: Report Results
Provide summary of:
- Documentation created/updated: List classes, methods, packages documented
- Standards applied: Which standards were followed
- Examples added: Code examples and usage patterns included
- Links created: Cross-references and @see tags added
- Any deviations: Document and justify any standard deviations
Quality Verification
Documentation Completeness Checklist
Content Quality Checklist
Format Quality Checklist
Generation Verification
Common Patterns and Examples
Basic Method Documentation
/**
* Validates the JWT token signature and expiration time against the configured
* issuer and clock skew tolerance.
*
* @param token the JWT token to validate, must not be null or empty
* @return validation result containing status and any error messages, never null
* @throws IllegalArgumentException if token is null or empty
* @since 1.2.0
*/
public ValidationResult validate(String token) {
// Implementation
}
Class Documentation with Example
/**
* Validates JWT tokens according to RFC 7519 specifications, verifying
* signature, expiration, and issuer claims.
*
* <p>This validator supports both symmetric (HS256) and asymmetric (RS256)
* signature algorithms.
*
* <p><b>Thread Safety:</b> This class is immutable and thread-safe.
*
* <p>Example usage:
* <pre><code>
* JwtTokenValidator validator = JwtTokenValidator.builder()
* .issuer("https://auth.example.com")
* .clockSkewSeconds(30)
* .build();
*
* ValidationResult result = validator.validate(jwtToken);
* if (!result.isValid()) {
* log.warn("Token validation failed: {}", result.getErrors());
* }
* </code></pre>
*
* @see TokenValidator
* @see ValidationResult
* @since 1.2.0
*/
public class JwtTokenValidator implements TokenValidator {
// Implementation
}
Package Documentation (package-info.java)
/**
* Provides token validation and authentication services for OAuth2 and JWT tokens.
*
* <h2>Key Components</h2>
* <ul>
* <li>{@link de.cuioss.portal.authentication.TokenValidator} - Main validation interface</li>
* <li>{@link de.cuioss.portal.authentication.JwtTokenParser} - JWT token parsing</li>
* <li>{@link de.cuioss.portal.authentication.OAuth2TokenValidator} - OAuth2 validation</li>
* </ul>
*
* <h2>Usage Example</h2>
* <pre><code>
* TokenValidator validator = new JwtTokenValidator(issuerConfig);
* ValidationResult result = validator.validate(bearerToken);
* if (result.isValid()) {
* // Process authenticated request
* }
* </code></pre>
*
* @since 1.0.0
* @author CUI Team
*/
package de.cuioss.portal.authentication;
Builder Pattern Documentation
/**
* Sets the token issuer URL.
*
* @param issuer the issuer URL (must be valid HTTPS URL)
* @return this builder for method chaining
* @throws IllegalArgumentException if issuer is null or not a valid HTTPS URL
*/
public Builder issuer(String issuer) {
// Implementation
return this;
}
/**
* Builds and returns a configured JWT token validator.
*
* @return a new JwtTokenValidator instance with the configured settings, never null
* @throws IllegalStateException if required settings (issuer, publicKey) are not set
*/
public JwtTokenValidator build() {
// Implementation
}
Deprecated API Documentation
/**
* Validates a token using legacy validation rules.
*
* @param token the token to validate
* @return true if valid, false otherwise
* @deprecated since 2.0.0, use {@link #validate(String)} instead which
* returns detailed validation results and supports modern
* token formats. This method will be removed in 3.0.0.
*/
@Deprecated
public boolean validateLegacy(String token) {
// Implementation
}
Common Documentation Tasks
Task: Document a new public class
- Load javadoc-core.md and javadoc-class-documentation.md
- Add class-level JavaDoc with purpose, thread-safety, and example
- Document all public constructors
- Document all public methods with params/returns/exceptions
- Add @since tag with current version
- Generate JavaDoc and verify
Task: Add code examples to existing documentation
- Load javadoc-core.md and javadoc-code-examples.md
- Identify methods that need examples (complex APIs, common use cases)
- Write complete, compilable examples with error handling
- Use proper
<pre><code> formatting
- Ensure examples follow project coding standards
- Generate JavaDoc and verify examples render correctly
Task: Update documentation for API changes
- Load javadoc-core.md and javadoc-method-documentation.md
- Review changed methods/classes
- Update parameter/return/exception documentation
- Add @deprecated tags if removing APIs
- Update @since tags if adding new parameters
- Verify all {@link} references still valid
- Generate JavaDoc and check for warnings
Error Handling
If encountering issues:
- JavaDoc generation errors: Review error messages, fix broken {@link} references and unclosed HTML tags
- Unclear documentation purpose: Review core principles, focus on behavior not implementation
- Missing standards information: Ask user for clarification on specific APIs or patterns
- Complex APIs to document: Break down into steps, provide comprehensive examples
- Deprecated API migration: Document clear migration path with code examples
References
- Core JavaDoc Standards: standards/javadoc-core.md
- Class Documentation: standards/javadoc-class-documentation.md
- Method Documentation: standards/javadoc-method-documentation.md
- Code Examples and Formatting: standards/javadoc-code-examples.md
1---2name: cui-javadoc3description: CUI JavaDoc documentation standards for Java classes, methods, and code examples4---5
6# CUI JavaDoc Documentation Skill
7
8Standards for writing high-quality JavaDoc documentation in CUI Java projects, ensuring consistency, completeness, and maintainability.
9
10## Workflow
11
12### Step 1: Load Applicable JavaDoc Standards
13
14**CRITICAL**: Load current JavaDoc standards to use as enforcement criteria.
15
161. **Always load foundational JavaDoc standards**:
17 ```
18 Read: standards/javadoc-core.md
19 ```
20 This provides core JavaDoc principles, mandatory documentation requirements, basic tag usage, tag order, anti-patterns, and maintenance guidelines that apply to all JavaDoc documentation.
21
222. **Conditional loading based on documentation context**:
23
24 **A. If documenting classes, interfaces, packages, enums, or annotations**:
25 ```
26 Read: standards/javadoc-class-documentation.md
27 ```
28 Provides comprehensive standards for package-info.java files, class/interface documentation, abstract classes, enums, annotations, inheritance, serialization, and generic types.
29
30 **B. If documenting methods or fields**:
31 ```
32 Read: standards/javadoc-method-documentation.md
33 ```
34 Covers method documentation (public, private, overridden), field documentation, constructors, special method patterns (builders, factories, fluent APIs), generic methods, and varargs.
35
36 **C. If adding code examples or complex formatting**:
37 ```
38 Read: standards/javadoc-code-examples.md
39 ```
40 Provides standards for inline code (`{@code}`, `{@literal}`), code blocks (`<pre><code>`), links (`{@link}`), HTML formatting, tables, lists, and complete code examples.
41
423. **Extract key requirements from all loaded standards**
43
444. **Store in working memory** for use during task execution
45
46### Step 2: Analyze Existing Documentation (if applicable)
47
48If working with existing JavaDoc:
49
501. **Identify documentation gaps**:
51 - Check which public/protected APIs lack documentation
52 - Identify incomplete parameter/return/exception documentation
53 - Find "stating the obvious" documentation that should be improved or removed
54 - Locate outdated documentation that doesn't match current code
55
562. **Assess documentation quality**:
57 - Review clarity and usefulness of descriptions
58 - Check if examples are complete and compilable
59 - Verify all {@link} references are valid
60 - Assess tag order and completeness
61 - Check for proper HTML tag closure
62
633. **Review consistency**:
64 - Verify consistent terminology across related classes
65 - Check consistent tag ordering
66 - Ensure uniform documentation style
67 - Validate similar APIs are documented similarly
68
69### Step 3: Write/Update JavaDoc According to Standards
70
71When writing or updating JavaDoc:
72
731. **Apply core principles**:
74 - Start with clear purpose statement (what and why)
75 - Avoid stating the obvious
76 - Focus on behavior, not implementation
77 - Document contracts, not code details
78 - Keep documentation synchronized with code
79
802. **Use proper tag structure** (if applicable):
81 - Document all parameters with validation rules (@param)
82 - Document return values with guarantees (@return)
83 - Document all exceptions with conditions (@throws)
84 - Add cross-references with @see
85 - Include version information (@since for public APIs)
86 - Provide migration path for deprecated APIs (@deprecated)
87 - Follow standard tag order
88
893. **Apply class-level documentation** (if applicable):
90 - Create or update package-info.java files
91 - Document class purpose and behavior
92 - Include thread-safety statements
93 - Provide usage examples for complex classes
94 - Document inheritance relationships
95 - Document serialization if applicable
96
974. **Apply method-level documentation** (if applicable):
98 - Document all public/protected methods
99 - Include parameter constraints and validation rules
100 - Document return value guarantees and null handling
101 - Document exception conditions
102 - Show examples for complex methods
103 - Document overridden methods if they add behavior
104 - Use builders/factories/fluent API patterns appropriately
105
1065. **Add code examples and formatting** (if applicable):
107 - Use `{@code}` for inline code
108 - Use `{@literal}` for special characters
109 - Use `{@link}` for class/method references
110 - Create complete, compilable code blocks with `<pre><code>`
111 - Include error handling in examples
112 - Use HTML formatting (lists, paragraphs, headings) appropriately
113 - Ensure all HTML tags are properly closed
114
115### Step 4: Verify Documentation Quality
116
117Before completing the task:
118
1191. **Verify standards compliance**:
120 - [ ] All public/protected APIs documented
121 - [ ] No "stating the obvious" documentation
122 - [ ] Proper tag order followed
123 - [ ] All parameters/returns/exceptions documented
124 - [ ] @since tags for public APIs
125 - [ ] Migration paths for deprecated APIs
126
1272. **Verify completeness**:
128 - [ ] Class purpose clearly stated
129 - [ ] Thread-safety documented where relevant
130 - [ ] Null handling documented
131 - [ ] Usage examples for complex APIs
132 - [ ] All {@link} references valid
133
1343. **Generate and review JavaDoc**:
135 ```bash
136 # Generate JavaDoc to check for warnings/errors
137 ./mvnw javadoc:javadoc
138
139 # Check generated HTML for formatting
140 open target/site/apidocs/index.html
141 ```
142
1434. **Verify formatting**:
144 - [ ] All HTML tags properly closed
145 - [ ] Code blocks render correctly
146 - [ ] Links work correctly
147 - [ ] Examples are readable and correctly formatted
148
149### Step 5: Report Results
150
151Provide summary of:
152
1531. **Documentation created/updated**: List classes, methods, packages documented
1542. **Standards applied**: Which standards were followed
1553. **Examples added**: Code examples and usage patterns included
1564. **Links created**: Cross-references and @see tags added
1575. **Any deviations**: Document and justify any standard deviations
158
159## Quality Verification
160
161### Documentation Completeness Checklist
162
163- [ ] All public classes/interfaces documented
164- [ ] All public/protected methods documented
165- [ ] Package-info.java files present
166- [ ] All parameters documented with constraints
167- [ ] All return values documented
168- [ ] All exceptions documented with conditions
169- [ ] @since tags present for public APIs
170
171### Content Quality Checklist
172
173- [ ] Clear purpose statements (no "stating the obvious")
174- [ ] Focus on behavior/contracts, not implementation
175- [ ] Examples are complete and compilable
176- [ ] Examples show error handling
177- [ ] Examples follow project coding standards
178- [ ] No outdated documentation
179- [ ] Consistent terminology used
180
181### Format Quality Checklist
182
183- [ ] Proper tag order (param, return, throws, see, since, deprecated)
184- [ ] All {@link} references valid
185- [ ] HTML tags properly closed
186- [ ] Code formatted with {@code} or <pre><code>
187- [ ] Lists use proper HTML tags
188- [ ] Paragraphs separated with <p>
189
190### Generation Verification
191
192- [ ] JavaDoc generation succeeds: `./mvnw javadoc:javadoc`
193- [ ] No warnings or errors in output
194- [ ] Generated HTML displays correctly
195- [ ] Links navigate correctly
196- [ ] Code examples render properly
197
198## Common Patterns and Examples
199
200### Basic Method Documentation
201
202```java
203/**
204 * Validates the JWT token signature and expiration time against the configured
205 * issuer and clock skew tolerance.
206 *
207 * @param token the JWT token to validate, must not be null or empty
208 * @return validation result containing status and any error messages, never null
209 * @throws IllegalArgumentException if token is null or empty
210 * @since 1.2.0
211 */
212public ValidationResult validate(String token) {
213 // Implementation
214}
215```
216
217### Class Documentation with Example
218
219```java
220/**
221 * Validates JWT tokens according to RFC 7519 specifications, verifying
222 * signature, expiration, and issuer claims.
223 *
224 * <p>This validator supports both symmetric (HS256) and asymmetric (RS256)
225 * signature algorithms.
226 *
227 * <p><b>Thread Safety:</b> This class is immutable and thread-safe.
228 *
229 * <p>Example usage:
230 * <pre><code>
231 * JwtTokenValidator validator = JwtTokenValidator.builder()
232 * .issuer("https://auth.example.com")
233 * .clockSkewSeconds(30)
234 * .build();
235 *
236 * ValidationResult result = validator.validate(jwtToken);
237 * if (!result.isValid()) {
238 * log.warn("Token validation failed: {}", result.getErrors());
239 * }
240 * </code></pre>
241 *
242 * @see TokenValidator
243 * @see ValidationResult
244 * @since 1.2.0
245 */
246public class JwtTokenValidator implements TokenValidator {
247 // Implementation
248}
249```
250
251### Package Documentation (package-info.java)
252
253```java
254/**
255 * Provides token validation and authentication services for OAuth2 and JWT tokens.
256 *
257 * <h2>Key Components</h2>
258 * <ul>
259 * <li>{@link de.cuioss.portal.authentication.TokenValidator} - Main validation interface</li>
260 * <li>{@link de.cuioss.portal.authentication.JwtTokenParser} - JWT token parsing</li>
261 * <li>{@link de.cuioss.portal.authentication.OAuth2TokenValidator} - OAuth2 validation</li>
262 * </ul>
263 *
264 * <h2>Usage Example</h2>
265 * <pre><code>
266 * TokenValidator validator = new JwtTokenValidator(issuerConfig);
267 * ValidationResult result = validator.validate(bearerToken);
268 * if (result.isValid()) {
269 * // Process authenticated request
270 * }
271 * </code></pre>
272 *
273 * @since 1.0.0
274 * @author CUI Team
275 */
276package de.cuioss.portal.authentication;
277```
278
279### Builder Pattern Documentation
280
281```java
282/**
283 * Sets the token issuer URL.
284 *
285 * @param issuer the issuer URL (must be valid HTTPS URL)
286 * @return this builder for method chaining
287 * @throws IllegalArgumentException if issuer is null or not a valid HTTPS URL
288 */
289public Builder issuer(String issuer) {
290 // Implementation
291 return this;
292}
293
294/**
295 * Builds and returns a configured JWT token validator.
296 *
297 * @return a new JwtTokenValidator instance with the configured settings, never null
298 * @throws IllegalStateException if required settings (issuer, publicKey) are not set
299 */
300public JwtTokenValidator build() {
301 // Implementation
302}
303```
304
305### Deprecated API Documentation
306
307```java
308/**
309 * Validates a token using legacy validation rules.
310 *
311 * @param token the token to validate
312 * @return true if valid, false otherwise
313 * @deprecated since 2.0.0, use {@link #validate(String)} instead which
314 * returns detailed validation results and supports modern
315 * token formats. This method will be removed in 3.0.0.
316 */
317@Deprecated
318public boolean validateLegacy(String token) {
319 // Implementation
320}
321```
322
323## Common Documentation Tasks
324
325### Task: Document a new public class
326
3271. Load javadoc-core.md and javadoc-class-documentation.md
3282. Add class-level JavaDoc with purpose, thread-safety, and example
3293. Document all public constructors
3304. Document all public methods with params/returns/exceptions
3315. Add @since tag with current version
3326. Generate JavaDoc and verify
333
334### Task: Add code examples to existing documentation
335
3361. Load javadoc-core.md and javadoc-code-examples.md
3372. Identify methods that need examples (complex APIs, common use cases)
3383. Write complete, compilable examples with error handling
3394. Use proper `<pre><code>` formatting
3405. Ensure examples follow project coding standards
3416. Generate JavaDoc and verify examples render correctly
342
343### Task: Update documentation for API changes
344
3451. Load javadoc-core.md and javadoc-method-documentation.md
3462. Review changed methods/classes
3473. Update parameter/return/exception documentation
3484. Add @deprecated tags if removing APIs
3495. Update @since tags if adding new parameters
3506. Verify all {@link} references still valid
3517. Generate JavaDoc and check for warnings
352
353## Error Handling
354
355If encountering issues:
356
3571. **JavaDoc generation errors**: Review error messages, fix broken {@link} references and unclosed HTML tags
3582. **Unclear documentation purpose**: Review core principles, focus on behavior not implementation
3593. **Missing standards information**: Ask user for clarification on specific APIs or patterns
3604. **Complex APIs to document**: Break down into steps, provide comprehensive examples
3615. **Deprecated API migration**: Document clear migration path with code examples
362
363## References
364
365* Core JavaDoc Standards: standards/javadoc-core.md
366* Class Documentation: standards/javadoc-class-documentation.md
367* Method Documentation: standards/javadoc-method-documentation.md
368* Code Examples and Formatting: standards/javadoc-code-examples.md