JavaDoc Auto Generator
Generate professional, accurate JavaDoc comments for Java methods, constructors, and interface
members with a single keystroke — entirely offline. No OpenAI, no Gemini, no Claude, no
Llama, no cloud service, no backend, no database, no network access of any kind. Everything runs
locally inside VS Code using static code analysis.

Features
- One shortcut, zero setup. Place your cursor inside or above any Java method and press
Ctrl+Alt+J (Cmd+Alt+J on macOS) — or run JavaDoc Auto Generator: Generate JavaDoc for
Method from the Command Palette.
- Batch mode. Run JavaDoc Auto Generator: Generate JavaDoc for All Methods in File to
document an entire file in one pass.
- Deep static parsing — no regex guesswork. Handles:
- Regular, static, final, and synchronized methods
- Constructors
- Interface methods and abstract methods (semicolon-terminated signatures)
- Generic methods (
<T> T identity(T value)) and generic types (List<T>, Map<K, V>,
Optional<T>)
- Arrays (
int[], String[][])
- Varargs (
String... args)
throws clauses with multiple exception types
- Overloaded methods (each overload is documented independently, correctly matching its own
parameter list)
- Nested and inner classes
- Records (canonical constructors) and enums with methods
- Annotated methods (
@Override, @Deprecated, custom annotations are preserved untouched)
- Intelligent descriptions. Method names are decomposed (
getEmployeeName →
"Returns the employee name.", calculateSalary → "Calculates the salary.",
isEnabled → "Checks whether enabled.") and parameter names are matched against a built-in
dictionary (id → "unique identifier", path → "file path", config → "configuration", …).
- Return-type-aware
@return text for booleans, primitives, String, arrays, List, Set,
Map, Optional, and custom objects.
- Never duplicates JavaDoc. If a method already has a
/** ... */ block directly above it,
it's left untouched (unless you opt in to overwriteExisting).
- Preserves indentation and inserts the comment exactly above the method signature.
Example
Input:
public int addNumbers(int a, int b) {
return a + b;
}
Ctrl+SHIFT+Alt+J produces:
/**
* Adds the numbers.
*
* @param a the a parameter
* @param b the b parameter
* @return the resulting numeric value
*/
public int addNumbers(int a, int b) {
return a + b;
}
For richer, well-named signatures the results read naturally out of the box:
public List<Employee> findEmployees(String department, boolean activeOnly) throws ServiceException {
becomes:
/**
* Finds the employees.
*
* @param department department
* @param activeOnly flag indicating whether active only
* @return list containing employees
* @throws ServiceException if a service exception occurs
*/
Static analysis can't read your mind — for terse parameter names like a/b you'll still want
to tighten the wording by hand. The generator gives you a correct, complete scaffold every time
so you never start from a blank comment.
Extension Settings
| Setting |
Default |
Description |
javadocAutoGenerator.authorTag |
false |
Adds a blank @author tag to generated JavaDoc. |
javadocAutoGenerator.sinceTag |
false |
Adds a blank @since tag to generated JavaDoc. |
javadocAutoGenerator.overwriteExisting |
false |
Replaces an existing JavaDoc block instead of skipping the method. |
javadocAutoGenerator.wrapLength |
100 |
Maximum line length before description text wraps. |
The keybinding (Ctrl+Alt+J / Cmd+Alt+J) can be changed from File → Preferences → Keyboard
Shortcuts by searching for "JavaDoc Auto Generator".
Requirements
None. The extension has zero runtime dependencies and makes zero network requests. It only needs
a .java file open in the editor.
How it works (architecture)
src/
model/
JavaMember.ts Shared data model for a parsed method/constructor
parser/
JavaMethodParser.ts Framework-agnostic static analyzer: finds the method under/near the
cursor and extracts modifiers, generics, return type, name,
parameters, throws clause, annotations, and enclosing type
generator/
JavadocGenerator.ts Turns a JavaMember into formatted, indented JavaDoc text
DescriptionDictionary.ts Word/phrase dictionaries for method-name and parameter-name inference
JavaTypeUtils.ts Return-type → @return phrasing (collections, generics, arrays, ...)
utilities/
StringUtils.ts camelCase splitting, text wrapping, indentation helpers
TextUtils.ts Bracket/paren/brace-aware text scanning (handles nested generics)
extension.ts VS Code entry point: commands, keybindings, editor integration
test/
javadoc.test.ts Mocha unit tests covering every supported construct
The parser and generator have no dependency on the vscode module, so the entire analysis
and generation pipeline is unit-tested with plain Mocha (npm test) without needing to launch the
VS Code Extension Host.
Parsing strategy
Rather than a single fragile regular expression, the parser:
- Strips comments while preserving line numbers.
- Scans for every
identifier( that is followed by a valid parameter list and then either { or
; — filtering out method calls (obj.method(...)), object instantiation (new Foo(...)),
and control-flow statements (if (...), for (...), while (...), etc.).
- Walks backward from each candidate to recover its modifiers, generic type parameters, return
type, and annotations, using bracket-depth-aware scanning so nested generics like
Map<String, List<Integer>> are never split incorrectly.
- Resolves which candidate belongs to the cursor: inside a method body → that method; on or above
a signature (including on a blank line, an annotation line, or an existing JavaDoc block) → the
next signature reachable without crossing unrelated code.
Development
npm install
npm run compile # one-off TypeScript build
npm run watch # incremental build
npm run lint # ESLint
npm test # compiles then runs the Mocha unit test suite
Press F5 in VS Code (with this folder open) to launch an Extension Development Host with the
extension loaded — open any .java file and try Ctrl+Alt+J.
Packaging & publishing to the Visual Studio Marketplace
- Update
publisher in package.json to your Marketplace publisher ID (create one for free at
https://marketplace.visualstudio.com/manage if you don't have one, using a Personal Access
Token from https://dev.azure.com).
- Install the packaging CLI (one time):
npm install -g @vscode/vsce
- Build and package:
npm run compile
npm run package # runs `vsce package`, producing javadoc-auto-generator-1.0.0.vsix
- Test the packaged
.vsix locally before publishing:
code --install-extension javadoc-auto-generator-1.0.0.vsix
- Log in and publish:
vsce login <your-publisher-id>
npm run publish # runs `vsce publish`
Alternatively, upload the .vsix manually via the "Manage Publisher" page on the Marketplace.
- Bump
version in package.json (and add an entry to CHANGELOG.md) before every subsequent
publish — vsce publish patch|minor|major will bump and publish in one step.
Known limitations
- Terse or single-letter parameter/method names (
a, b, tmp) produce a generic placeholder
description rather than true semantic meaning — no static analyzer can infer intent that isn't
present in the code. Rename-friendly, descriptive identifiers get the best results.
- The parser targets standard method/constructor/interface-member declarations; it does not
generate JavaDoc for fields, classes, or annotation-type elements in this release (see
CHANGELOG.md for the roadmap).
License
MIT — see LICENSE.