|
| 1 | +# Coding Instructions for LLM Tools |
| 2 | + |
| 3 | +## Purpose |
| 4 | +Guidelines for LLMs (e.g., GitHub Copilot) to generate, edit, and review code in the Flaggle project. |
| 5 | + |
| 6 | +## Coding Standards |
| 7 | +- Follow [PEP 8](https://peps.python.org/pep-0008/) for style. |
| 8 | +- Use type annotations for all public functions and methods. |
| 9 | +- Use Google-style docstrings for all public classes and methods. |
| 10 | +- Prefer explicit, readable code over cleverness. |
| 11 | +- Use triple double quotes (`"""`) for docstrings. |
| 12 | +- Add examples in docstrings for public APIs. |
| 13 | +- Use `from ... import ...` for imports within the package. |
| 14 | + |
| 15 | +## Docstring Directives |
| 16 | +- **Short docstring**: Use for simple, self-explanatory functions or classes. One concise sentence, no blank line after the summary. |
| 17 | +- **Long docstring**: Use for public, complex, or reusable code. Structure: |
| 18 | + - First line: short summary. |
| 19 | + - Blank line. |
| 20 | + - Extended description (optional). |
| 21 | + - Args: List all parameters, their types, and descriptions. |
| 22 | + - Returns: Describe the return type and meaning. |
| 23 | + - Raises: List exceptions that may be raised. |
| 24 | + - Attributes: For classes, document all public attributes. |
| 25 | + - Examples: (Optional) Add usage examples for clarity, using indented code blocks in docstrings and fenced code blocks (```python) in markdown/README. |
| 26 | +- **Tone**: Use clear, concise, and neutral language. |
| 27 | +- **Formatting**: Use triple double quotes (`"""`) and follow [PEP 257](https://peps.python.org/pep-0257/). |
| 28 | +- **Compatibility**: This template is compatible with VS Code, PyCharm, Sphinx, and most Python docstring tools. Structure is inspired by Google and NumPy conventions. |
| 29 | + |
| 30 | +## File Structure |
| 31 | +- Place new features in the appropriate module under `python_flaggle/`. |
| 32 | +- Place all tests in `tests/`. |
| 33 | + |
| 34 | +## Testing |
| 35 | +- All new code must be covered by tests. |
| 36 | +- Use `pytest` for all tests. |
| 37 | +- Strive for 100% code coverage. |
| 38 | +- Test both typical and edge cases. |
| 39 | + |
| 40 | +## Example Docstring |
| 41 | +```python |
| 42 | +class MyClass: |
| 43 | + """ |
| 44 | + Short summary of the class. |
| 45 | +
|
| 46 | + Attributes: |
| 47 | + attr1 (type): Description. |
| 48 | + """ |
| 49 | + def my_method(self, param1: int) -> bool: |
| 50 | + """ |
| 51 | + Short summary of the method. |
| 52 | +
|
| 53 | + Args: |
| 54 | + param1 (int): Description. |
| 55 | + Returns: |
| 56 | + bool: Description. |
| 57 | + Example: |
| 58 | + ```python |
| 59 | + obj = MyClass() |
| 60 | + obj.my_method(1) |
| 61 | + ``` |
| 62 | + """ |
| 63 | +``` |
0 commit comments