add_comment_before
Insert documentation comments above functions, classes, or statements in code files using Abstract Syntax Tree editing for precise placement.
Instructions
Insert comment line(s) immediately before a named symbol. The comment must include its own comment marker (e.g. '# foo' for Python, '// foo' for JS/C/C++).
Use this when: You want to document a function, class, or statement by adding
an inline comment above it.
Don't use this when: You want a Python function/class docstring -> use
replace_docstring. You want to replace an existing leading comment -> use
replace_leading_comment.
Example: target="LRUCache.get" comment=" # Retrieve an item by key, returning None if absent"
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | ||
| target | Yes | ||
| comment | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |