What it does
Code Documentor reads a function, class, or module and generates production-quality documentation in the appropriate format for the target language. Rather than regurgitating type signatures, it reads the function body to understand what the code actually does — the preconditions, the side effects, why it might throw, and what a good usage example looks like.
The result is documentation that a new team member can actually learn from, not just a verbatim restatement of the type annotations.
How to install
npx plugins add code-docs
Supported doc formats
- JSDoc — TypeScript and JavaScript (
@param,@returns,@throws,@example) - Google style — Python docstrings with Args / Returns / Raises sections
- NumPy style — Python scientific / data science convention
- Rust doc comments —
///with Panics, Safety, Examples sections - Go godoc — package and function comments
Example
export function rotateRefreshToken( userId: string, oldToken: string ): Promise<TokenPair> { const stored = await tokenStore.get(userId); if (stored !== oldToken) throw new InvalidTokenError(); const newPair = await tokenIssuer.issue(userId); await tokenStore.set(userId, newPair.refresh); return newPair; }
/**
* Rotates a user's refresh token using the sliding-window
* strategy, invalidating the old token and issuing a new pair.
*
* The old token must exactly match the value currently stored
* for the user; a mismatch indicates a replay attack and causes
* the function to throw without issuing new credentials.
*
* @param userId - Stable user identifier from the auth database.
* @param oldToken - The refresh token the client is exchanging.
* @returns A new `TokenPair` containing both access and refresh tokens.
* @throws {InvalidTokenError} If `oldToken` does not match the stored token.
*
* @example
* const { access, refresh } = await rotateRefreshToken(user.id, req.cookies.rt);
* res.cookie('rt', refresh, { httpOnly: true });
*/
Configuration
{
"code-docs": {
"style": "jsdoc",
"include-examples": true,
"include-throws": true,
"language": "auto"
}
}
Tip: Run Code Documentor across an entire directory before opening a PR. Ask Claude to document all exported functions in src/api/ in one pass — it processes them in parallel and writes the docs back to the files directly.