@lxgicstudios/ai-docs
v1.0.0
Published
Add JSDoc/TSDoc comments to your source files using OpenAI
Readme
ai-docs
Adds JSDoc or TSDoc comments to your code. Point it at files or a directory and it'll document your exported functions, classes, and interfaces without touching any logic.
Install
npm install -g ai-docsSetup
export OPENAI_API_KEY=sk-your-key-hereUsage
# Preview docs for a directory (prints to stdout)
npx ai-docs src/ --style jsdoc
# TSDoc style
npx ai-docs src/ --style tsdoc
# Actually write the changes back to the files
npx ai-docs src/ --style jsdoc --write
# Single file
npx ai-docs src/utils.ts --style jsdoc
# Glob patterns work too
npx ai-docs "src/**/*.ts" --style tsdocWhat it does
Reads each file, sends it to OpenAI, gets back the same file with doc comments added to all the exported stuff. It won't change your code. It just adds comments above functions, classes, interfaces, and types.
Tips
- Run without
--writefirst to preview what it'll do - It skips files over 20KB (they'd blow the context window anyway)
- Automatically ignores node_modules and dist folders
