๐ค Contributing Guide¶
Thank you for your interest in the EmailWidget project! We welcome all forms of contributions, whether code, documentation, testing, or feedback suggestions.
๐ฏ Ways to Contribute¶
๐ Code Contributions¶
- ๐ Bug Fixes - Help us fix known issues
- โจ New Features - Add new Widgets or functionality
- โก Performance Optimization - Improve code performance and efficiency
- ๐ง Refactoring - Improve code structure and maintainability
๐ Documentation Contributions¶
- ๐ Improve Documentation - Enhance existing documentation
- ๐ก Add Examples - Provide more usage examples
- ๐ Translation - Help translate documentation to other languages
- ๐น Tutorials - Create video or illustrated tutorials
๐งช Testing Contributions¶
- ๐ Write Tests - Add tests for existing functionality
- ๐ Report Bugs - Find and report issues
- ๐ Performance Testing - Test performance in different environments
๐ Quick Start¶
1. ๐ด Fork the Project¶
Click the "Fork" button in the top right corner of the GitHub page to copy the project to your account.
2. ๐ฅ Clone the Code¶
3. ๐ง Setup Development Environment¶
# Create virtual environment
python -m venv venv
source venv/bin/activate # Linux/macOS
# or venv\Scripts\activate # Windows
# Install development dependencies
pip install -e ".[dev]"
4. ๐ฟ Create Branch¶
5. ๐ป Start Development¶
Now you can start developing!
๐ Development Standards¶
๐ Code Style¶
We use the following tools to maintain code quality:
# Code formatting
black email_widget/
isort email_widget/
# Code linting
flake8 email_widget/
mypy email_widget/
๐ Commit Standards¶
We use Conventional Commits specification:
# Feature addition
git commit -m "feat: add new progress bar Widget"
# Bug fix
git commit -m "fix: fix encoding issue in table rendering"
# Documentation update
git commit -m "docs: update API documentation"
# Testing
git commit -m "test: add unit tests for TextWidget"
# Refactoring
git commit -m "refactor: optimize Email class rendering logic"
๐งช Testing Requirements¶
- All new features should have corresponding tests
- Bug fixes should include regression tests
- Ensure test coverage doesn't decrease
# Run tests
pytest tests/ -v
# Check coverage
pytest tests/ --cov=email_widget --cov-report=html
๐จ Creating New Widgets¶
If you want to add new components to EmailWidget, please follow these steps:
1. ๐ File Structure¶
email_widget/ewidget/widgets/
โโโ __init__.py
โโโ your_new_widget.py # New Widget file
โโโ ...
2. ๐ Widget Base Template¶
"""ไฝ ็ๆฐWidgetๅฎ็ฐ
่ฟไธชๆจกๅๆไพไบXXXๅ่ฝ็Widgetใ
"""
from typing import Optional
from email_widget.core.base import BaseWidget
class YourNewWidget(BaseWidget):
"""ไฝ ็ๆฐWidget็ฑป๏ผ็จไบXXXๅ่ฝใ
่ฏฆ็ป็็ฑป่ฏดๆ...
Attributes:
_your_attr: ๅฑๆง่ฏดๆ
Examples:
>>> widget = YourNewWidget()
>>> widget.set_something("value")
>>> html = widget.render_html()
"""
def __init__(self, widget_id: Optional[str] = None):
"""ๅๅงๅWidgetใ
Args:
widget_id: ๅฏ้็Widget ID
"""
super().__init__(widget_id)
# ๅๅงๅไฝ ็ๅฑๆง
self._your_attr = "default_value"
def set_something(self, value: str) -> 'YourNewWidget':
"""่ฎพ็ฝฎๆไธชๅฑๆงใ
Args:
value: ๅฑๆงๅผ
Returns:
่ฟๅselfไปฅๆฏๆ้พๅผ่ฐ็จ
"""
self._your_attr = value
return self
def _get_template_name(self) -> str:
"""่ทๅๆจกๆฟๅ็งฐใ
Returns:
ๆจกๆฟๆไปถๅ
"""
return "your_new_widget.html"
def render_html(self) -> str:
"""ๆธฒๆไธบHTMLๅญ็ฌฆไธฒใ
Returns:
ๆธฒๆๅ็HTMLๅญ็ฌฆไธฒ
"""
# ๅฎ็ฐไฝ ็ๆธฒๆ้ป่พ
return f'<div>{self._your_attr}</div>'
3. ๐ Documentation Requirements¶
- Use Google-style docstrings
- Provide detailed class and method descriptions
- Include usage examples
- Describe parameters and return values
4. ๐งช Test Files¶
Create corresponding test file tests/test_your_new_widget.py
:
import pytest
from email_widget.widgets import YourNewWidget
class TestYourNewWidget:
def test_init(self):
"""ๆต่ฏWidgetๅๅงๅ"""
widget = YourNewWidget()
assert widget._your_attr == "default_value"
def test_set_something(self):
"""ๆต่ฏ่ฎพ็ฝฎๅฑๆง"""
widget = YourNewWidget()
result = widget.set_something("test_value")
assert widget._your_attr == "test_value"
assert result is widget # ๆต่ฏ้พๅผ่ฐ็จ
def test_render_html(self):
"""ๆต่ฏHTMLๆธฒๆ"""
widget = YourNewWidget()
widget.set_something("test")
html = widget.render_html()
assert "test" in html
5. ๐ฆ Register Widget¶
Add import in email_widget/ewidget/widgets/__init__.py
:
๐ค Submitting Pull Request¶
1. โ Pre-submission Checklist¶
# Run all tests
pytest tests/ -v
# Check code style
black --check email_widget/
isort --check-only email_widget/
flake8 email_widget/
# Type checking
mypy email_widget/
2. ๐ PR Description Template¶
## ๐ Change Type
- [ ] ๐ Bug fix
- [ ] โจ New feature
- [ ] ๐ฅ Breaking change
- [ ] ๐ Documentation update
- [ ] ๐ง Code refactoring
- [ ] โก Performance optimization
- [ ] ๐งช Test improvement
## ๐ Change Description
Brief description of your changes...
## ๐งช Testing Description
- [ ] Added unit tests
- [ ] Passed all existing tests
- [ ] Manually tested functionality
## ๐ธ Screenshots/Examples
If UI-related changes, please provide screenshots or example code
## ๐ Related Issues
Fixes #(issue number)
3. ๐ Code Review¶
- We carefully review every PR
- May request some modifications
- Please be patient for review and actively respond to feedback
๐ Reporting Bugs¶
๐ Bug Report Template¶
When you find a bug, please create an Issue using the following template:
## ๐ Bug Description
Brief description of the problem encountered...
## ๐ Steps to Reproduce
1. Execute '...'
2. Click '....'
3. Scroll to '....'
4. See error
## ๐ฏ Expected Behavior
Describe what you expected to happen...
## ๐ธ Screenshots
If applicable, add screenshots to help explain the problem
## ๐ฅ๏ธ Environment Information
- OS: [e.g. Windows 10, macOS 12.0, Ubuntu 20.04]
- Python version: [e.g. 3.10.0]
- EmailWidget version: [e.g. 0.1.0]
## ๐ Additional Information
Add any other information about the problem...
๐ก Feature Suggestions¶
We welcome suggestions for new features! When creating a Feature Request, please:
- ๐ฏ Clear Requirements - Describe the feature you want in detail
- ๐ค Explain Reasons - Why is this feature needed
- ๐ญ Provide Solutions - If you have ideas, provide implementation solutions
- ๐ Give Examples - Provide usage examples
๐ Recognizing Contributors¶
We recognize contributors in the following places:
- ๐ CONTRIBUTORS.md file
- ๐ Release notes acknowledgments
- ๐ฌ Social media promotion
- ๐ Special badges (for major contributions)
๐ Contact Us¶
If you have any questions or need help:
- ๐ฌ GitHub Discussions
- ๐ GitHub Issues
- ๐ง Email
Thank you for your contribution!
Every contribution makes EmailWidget better. Regardless of the size of the contribution, we are very grateful! ๐