Skip to content

Commit 1fedbd6

Browse files
🤖 feat(cursor): Add docstring rules (#3187)
* Add python docstrings cursor rule Signed-off-by: Ashwin Vaidya <[email protected]> * Update .cursor/rules/python_docstrings.mdc Signed-off-by: Ashwin Vaidya <[email protected]> --------- Signed-off-by: Ashwin Vaidya <[email protected]> Signed-off-by: Ashwin Vaidya <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent 469dfe4 commit 1fedbd6

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
description: Standards for Python docstrings using Google style
3+
globs: **/*.py
4+
---
5+
6+
# Python Docstring Rules
7+
8+
You are an expert Python developer who writes high-quality, Google-style docstrings.
9+
10+
## General Guidelines
11+
12+
- **Style:** Use Google-style docstrings.
13+
- **Line Length:** Limit docstrings to 120 characters per line.
14+
- **Structure:**
15+
1. **Short Description:** A concise summary of the function, class, or module.
16+
2. **Longer Explanation:** (Optional) detailed description of the behavior.
17+
3. **Args:** Description of arguments.
18+
4. **Returns:** Description of return values.
19+
5. **Raises:** (Optional) Description of raised exceptions.
20+
6. **Example:** Usage examples using doctest style.
21+
22+
## Formatting Details
23+
24+
### Args Section
25+
26+
- List each argument with its type and a description.
27+
- Format: `param_name (type): Description. Defaults to value.`
28+
- If types are long, they can be included in the description or wrapped.
29+
30+
### Returns Section
31+
32+
- Describe the return value and its type.
33+
- Format: `type: Description.`
34+
35+
### Example Section
36+
37+
- Use `>>>` for code examples (doctest style).
38+
- Show the expected output on the following lines.
39+
40+
## Example
41+
42+
```python
43+
def my_function(param1: int, param2: str = "default") -> bool:
44+
"""Short description.
45+
46+
A longer explanation.
47+
48+
Args:
49+
param1 (int): Explanation of param1.
50+
param2 (str): Explanation of param2. Defaults to "default".
51+
52+
Returns:
53+
bool: Explanation of the return value.
54+
55+
Example:
56+
>>> my_function(1, "test")
57+
True
58+
"""
59+
return True
60+
```

0 commit comments

Comments
 (0)