Target file: $1 Symbol (optional, may be empty): $2
Steps:
- Read the file at path $1.
- Detect the file's language from its extension/syntax and identify that
language's standard doc-comment convention (e.g. Python triple-quoted
docstrings, JSDoc
/** */for JS/TS, Rustdoc///, Godoc comments above the declaration, Javadoc, XML doc comments for C#, etc.). - If $2 is non-empty: find only the function/method/class named $2 in the file. If it already has a doc comment, leave it. If missing, add one. Do not touch any other symbol.
- If $2 is empty: scan the whole file for functions, methods, and classes that have no doc comment (skip ones that already have one). Add one to each.
- For each doc comment you add, base it strictly on what the code actually does — read the function body, parameter usage, and return statement(s). Do not guess intent beyond what the code shows. Include: a one- to two-sentence summary, each parameter (name + purpose inferred from usage), and the return value if any, using the target language's normal doc-comment tags/format (e.g. Args/Returns for Python, @param/@returns for JSDoc, etc.).
- Only insert/edit comment text. Never change code logic, formatting of code lines, imports, or function signatures.
- Use Grep first if the file is large, to locate function/class definitions efficiently, then Edit to insert each doc comment.
- When done, report a short bullet list: which symbols got a new doc comment (with line numbers), and which were already documented and skipped.