Skip to content

Commit ebbe40c

Browse files
oasaphoasaph
andauthored
📝 feat(docs): add comprehensive documentation(#12)
Co-authored-by: oasaph <contato@asaph.dev>
1 parent 32818ee commit ebbe40c

9 files changed

Lines changed: 401 additions & 16 deletions

File tree

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
```
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Commit Message Instructions for LLM Tools
2+
3+
## Purpose
4+
Guidelines for LLMs to generate clear, conventional commit messages for the Flaggle project.
5+
6+
## Format
7+
- Use [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/):
8+
- `type(scope): subject`
9+
- Example: `feat(flag): add support for float flag types`
10+
- Types: feat, fix, docs, style, refactor, test, chore
11+
- Use imperative mood (e.g., "add", not "adds")
12+
- Limit subject line to 72 characters
13+
- Use body to explain what and why, not how (if needed)
14+
- Reference issues or PRs if relevant
15+
16+
## Examples
17+
- `fix(flaggle): handle ValueError in _fetch_flags`
18+
- `docs(readme): clarify JSON schema for flags endpoint`
19+
- `test(flag): add test for else branch in is_enabled`
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Documentation Instructions for LLM Tools
2+
3+
## Purpose
4+
Guidelines for LLMs to generate and update documentation in the Flaggle project.
5+
6+
## General Principles
7+
- All public APIs must be documented in `README.md` and/or module docstrings.
8+
- Use Markdown fenced code blocks (```python) for examples.
9+
- Use clear, concise, and neutral language.
10+
- Document the JSON schema for the flags endpoint.
11+
- Update the Table of Contents if new sections are added.
12+
13+
## README.md Structure
14+
- Overview
15+
- Features
16+
- Installation
17+
- Getting Started
18+
- Flaggle Class: Configuration & Usage
19+
- Supported Operations
20+
- Advanced Usage: The Flag Class
21+
- JSON Schema for Flags Endpoint
22+
- Contributing
23+
- License
24+
- TODO / Roadmap
25+
26+
## Best Practices
27+
- Use headings and subheadings for clarity.
28+
- Add usage examples for all major features.
29+
- Keep documentation up to date with code changes.
30+
- Add a changelog entry for significant documentation updates.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Pull Request Body Instructions for LLM Tools
2+
3+
## Purpose
4+
Guidelines for LLMs to generate clear, informative PR bodies for the Flaggle project.
5+
6+
## Structure
7+
- **Summary**: Briefly describe what the PR does.
8+
- **Motivation**: Why is this change needed?
9+
- **Changes**: List major changes (new features, bug fixes, refactors, docs, tests).
10+
- **Testing**: Describe how the change was tested.
11+
- **Checklist**:
12+
- [ ] Code follows style and docstring guidelines
13+
- [ ] Tests added/updated and passing
14+
- [ ] Documentation updated
15+
- [ ] No unrelated changes
16+
- **Related Issues/PRs**: Reference any related issues or pull requests.
17+
18+
## Example
19+
```
20+
## Summary
21+
Add async support to Flaggle's flag fetching.
22+
23+
## Motivation
24+
Async support allows non-blocking flag updates in async applications.
25+
26+
## Changes
27+
- Add async versions of fetch/update methods
28+
- Update tests for async
29+
- Update README with async usage
30+
31+
## Testing
32+
- Added new async tests
33+
- All tests pass locally
34+
35+
## Checklist
36+
- [x] Code follows style and docstring guidelines
37+
- [x] Tests added/updated and passing
38+
- [x] Documentation updated
39+
- [x] No unrelated changes
40+
41+
## Related Issues/PRs
42+
Closes #42
43+
```

.vscode/settings.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,19 @@
33
"tests"
44
],
55
"python.testing.unittestEnabled": false,
6-
"python.testing.pytestEnabled": true
6+
"python.testing.pytestEnabled": true,
7+
"github.copilot.chat.codeGeneration.enabled": true,
8+
"github.copilot.chat.codeGeneration.instructions": [
9+
{
10+
"file": ".github/instructions/INSTRUCTIONS_CODE.md",
11+
},
12+
{
13+
"file": ".github/instructions/INSTRUCTIONS_DOCS.md",
14+
}
15+
],
16+
"github.copilot.chat.commitMessageGeneration.instructions": [
17+
{
18+
"file": ".github/instructions/INSTRUCTIONS_COMMITS.md",
19+
}
20+
],
721
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,6 @@ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file
238238
- [ ] **Async Support:** Add async/await support for non-blocking flag fetching and updates.
239239
- [ ] **Type Annotations & Validation:** Improve type safety and validation for flag values and operations.
240240
- [ ] **Better Error Handling & Logging:** More granular error reporting and logging options.
241-
- [ ] **Extensive Documentation & Examples:** Expand documentation with more real-world usage patterns and advanced scenarios.
241+
- [x] **Extensive Documentation & Examples:** Expand documentation with more real-world usage patterns and advanced scenarios.
242242

243243
Contributions and suggestions are welcome! Please open an issue or pull request if you have ideas for improvements.

python_flaggle/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
"""Flaggle: Python feature flag management library.
2+
3+
This package provides the Flaggle class for managing feature flags, as well as the Flag, FlagType, and FlagOperation classes for defining and evaluating individual flags.
4+
5+
Exports:
6+
Flaggle: Main entry point for feature flag management.
7+
Flag: Represents a single feature flag.
8+
FlagType: Enum of supported flag value types.
9+
FlagOperation: Enum of supported flag operations.
10+
"""
11+
112
from python_flaggle.flaggle import Flaggle
213
from python_flaggle.flag import Flag, FlagOperation, FlagType
314

0 commit comments

Comments
 (0)