|
| 1 | +# Skill: Generate Javadoc |
| 2 | + |
| 3 | +## Purpose |
| 4 | +Generate comprehensive Javadocs for public API interfaces and classes in a specified module, following consistent documentation standards. |
| 5 | + |
| 6 | +## Trigger |
| 7 | +When the user asks to: |
| 8 | +- Generate javadocs for a module |
| 9 | +- Add documentation to public APIs |
| 10 | +- Document interfaces/classes with `@since` tags |
| 11 | + |
| 12 | +## Requirements |
| 13 | + |
| 14 | +### What to Document |
| 15 | +1. **Public API interfaces and classes only** - files in main source packages |
| 16 | +2. **Skip implementation classes** - files in `impl/` packages are NOT documented |
| 17 | +3. **Skip test classes** - files in `src/test/` are NOT documented |
| 18 | + |
| 19 | +### Javadoc Standards |
| 20 | +Each documented element must include: |
| 21 | + |
| 22 | +1. **Class/Interface level:** |
| 23 | + - Short description of purpose |
| 24 | + - `@param` for type parameters (if generic) |
| 25 | + - `@author JavaSaBr` |
| 26 | + - `@since 10.0.0` |
| 27 | + |
| 28 | +2. **Method level:** |
| 29 | + - Short description for ALL methods |
| 30 | + - `@param` and `@return` only for **non-trivial** methods |
| 31 | + - `@since 10.0.0` |
| 32 | + - `@throws` only when explicitly thrown |
| 33 | + |
| 34 | +3. **Constants/Fields:** |
| 35 | + - Short description |
| 36 | + - `@since 10.0.0` |
| 37 | + |
| 38 | +### Example Format |
| 39 | + |
| 40 | +```java |
| 41 | +/** |
| 42 | + * An immutable array interface that provides type-safe, indexed access to elements. |
| 43 | + * |
| 44 | + * @param <E> the type of elements in this array |
| 45 | + * @author JavaSaBr |
| 46 | + * @since 10.0.0 |
| 47 | + */ |
| 48 | +public interface Array<E> extends Iterable<E> { |
| 49 | + |
| 50 | + /** |
| 51 | + * Creates an empty immutable array of the specified type. |
| 52 | + * |
| 53 | + * @param <E> the type of elements |
| 54 | + * @param type the component type of the array |
| 55 | + * @return an empty immutable array |
| 56 | + * @since 10.0.0 |
| 57 | + */ |
| 58 | + static <E> Array<E> empty(Class<? super E> type) { |
| 59 | + // ... |
| 60 | + } |
| 61 | + |
| 62 | + /** |
| 63 | + * Returns the number of elements in this array. |
| 64 | + * |
| 65 | + * @return the number of elements |
| 66 | + * @since 10.0.0 |
| 67 | + */ |
| 68 | + int size(); |
| 69 | + |
| 70 | + /** |
| 71 | + * Returns the element at the specified index. |
| 72 | + * |
| 73 | + * @param index the index of the element to return |
| 74 | + * @return the element at the specified index |
| 75 | + * @throws IndexOutOfBoundsException if the index is out of range |
| 76 | + * @since 10.0.0 |
| 77 | + */ |
| 78 | + E get(int index); |
| 79 | +} |
| 80 | +``` |
| 81 | + |
| 82 | +## Execution Steps |
| 83 | + |
| 84 | +1. **Analyze module structure:** |
| 85 | + ```bash |
| 86 | + ls -la <module>/src/main/java/<package-path>/ |
| 87 | + ``` |
| 88 | + |
| 89 | +2. **Identify public API files:** |
| 90 | + - List all `.java` files in main packages |
| 91 | + - Exclude `impl/` subdirectories |
| 92 | + - Exclude `package-info.java` (optional to document) |
| 93 | + |
| 94 | +3. **Read each file** to understand existing documentation state |
| 95 | + |
| 96 | +4. **Add Javadocs** using `replace_string_in_file` tool: |
| 97 | + - Add class-level Javadoc with description, `@author`, `@since` |
| 98 | + - Add method-level Javadocs with description and `@since` |
| 99 | + - Add `@param`/`@return` only for non-trivial methods |
| 100 | + |
| 101 | +5. **Validate changes:** |
| 102 | + ```bash |
| 103 | + ./gradlew :<module>:compileJava |
| 104 | + ``` |
| 105 | + |
| 106 | +6. **Run full build:** |
| 107 | + ```bash |
| 108 | + ./gradlew :<module>:build |
| 109 | + ``` |
| 110 | + |
| 111 | +7. **Update summary file** at `./summary.md` with documented files |
| 112 | + |
| 113 | +## Output |
| 114 | +- All public API files documented with proper Javadocs |
| 115 | +- Build passes successfully |
| 116 | +- Summary file updated with documentation status |
| 117 | + |
| 118 | +## Notes |
| 119 | +- Use existing code style from the project |
| 120 | +- Preserve existing Javadocs that are already complete (just add `@since` if missing) |
| 121 | +- Group related edits to minimize tool calls |
| 122 | +- Check for errors after editing each file |
0 commit comments